[include-cleaner] Treat a constructor call as a use of the class type.
authorHaojian Wu <hokein.wu@gmail.com>
Thu, 12 Jan 2023 11:40:12 +0000 (12:40 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Thu, 12 Jan 2023 12:12:14 +0000 (13:12 +0100)
Per the discussion in https://github.com/llvm/llvm-project/issues/59916.

Differential Revision: https://reviews.llvm.org/D141592

clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

index 18e6d5e21df07b6dad0c62631665e2c7e7ff4a04..6a5594e3d6d35e475678ab79e5ef9951ec627f6e 100644 (file)
@@ -104,7 +104,7 @@ public:
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-    report(E->getLocation(), E->getConstructor(),
+    report(E->getLocation(), getMemberProvider(E->getType()),
            E->getParenOrBraceRange().isValid() ? RefType::Explicit
                                                : RefType::Implicit);
     return true;
index c8959e7eb6735f99f4adebc3815b66417513ae2c..af7e155b58fb34880a63d0b744a89cfa7c199b20 100644 (file)
@@ -240,9 +240,10 @@ TEST(WalkAST, MemberExprs) {
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  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("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {