[clang-tools-extra] c23ae3f - [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 30 14:57:49 PDT 2020
Author: Nathan James
Date: 2020-07-30T22:57:33+01:00
New Revision: c23ae3f18ee3ff11671f4c62ffc66d150b1bcdc2
URL: https://github.com/llvm/llvm-project/commit/c23ae3f18ee3ff11671f4c62ffc66d150b1bcdc2
DIFF: https://github.com/llvm/llvm-project/commit/c23ae3f18ee3ff11671f4c62ffc66d150b1bcdc2.diff
LOG: [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D84926
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyModule.cpp
clang-tools-extra/clang-tidy/ClangTidyModule.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 63c83a0b9954e..90b39347bc9ac 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -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
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
index e9031d498eeff..c72bcd3e188ce 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -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;
}
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index 31cf4774a885a..7fd16c2a7b3c7 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -69,7 +69,7 @@ class ClangTidyCheckFactories {
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(); }
More information about the cfe-commits
mailing list