diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2020-06-19 00:40:00 +0100 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2020-06-19 00:40:10 +0100 |
commit | 8b0df1c1a992d203212901c1139665261e0bbc1c (patch) | |
tree | 65bfd9e2088530354603da1305749ada0ff576cf /clang/lib/Frontend/FrontendAction.cpp | |
parent | f672791e08fc819fd23f6331025570e24773ea82 (diff) | |
download | llvm-8b0df1c1a992d203212901c1139665261e0bbc1c.zip llvm-8b0df1c1a992d203212901c1139665261e0bbc1c.tar.gz llvm-8b0df1c1a992d203212901c1139665261e0bbc1c.tar.bz2 |
[NFC] Refactor Registry loops to range for
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index dc361b2..59a968b 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -157,10 +157,9 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, bool FoundAllPlugins = true; for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) { bool Found = false; - for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(), - ie = FrontendPluginRegistry::end(); - it != ie; ++it) { - if (it->getName() == Arg) + for (const FrontendPluginRegistry::entry &Plugin : + FrontendPluginRegistry::entries()) { + if (Plugin.getName() == Arg) Found = true; } if (!Found) { @@ -183,26 +182,24 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, // or after it (in AfterConsumers) std::vector<std::unique_ptr<ASTConsumer>> Consumers; std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers; - for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(), - ie = FrontendPluginRegistry::end(); - it != ie; ++it) { - std::unique_ptr<PluginASTAction> P = it->instantiate(); + for (const FrontendPluginRegistry::entry &Plugin : + FrontendPluginRegistry::entries()) { + std::unique_ptr<PluginASTAction> P = Plugin.instantiate(); PluginASTAction::ActionType ActionType = P->getActionType(); if (ActionType == PluginASTAction::Cmdline) { // This is O(|plugins| * |add_plugins|), but since both numbers are // way below 50 in practice, that's ok. - for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size(); - i != e; ++i) { - if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) { - ActionType = PluginASTAction::AddAfterMainAction; - break; - } - } + if (llvm::any_of(CI.getFrontendOpts().AddPluginActions, + [&](const std::string &PluginAction) { + return PluginAction == Plugin.getName(); + })) + ActionType = PluginASTAction::AddAfterMainAction; } if ((ActionType == PluginASTAction::AddBeforeMainAction || ActionType == PluginASTAction::AddAfterMainAction) && P->ParseArgs( - CI, CI.getFrontendOpts().PluginArgs[std::string(it->getName())])) { + CI, + CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())])) { std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile); if (ActionType == PluginASTAction::AddBeforeMainAction) { Consumers.push_back(std::move(PluginConsumer)); |