-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang-tidy] misc-include-cleaner: redundant insertion on different symbols from same header #65285
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@llvm/issue-subscribers-clang-tidy |
I cannot reproduce this issue in e22f04b, could you give more detail information about clang-tidy version and system environment. |
One easier way to reproduce is using https://github.com/llvm/llvm-project/blob/e22f04b597e03339739d42e3a60c05634bb74313/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp with this diff:
Test with Produces: // RUN: %check_clang_tidy %s misc-include-cleaner %t -- -- -I%S/Inputs -isystem%S/Inputs/system
#include "bar.h"
// CHECK-FIXES: {{^}}#include "baz.h"{{$}}
#include "baz.h"
#include "baz.h"
#include "public.h"
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: included header foo.h is not used directly [misc-include-cleaner]
// CHECK-FIXES: {{^}}
// CHECK-FIXES: {{^}}#include <string>{{$}}
#include <string>
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: included header vector.h is not used directly [misc-include-cleaner]
// CHECK-FIXES: {{^}}
int BarResult = bar();
int BazResult = baz();
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz" is directly included [misc-include-cleaner]
std::string HelloString;
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
int FooBarResult = foobar();
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
int BazResult1 = BAZ; |
Tested with latest main on linux. |
Or reproduce with randomly picked
You'll get this
|
@llvm/issue-subscribers-clang-include-cleaner |
@llvm/issue-subscribers-clang-tidy |
… multiple times (llvm#65431) `HeaderIncludes` won't update `ExistingIncludes` during inserting. We need to manage it in tidy check. Fixed: llvm#65285
Testcase:
command:
fixed test.c
baz.h
is redundant.The text was updated successfully, but these errors were encountered: