https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/227408
Follow the lowerCamelCase function naming convention and take StringRef. Extracted from #226773 >From 5ffb8a46e7559a86ed9178ab92605777eed49ee1 Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Tue, 29 Sep 2026 10:55:23 -0700 Subject: [PATCH] [Plugins] Rename PassPlugin::Load to load. NFC Follow the lowerCamelCase function naming convention and take StringRef. Extracted from #226773 --- clang/docs/InternalsManual.md | 2 +- clang/lib/Frontend/CompilerInstance.cpp | 2 +- .../tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 2 +- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 +- llvm/docs/WritingAnLLVMNewPMPass.md | 2 +- llvm/include/llvm/Plugins/PassPlugin.h | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/Plugins/PassPlugin.cpp | 6 +++--- llvm/tools/llc/lib/llcdriver.cpp | 2 +- llvm/tools/opt/optdriver.cpp | 2 +- .../Analysis/PluginInlineAdvisorAnalysisTest.cpp | 2 +- .../Analysis/PluginInlineOrderAnalysisTest.cpp | 2 +- llvm/unittests/Passes/Plugins/PluginsTest.cpp | 10 +++++----- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/clang/docs/InternalsManual.md b/clang/docs/InternalsManual.md index 58d1819b0a947..3b16082b0eeda 100644 --- a/clang/docs/InternalsManual.md +++ b/clang/docs/InternalsManual.md @@ -883,7 +883,7 @@ desired. void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(/*...*/) { // ... + for (auto &PluginFN : CodeGenOpts.PassPlugins) -+ if (auto PassPlugin = PassPlugin::Load(PluginFN)) ++ if (auto PassPlugin = PassPlugin::load(PluginFN)) + PassPlugin->registerPassBuilderCallbacks(PB); } ``` diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 87abcd38c1a92..28f61b7cff9f6 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1115,7 +1115,7 @@ void CompilerInstance::LoadRequestedPlugins() { // Load and store pass plugins for the back-end. for (const std::string &Path : getCodeGenOpts().PassPlugins) { - if (auto PassPlugin = llvm::PassPlugin::Load(Path)) { + if (auto PassPlugin = llvm::PassPlugin::load(Path)) { PassPlugins.emplace_back(std::make_unique<llvm::PassPlugin>(*PassPlugin)); } else { getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index a5ebd7d2ad06b..b59ef0304ad71 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -1534,7 +1534,7 @@ int main(int Argc, char **Argv) { NewArgv.push_back(Arg->getValue()); SmallVector<PassPlugin, 1> PluginList; PassPlugins.setCallback([&](const std::string &PluginPath) { - auto Plugin = PassPlugin::Load(PluginPath); + auto Plugin = PassPlugin::load(PluginPath); if (!Plugin) reportFatalUsageError(Plugin.takeError()); PluginList.emplace_back(Plugin.get()); diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 0396889fc57a4..aa06cc6ebb036 100644 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -182,7 +182,7 @@ bool executeCompilerInvocation(CompilerInstance *flang) { for (const std::string &path : flang->getInvocation().getCodeGenOpts().LLVMPassPlugins) { if (llvm::Expected<llvm::PassPlugin> passPlugin = - llvm::PassPlugin::Load(path)) { + llvm::PassPlugin::load(path)) { flang->addPassPlugin(std::make_unique<llvm::PassPlugin>(*passPlugin)); } else { unsigned diagID = flang->getDiagnostics().getCustomDiagID( diff --git a/llvm/docs/WritingAnLLVMNewPMPass.md b/llvm/docs/WritingAnLLVMNewPMPass.md index 065c6b5bb0238..4ea4578ae53b9 100644 --- a/llvm/docs/WritingAnLLVMNewPMPass.md +++ b/llvm/docs/WritingAnLLVMNewPMPass.md @@ -273,7 +273,7 @@ To make `PassBuilder` aware of dynamically linked pass plugins: ```c++ // Load plugin dynamically. -auto Plugin = PassPlugin::Load(PathToPlugin); +auto Plugin = PassPlugin::load(PathToPlugin); if (!Plugin) report_error(); // Register plugin extensions in PassBuilder. diff --git a/llvm/include/llvm/Plugins/PassPlugin.h b/llvm/include/llvm/Plugins/PassPlugin.h index e8da9c51c0a85..7c2d1a5de799f 100644 --- a/llvm/include/llvm/Plugins/PassPlugin.h +++ b/llvm/include/llvm/Plugins/PassPlugin.h @@ -75,7 +75,7 @@ class PassPlugin { /// \returns Returns an error if either the library cannot be found or loaded, /// there is no public entry point, or the plugin implements the wrong API /// version. - LLVM_ABI static Expected<PassPlugin> Load(const std::string &Filename); + LLVM_ABI static Expected<PassPlugin> load(StringRef Filename); /// Get the filename of the loaded plugin. StringRef getFilename() const { return Filename; } diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index d9a6551139d37..0d253647ae46c 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -207,7 +207,7 @@ static void RegisterPassPlugins(const Config &Conf, PassBuilder &PB) { // Load requested pass plugins and let them register pass builder callbacks for (auto &PluginFN : Conf.PassPluginFilenames) { - auto PassPlugin = PassPlugin::Load(PluginFN); + auto PassPlugin = PassPlugin::load(PluginFN); if (!PassPlugin) reportFatalUsageError(PassPlugin.takeError()); PassPlugin->registerPassBuilderCallbacks(PB); diff --git a/llvm/lib/Plugins/PassPlugin.cpp b/llvm/lib/Plugins/PassPlugin.cpp index 84d55fc513b78..9034060380e68 100644 --- a/llvm/lib/Plugins/PassPlugin.cpp +++ b/llvm/lib/Plugins/PassPlugin.cpp @@ -13,16 +13,16 @@ using namespace llvm; -Expected<PassPlugin> PassPlugin::Load(const std::string &Filename) { +Expected<PassPlugin> PassPlugin::load(StringRef Filename) { std::string Error; auto Library = - sys::DynamicLibrary::getPermanentLibrary(Filename.c_str(), &Error); + sys::DynamicLibrary::getPermanentLibrary(Filename.str().c_str(), &Error); if (!Library.isValid()) return make_error<StringError>(Twine("Could not load library '") + Filename + "': " + Error, inconvertibleErrorCode()); - PassPlugin P{Filename, Library}; + PassPlugin P{Filename.str(), Library}; // llvmGetPassPluginInfo should be resolved to the definition from the plugin // we are currently loading. diff --git a/llvm/tools/llc/lib/llcdriver.cpp b/llvm/tools/llc/lib/llcdriver.cpp index 7f0ee013cd947..6f19f1dbe295a 100644 --- a/llvm/tools/llc/lib/llcdriver.cpp +++ b/llvm/tools/llc/lib/llcdriver.cpp @@ -396,7 +396,7 @@ extern "C" int llcMain(int argc, char **argv) { SmallVector<PassPlugin, 1> PluginList; PassPlugins.setCallback([&](const std::string &PluginPath) { - auto Plugin = PassPlugin::Load(PluginPath); + auto Plugin = PassPlugin::load(PluginPath); if (!Plugin) reportFatalUsageError(Plugin.takeError()); PluginList.emplace_back(Plugin.get()); diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp index 46c6833515e18..2a219c4e5d568 100644 --- a/llvm/tools/opt/optdriver.cpp +++ b/llvm/tools/opt/optdriver.cpp @@ -445,7 +445,7 @@ optMain(int argc, char **argv, SmallVector<PassPlugin, 1> PluginList; PassPlugins.setCallback([&](const std::string &PluginPath) { - auto Plugin = PassPlugin::Load(PluginPath); + auto Plugin = PassPlugin::load(PluginPath); if (!Plugin) reportFatalUsageError(Plugin.takeError()); PluginList.emplace_back(Plugin.get()); diff --git a/llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp b/llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp index 61ab1820373c3..34c6dce215f20 100644 --- a/llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp +++ b/llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp @@ -63,7 +63,7 @@ struct CompilerInstance { void setupPlugin() { auto PluginPath = libPath(); ASSERT_NE("", PluginPath); - Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath); + Expected<PassPlugin> Plugin = PassPlugin::load(PluginPath); ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath; Plugin->registerPassBuilderCallbacks(PB); } diff --git a/llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp b/llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp index e9e839904a2e6..f5431cd7fdc85 100644 --- a/llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp +++ b/llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp @@ -45,7 +45,7 @@ struct CompilerInstance { void setupPlugin() { auto PluginPath = libPath(); ASSERT_NE("", PluginPath); - Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath); + Expected<PassPlugin> Plugin = PassPlugin::load(PluginPath); ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath; Plugin->registerPassBuilderCallbacks(PB); } diff --git a/llvm/unittests/Passes/Plugins/PluginsTest.cpp b/llvm/unittests/Passes/Plugins/PluginsTest.cpp index d4d519eb52a53..c2ef01c14dc73 100644 --- a/llvm/unittests/Passes/Plugins/PluginsTest.cpp +++ b/llvm/unittests/Passes/Plugins/PluginsTest.cpp @@ -48,7 +48,7 @@ TEST(PluginsTests, LoadPlugin) { auto PluginPath = LibPath(); ASSERT_NE("", PluginPath); - Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath); + Expected<PassPlugin> Plugin = PassPlugin::load(PluginPath); ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath; ASSERT_EQ(TEST_PLUGIN_NAME, Plugin->getPluginName()); @@ -76,18 +76,18 @@ TEST(PluginsTests, LoadMultiplePlugins) { ASSERT_NE("", DoublerPluginPath); ASSERT_NE("", TestPluginPath); - Expected<PassPlugin> DoublerPlugin1 = PassPlugin::Load(DoublerPluginPath); + Expected<PassPlugin> DoublerPlugin1 = PassPlugin::load(DoublerPluginPath); ASSERT_TRUE(!!DoublerPlugin1) << "Plugin path: " << DoublerPlugin1->getFilename(); - Expected<PassPlugin> TestPlugin = PassPlugin::Load(TestPluginPath); + Expected<PassPlugin> TestPlugin = PassPlugin::load(TestPluginPath); ASSERT_TRUE(!!TestPlugin) << "Plugin path: " << TestPlugin->getFilename(); // If llvmGetPassPluginInfo is resolved as a weak symbol taking into account - // all loaded symbols, the second call to PassPlugin::Load will actually + // all loaded symbols, the second call to PassPlugin::load will actually // return the llvmGetPassPluginInfo from the most recently loaded plugin, in // this case TestPlugin. - Expected<PassPlugin> DoublerPlugin2 = PassPlugin::Load(DoublerPluginPath); + Expected<PassPlugin> DoublerPlugin2 = PassPlugin::load(DoublerPluginPath); ASSERT_TRUE(!!DoublerPlugin2) << "Plugin path: " << DoublerPlugin2->getFilename(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
