[clang] 3e9d04f - Revert "[clang-repl] Allow loading of plugins in clang-repl."

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 4 23:11:31 PDT 2021


Author: Vassil Vassilev
Date: 2021-10-05T06:10:38Z
New Revision: 3e9d04f7e422c3e62d9adac506df8e7d42acc206

URL: https://github.com/llvm/llvm-project/commit/3e9d04f7e422c3e62d9adac506df8e7d42acc206
DIFF: https://github.com/llvm/llvm-project/commit/3e9d04f7e422c3e62d9adac506df8e7d42acc206.diff

LOG: Revert "[clang-repl] Allow loading of plugins in clang-repl."

This reverts commit 81fb640f83b6a5d099f9124739ab3049be79ea56 due to bot failures:
https://lab.llvm.org/buildbot#builders/57/builds/10807

Added: 
    

Modified: 
    clang/include/clang/Frontend/CompilerInstance.h
    clang/lib/Frontend/CompilerInstance.cpp
    clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
    clang/lib/Interpreter/IncrementalParser.cpp
    clang/tools/clang-repl/CMakeLists.txt
    clang/tools/clang-repl/ClangRepl.cpp

Removed: 
    clang/test/Interpreter/plugins.cpp


################################################################################
diff  --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index 74e152ea59520..861b15020329b 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -219,9 +219,6 @@ class CompilerInstance : public ModuleLoader {
   // of the context or else not CompilerInstance specific.
   bool ExecuteAction(FrontendAction &Act);
 
-  /// Load the list of plugins requested in the \c FrontendOptions.
-  void LoadRequestedPlugins();
-
   /// }
   /// @name Compiler Invocation and Options
   /// {

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index a9c7566163560..8de2e75388bed 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -23,7 +23,6 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/LogDiagnosticPrinter.h"
 #include "clang/Frontend/SerializedDiagnosticPrinter.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -1030,27 +1029,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
   return !getDiagnostics().getClient()->getNumErrors();
 }
 
-void CompilerInstance::LoadRequestedPlugins() {
-  // Load any requested plugins.
-  for (const std::string &Path : getFrontendOpts().Plugins) {
-    std::string Error;
-    if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
-      getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
-          << Path << Error;
-  }
-
-  // Check if any of the loaded plugins replaces the main AST action
-  for (const FrontendPluginRegistry::entry &Plugin :
-       FrontendPluginRegistry::entries()) {
-    std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
-    if (P->getActionType() == PluginASTAction::ReplaceAction) {
-      getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
-      getFrontendOpts().ActionName = Plugin.getName().str();
-      break;
-    }
-  }
-}
-
 /// Determine the appropriate source input kind based on language
 /// options.
 static Language getLanguageFromOptions(const LangOptions &LangOpts) {

diff  --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index dc8409f88dfad..b95851e380d28 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -203,7 +203,24 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
     return true;
   }
 
-  Clang->LoadRequestedPlugins();
+  // Load any requested plugins.
+  for (const std::string &Path : Clang->getFrontendOpts().Plugins) {
+    std::string Error;
+    if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
+      Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
+        << Path << Error;
+  }
+
+  // Check if any of the loaded plugins replaces the main AST action
+  for (const FrontendPluginRegistry::entry &Plugin :
+       FrontendPluginRegistry::entries()) {
+    std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
+    if (P->getActionType() == PluginASTAction::ReplaceAction) {
+      Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
+      Clang->getFrontendOpts().ActionName = Plugin.getName().str();
+      break;
+    }
+  }
 
   // Honor -mllvm.
   //

diff  --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index 6c5a26e599033..897e2cd1aaed8 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -65,8 +65,6 @@ class IncrementalAction : public WrapperFrontendAction {
           case frontend::ParseSyntaxOnly:
             Act = CreateFrontendAction(CI);
             break;
-          case frontend::PluginAction:
-            LLVM_FALLTHROUGH;
           case frontend::EmitAssembly:
             LLVM_FALLTHROUGH;
           case frontend::EmitObj:

diff  --git a/clang/test/Interpreter/plugins.cpp b/clang/test/Interpreter/plugins.cpp
deleted file mode 100644
index 032f704624ad7..0000000000000
--- a/clang/test/Interpreter/plugins.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -load -Xcc -Xclang \
-// RUN:            -Xcc %llvmshlibdir/PrintFunctionNames%pluginext -Xcc -Xclang\
-// RUN:            -Xcc -add-plugin -Xcc -Xclang -Xcc print-fns 2>&1 | FileCheck %s
-// REQUIRES: host-supports-jit, plugins, examples
-
-int i = 10;
-extern "C" int printf(const char*,...);
-auto r1 = printf("i = %d\n", i);
-quit
-
-
-// CHECK: top-level-decl: "i"
-// CHECK-NEXT: top-level-decl: "r1"
-// CHECK-NEXT: i = 10

diff  --git a/clang/tools/clang-repl/CMakeLists.txt b/clang/tools/clang-repl/CMakeLists.txt
index a40913ae9abb9..060c62aa419c7 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -16,8 +16,3 @@ clang_target_link_libraries(clang-repl PUBLIC
   clangInterpreter
   clangTooling
   )
-
-# Support plugins.
-if(CLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(clang-repl)
-endif()

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp
index 72a1a3e5910af..ba6bb11abc867 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -80,9 +80,6 @@ int main(int argc, const char **argv) {
   llvm::install_fatal_error_handler(LLVMErrorHandler,
                                     static_cast<void *>(&CI->getDiagnostics()));
 
-  // Load any requested plugins.
-  CI->LoadRequestedPlugins();
-
   auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
   for (const std::string &input : OptInputs) {
     if (auto Err = Interp->ParseAndExecute(input))


        


More information about the cfe-commits mailing list