summaryrefslogtreecommitdiff
path: root/clang-tools-extra/include-cleaner
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2022-12-19 09:22:42 +0100
committerHaojian Wu <hokein.wu@gmail.com>2022-12-19 19:46:18 +0100
commit8a7ea764b2583e93fe0a332739c391d3bb11a867 (patch)
tree34e49d87e1bf256cae29e0d2affa862dfc8d657f /clang-tools-extra/include-cleaner
parentc42e50fede53bbcce79095e7c8115f26826c81ae (diff)
downloadllvm-8a7ea764b2583e93fe0a332739c391d3bb11a867.tar.gz
[include-cleaner] Base-type usage from member exprs is implicit.
Per the discussion on https://reviews.llvm.org/D140095#inline-1352956 Differential Revision: https://reviews.llvm.org/D140284
Diffstat (limited to 'clang-tools-extra/include-cleaner')
-rw-r--r--clang-tools-extra/include-cleaner/lib/WalkAST.cpp6
-rw-r--r--clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp34
2 files changed, 20 insertions, 20 deletions
diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index cf2373d43389..f32221018caf 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -80,12 +80,12 @@ public:
//
// FIXME: support dependent types, e.g., "std::vector<T>().size()".
QualType Type = E->getBase()->IgnoreImpCasts()->getType();
- // FIXME: this should report as implicit reference.
- report(E->getMemberLoc(), getMemberProvider(Type));
+ report(E->getMemberLoc(), getMemberProvider(Type), RefType::Implicit);
return true;
}
bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) {
- report(E->getMemberLoc(), getMemberProvider(E->getBaseType()));
+ report(E->getMemberLoc(), getMemberProvider(E->getBaseType()),
+ RefType::Implicit);
return true;
}
diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 2a2fbc438ab9..ca2eb25eceee 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -180,32 +180,32 @@ TEST(WalkAST, TemplateNames) {
}
TEST(WalkAST, MemberExprs) {
- testWalk("struct $explicit^S { void foo(); };", "void foo() { S{}.^foo(); }");
+ testWalk("struct $implicit^S { void foo(); };", "void foo() { S{}.^foo(); }");
testWalk(
- "struct S { void foo(); }; struct $explicit^X : S { using S::foo; };",
+ "struct S { void foo(); }; struct $implicit^X : S { using S::foo; };",
"void foo() { X{}.^foo(); }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"void fun(Derived d) { d.^a; }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"void fun(Derived* d) { d->^a; }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"void fun(Derived& d) { d.^a; }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"void fun() { Derived().^a; }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"Derived foo(); void fun() { foo().^a; }");
- testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ testWalk("struct Base { int a; }; struct $implicit^Derived : public Base {};",
"Derived& foo(); void fun() { foo().^a; }");
testWalk(R"cpp(
template <typename T>
struct unique_ptr {
T *operator->();
};
- struct $explicit^Foo { int a; };)cpp",
+ struct $implicit^Foo { int a; };)cpp",
"void test(unique_ptr<Foo> &V) { V->^a; }");
testWalk(R"cpp(
template <typename T>
- struct $explicit^unique_ptr {
+ struct $implicit^unique_ptr {
void release();
};
struct Foo {};)cpp",
@@ -213,28 +213,28 @@ TEST(WalkAST, MemberExprs) {
// Respect the sugar type (typedef, using-type).
testWalk(R"cpp(
namespace ns { struct Foo { int a; }; }
- using $explicit^Bar = ns::Foo;)cpp",
+ using $implicit^Bar = ns::Foo;)cpp",
"void test(Bar b) { b.^a; }");
testWalk(R"cpp(
namespace ns { struct Foo { int a; }; }
- using ns::$explicit^Foo;)cpp",
+ using ns::$implicit^Foo;)cpp",
"void test(Foo b) { b.^a; }");
testWalk(R"cpp(
namespace ns { struct Foo { int a; }; }
namespace ns2 { using Bar = ns::Foo; }
- using ns2::$explicit^Bar;
+ using ns2::$implicit^Bar;
)cpp",
"void test(Bar b) { b.^a; }");
testWalk(R"cpp(
namespace ns { template<typename> struct Foo { int a; }; }
- using ns::$explicit^Foo;)cpp",
+ using ns::$implicit^Foo;)cpp",
"void k(Foo<int> b) { b.^a; }");
// Test the dependent-type case (CXXDependentScopeMemberExpr)
- testWalk("template<typename T> struct $explicit^Base { void method(); };",
+ testWalk("template<typename T> struct $implicit^Base { void method(); };",
"template<typename T> void k(Base<T> t) { t.^method(); }");
- testWalk("template<typename T> struct $explicit^Base { void method(); };",
+ testWalk("template<typename T> struct $implicit^Base { void method(); };",
"template<typename T> void k(Base<T>& t) { t.^method(); }");
- testWalk("template<typename T> struct $explicit^Base { void method(); };",
+ testWalk("template<typename T> struct $implicit^Base { void method(); };",
"template<typename T> void k(Base<T>* t) { t->^method(); }");
}