This revision was automatically updated to reflect the committed changes. Closed by commit rG279b4985ed4f: [include-cleaner] Always treat constructor calls as implicit (authored by kadircet).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144582/new/ https://reviews.llvm.org/D144582 Files: clang-tools-extra/include-cleaner/lib/WalkAST.cpp clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp =================================================================== --- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -111,6 +111,9 @@ testWalk("struct $explicit^S {};", "^S *y;"); testWalk("enum $explicit^E {};", "^E *y;"); testWalk("struct $explicit^S { static int x; };", "int y = ^S::x;"); + // One explicit call from the TypeLoc in constructor spelling, another + // implicit reference through the constructor call. + testWalk("struct $explicit^$implicit^S { static int x; };", "auto y = ^S();"); } TEST(WalkAST, Alias) { @@ -241,7 +244,7 @@ TEST(WalkAST, ConstructExprs) { testWalk("struct $implicit^S {};", "S ^t;"); testWalk("struct $implicit^S { S(); };", "S ^t;"); - testWalk("struct $explicit^S { S(int); };", "S ^t(42);"); + testWalk("struct $implicit^S { S(int); };", "S ^t(42);"); testWalk("struct $implicit^S { S(int); };", "S t = ^42;"); testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;"); } Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp =================================================================== --- clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -102,9 +102,12 @@ } bool VisitCXXConstructExpr(CXXConstructExpr *E) { + // Always treat consturctor calls as implicit. We'll have an explicit + // reference for the constructor calls that mention the type-name (through + // TypeLocs). This reference only matters for cases where there's no + // explicit syntax at all or there're only braces. report(E->getLocation(), getMemberProvider(E->getType()), - E->getParenOrBraceRange().isValid() ? RefType::Explicit - : RefType::Implicit); + RefType::Implicit); return true; }
Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp =================================================================== --- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -111,6 +111,9 @@ testWalk("struct $explicit^S {};", "^S *y;"); testWalk("enum $explicit^E {};", "^E *y;"); testWalk("struct $explicit^S { static int x; };", "int y = ^S::x;"); + // One explicit call from the TypeLoc in constructor spelling, another + // implicit reference through the constructor call. + testWalk("struct $explicit^$implicit^S { static int x; };", "auto y = ^S();"); } TEST(WalkAST, Alias) { @@ -241,7 +244,7 @@ TEST(WalkAST, ConstructExprs) { testWalk("struct $implicit^S {};", "S ^t;"); testWalk("struct $implicit^S { S(); };", "S ^t;"); - testWalk("struct $explicit^S { S(int); };", "S ^t(42);"); + testWalk("struct $implicit^S { S(int); };", "S ^t(42);"); testWalk("struct $implicit^S { S(int); };", "S t = ^42;"); testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;"); } Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp =================================================================== --- clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -102,9 +102,12 @@ } bool VisitCXXConstructExpr(CXXConstructExpr *E) { + // Always treat consturctor calls as implicit. We'll have an explicit + // reference for the constructor calls that mention the type-name (through + // TypeLocs). This reference only matters for cases where there's no + // explicit syntax at all or there're only braces. report(E->getLocation(), getMemberProvider(E->getType()), - E->getParenOrBraceRange().isValid() ? RefType::Explicit - : RefType::Implicit); + RefType::Implicit); return true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits