File tree 4 files changed +29
-2
lines changed
4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -337,6 +337,10 @@ Changes in existing checks
337
337
<clang-tidy/checks/misc/header-include-cycle>` check by avoiding crash for self
338
338
include cycles.
339
339
340
+ - Improved :doc: `misc-include-cleaner
341
+ <clang-tidy/checks/misc/include-cleaner>` check by avoiding false positives for
342
+ the functions with the same name as standard library functions.
343
+
340
344
- Improved :doc: `misc-unused-using-decls
341
345
<clang-tidy/checks/misc/unused-using-decls>` check by replacing the local
342
346
option `HeaderFileExtensions ` by the global option of the same name.
Original file line number Diff line number Diff line change 14
14
#include " clang/AST/DeclTemplate.h"
15
15
#include " clang/Tooling/Inclusions/StandardLibrary.h"
16
16
#include " llvm/Support/Casting.h"
17
+ #include " llvm/Support/raw_ostream.h"
17
18
#include < utility>
18
19
#include < vector>
19
20
@@ -40,8 +41,11 @@ Hints declHints(const Decl *D) {
40
41
std::vector<Hinted<SymbolLocation>> locateDecl (const Decl &D) {
41
42
std::vector<Hinted<SymbolLocation>> Result;
42
43
// FIXME: Should we also provide physical locations?
43
- if (auto SS = tooling::stdlib::Recognizer ()(&D))
44
- return {{*SS, Hints::CompleteSymbol}};
44
+ if (auto SS = tooling::stdlib::Recognizer ()(&D)) {
45
+ Result.push_back ({*SS, Hints::CompleteSymbol});
46
+ if (!D.hasBody ())
47
+ return Result;
48
+ }
45
49
// FIXME: Signal foreign decls, e.g. a forward declaration not owned by a
46
50
// library. Some useful signals could be derived by checking the DeclContext.
47
51
// Most incidental forward decls look like:
Original file line number Diff line number Diff line change @@ -628,6 +628,17 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) {
628
628
tooling::stdlib::Header::named (" <assert.h>" )));
629
629
}
630
630
631
+ TEST_F (HeadersForSymbolTest, NonStandardHeaders) {
632
+ Inputs.Code = " void assert() {}" ;
633
+ buildAST ();
634
+ EXPECT_THAT (
635
+ headersFor (" assert" ),
636
+ // Respect the ordering from the stdlib mapping.
637
+ UnorderedElementsAre (physicalHeader (" input.mm" ),
638
+ tooling::stdlib::Header::named (" <cassert>" ),
639
+ tooling::stdlib::Header::named (" <assert.h>" )));
640
+ }
641
+
631
642
TEST_F (HeadersForSymbolTest, ExporterNoNameMatch) {
632
643
Inputs.Code = R"cpp(
633
644
#include "exporter/foo.h"
Original file line number Diff line number Diff line change @@ -15,3 +15,11 @@ std::string HelloString;
15
15
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
16
16
int FooBarResult = foobar();
17
17
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
18
+
19
+ namespace valid {
20
+
21
+ namespace gh93335 {
22
+ void log2 () {}
23
+ } // namespace gh93335
24
+
25
+ } // namespace valid
You can’t perform that action at this time.
0 commit comments