[clang-tools-extra] r272132 - [include-fixer] do not add enum forward declaration into symbol index table.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 8 05:13:15 PDT 2016


Author: ioeric
Date: Wed Jun  8 07:13:14 2016
New Revision: 272132

URL: http://llvm.org/viewvc/llvm-project?rev=272132&view=rev
Log:
[include-fixer] do not add enum forward declaration into symbol index table.

Modified:
    clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
    clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=272132&r1=272131&r2=272132&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp Wed Jun  8 07:13:14 2016
@@ -183,10 +183,10 @@ void FindAllSymbols::registerMatchers(Ma
       this);
 
   // Matchers for enum declarations.
-  MatchFinder->addMatcher(
-      enumDecl(CommonFilter, anyOf(HasNSOrTUCtxMatcher, ExternCMatcher))
-          .bind("decl"),
-      this);
+  MatchFinder->addMatcher(enumDecl(CommonFilter, isDefinition(),
+                                   anyOf(HasNSOrTUCtxMatcher, ExternCMatcher))
+                              .bind("decl"),
+                          this);
 
   // Matchers for enum constant declarations.
   // We only match the enum constants in non-scoped enum declarations which are

Modified: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=272132&r1=272131&r2=272132&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Wed Jun  8 07:13:14 2016
@@ -334,6 +334,7 @@ TEST_F(FindAllSymbolsTest, EnumTest) {
       public:
         enum A_ENUM { X1, X2 };
       };
+      enum DECL : int;
       )";
   runFindAllSymbols(Code);
 
@@ -376,6 +377,10 @@ TEST_F(FindAllSymbolsTest, EnumTest) {
                       {{SymbolInfo::ContextType::EnumDecl, "A_ENUM"},
                        {SymbolInfo::ContextType::Record, "A"}});
   EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol =
+      SymbolInfo("DECL", SymbolInfo::SymbolKind::EnumDecl, HeaderName, 9, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {




More information about the cfe-commits mailing list