[clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D84926
This commit is contained in:
Nathan James 2020-07-30 22:57:32 +01:00
parent 1e7f026c3b
commit c23ae3f18e
No known key found for this signature in database
GPG key ID: CC007AFCDA90AA5F
3 changed files with 6 additions and 6 deletions

View file

@ -449,8 +449,8 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
std::vector<std::string> CheckNames;
for (const auto &CheckFactory : *CheckFactories) {
if (Context.isCheckEnabled(CheckFactory.first))
CheckNames.push_back(CheckFactory.first);
if (Context.isCheckEnabled(CheckFactory.getKey()))
CheckNames.emplace_back(CheckFactory.getKey());
}
#if CLANG_ENABLE_STATIC_ANALYZER

View file

@ -18,15 +18,15 @@ namespace tidy {
void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
Factories[std::string(Name)] = std::move(Factory);
Factories.insert_or_assign(Name, std::move(Factory));
}
std::vector<std::unique_ptr<ClangTidyCheck>>
ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
for (const auto &Factory : Factories) {
if (Context->isCheckEnabled(Factory.first))
Checks.emplace_back(Factory.second(Factory.first, Context));
if (Context->isCheckEnabled(Factory.getKey()))
Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
}
return Checks;
}

View file

@ -69,7 +69,7 @@ public:
std::vector<std::unique_ptr<ClangTidyCheck>>
createChecks(ClangTidyContext *Context);
typedef std::map<std::string, CheckFactory> FactoryMap;
typedef llvm::StringMap<CheckFactory> FactoryMap;
FactoryMap::const_iterator begin() const { return Factories.begin(); }
FactoryMap::const_iterator end() const { return Factories.end(); }
bool empty() const { return Factories.empty(); }