[PATCH] D141592: [include-cleaner] Treat a constructor call as a use of the class type.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 12 03:41:54 PST 2023
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.
Per the discussion in https://github.com/llvm/llvm-project/issues/59916.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141592
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
@@ -240,9 +240,10 @@
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) {
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
@@ -104,7 +104,7 @@
}
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
- report(E->getLocation(), E->getConstructor(),
+ report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141592.488586.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230112/9fcd2407/attachment.bin>
More information about the cfe-commits
mailing list