diff options
| author | Haojian Wu <hokein@google.com> | 2016-05-13 15:17:17 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2016-05-13 15:17:17 +0000 |
| commit | 631e5f23f98eff23abd3b1b62e812053a7cd6a6a (patch) | |
| tree | fed617df34a2ff08d8bd6cbecdb3a250cd345d72 /clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp | |
| parent | b79ab27853b8b4c9473005d5418895c1450c72c7 (diff) | |
| download | bcm5719-llvm-631e5f23f98eff23abd3b1b62e812053a7cd6a6a.tar.gz bcm5719-llvm-631e5f23f98eff23abd3b1b62e812053a7cd6a6a.zip | |
[include-fixer] Simplify unittest code.
Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20232
llvm-svn: 269427
Diffstat (limited to 'clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp')
| -rw-r--r-- | clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp b/clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp index 388bab20cb1..7f851741c2e 100644 --- a/clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp +++ b/clang-tools-extra/include-fixer/InMemorySymbolIndex.cpp @@ -15,24 +15,9 @@ namespace clang { namespace include_fixer { InMemorySymbolIndex::InMemorySymbolIndex( - const std::map<std::string, std::vector<std::string>> &LookupTable) { - for (const auto &Entry : LookupTable) { - llvm::StringRef Identifier(Entry.first); - llvm::SmallVector<llvm::StringRef, 8> Names; - Identifier.split(Names, "::"); - for (const auto &Header : Entry.second) { - std::vector<SymbolInfo::Context> Contexts; - for (auto IdentiferContext = Names.rbegin() + 1; - IdentiferContext != Names.rend(); ++IdentiferContext) { - Contexts.emplace_back(SymbolInfo::ContextType::Namespace, - *IdentiferContext); - } - - SymbolInfo Symbol(Names.back(), SymbolInfo::SymbolKind::Class, Header, - Contexts, 1); - this->LookupTable[Symbol.getName()].push_back(Symbol); - } - } + const std::vector<SymbolInfo> &Symbols) { + for (const auto &Symbol : Symbols) + LookupTable[Symbol.getName()].push_back(Symbol); } std::vector<SymbolInfo> |

