[PATCH] D20354: [include-fixer] Ignore non-scoped enum declaration during search.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 02:11:01 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269890: [include-fixer] Ignore non-scoped enum declaration during search. (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D20354?vs=57572&id=57577#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20354
Files:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===================================================================
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -41,10 +41,16 @@
auto SymbolContext = Symbol.getContexts().begin();
auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
// Match the remaining context names.
- for (; IdentiferContext != Names.rend() &&
- SymbolContext != Symbol.getContexts().end();
- ++IdentiferContext, ++SymbolContext) {
- if (SymbolContext->second != *IdentiferContext) {
+ while (IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end()) {
+ if (SymbolContext->second == *IdentiferContext) {
+ ++IdentiferContext;
+ ++SymbolContext;
+ } else if (SymbolContext->first ==
+ find_all_symbols::SymbolInfo::ContextType::EnumDecl) {
+ // Skip non-scoped enum context.
+ ++SymbolContext;
+ } else {
IsMatched = false;
break;
}
Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -62,6 +62,10 @@
SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
1, {{SymbolInfo::ContextType::Namespace, "b"},
{SymbolInfo::ContextType::Namespace, "a"}}),
+ SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"",
+ 1, {{SymbolInfo::ContextType::EnumDecl, "Color"},
+ {SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
};
auto SymbolIndexMgr = llvm::make_unique<include_fixer::SymbolIndexManager>();
SymbolIndexMgr->addSymbolIndex(
@@ -166,6 +170,12 @@
EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
runIncludeFixer("namespace A { b::bar b; }\n"));
}
+
+TEST(IncludeFixer, EnumConstantSymbols) {
+ EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+ runIncludeFixer("int test = a::b::Green;\n"));
+}
+
} // namespace
} // namespace include_fixer
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20354.57577.patch
Type: text/x-patch
Size: 2478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160518/72e943ac/attachment.bin>
More information about the cfe-commits
mailing list