hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a subscriber: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140284

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
@@ -180,32 +180,32 @@
 }
 
 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,21 +213,21 @@
   // 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; }");
 }
 
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
@@ -80,8 +80,7 @@
     //
     // 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;
   }
 


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
@@ -180,32 +180,32 @@
 }
 
 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,21 +213,21 @@
   // 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; }");
 }
 
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
@@ -80,8 +80,7 @@
     //
     // 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;
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D140284: [include-clean... Haojian Wu via Phabricator via cfe-commits

Reply via email to