Skip to content

[InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action #82293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

cyndyishida
Copy link
Member

Installapi has important distinctions when compared to the clang driver, so much that, it doesn't make much sense to try to integrate into it.

This patch partially reverts the CC1 action & driver support to replace with its own driver as a clang tool.

For distribution, we could use LLVM_TOOL_LLVM_DRIVER_BUILD mechanism for integrating the functionality into clang such that the toolchain size is less impacted.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Feb 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Cyndy Ishida (cyndyishida)

Changes

Installapi has important distinctions when compared to the clang driver, so much that, it doesn't make much sense to try to integrate into it.

This patch partially reverts the CC1 action & driver support to replace with its own driver as a clang tool.

For distribution, we could use LLVM_TOOL_LLVM_DRIVER_BUILD mechanism for integrating the functionality into clang such that the toolchain size is less impacted.


Patch is 41.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/82293.diff

29 Files Affected:

  • (modified) clang/include/clang/Driver/Action.h (-12)
  • (modified) clang/include/clang/Driver/Options.td (+2-7)
  • (modified) clang/include/clang/Driver/Types.def (-1)
  • (modified) clang/include/clang/Frontend/CompilerInstance.h (-7)
  • (modified) clang/include/clang/Frontend/CompilerInvocation.h (+7-14)
  • (modified) clang/include/clang/Frontend/FrontendActions.h (-10)
  • (modified) clang/include/clang/Frontend/FrontendOptions.h (-3)
  • (removed) clang/include/clang/Frontend/InstallAPIOptions.h (-28)
  • (modified) clang/include/clang/InstallAPI/Context.h (+8-7)
  • (modified) clang/lib/Driver/Action.cpp (+2-8)
  • (modified) clang/lib/Driver/Driver.cpp (+1-15)
  • (modified) clang/lib/Driver/ToolChain.cpp (-1)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (-11)
  • (modified) clang/lib/Frontend/CMakeLists.txt (-3)
  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (+1-40)
  • (removed) clang/lib/Frontend/InstallAPIConsumer.cpp (-43)
  • (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+2-3)
  • (modified) clang/lib/InstallAPI/CMakeLists.txt (+1)
  • (modified) clang/lib/InstallAPI/Context.cpp (+6-7)
  • (modified) clang/test/CMakeLists.txt (+1)
  • (removed) clang/test/Driver/installapi.h (-13)
  • (modified) clang/test/InstallAPI/installapi-basic.test (+38-1)
  • (added) clang/test/InstallAPI/installapi-driver-invalid-options.test (+4)
  • (modified) clang/test/lit.cfg.py (+1)
  • (modified) clang/tools/CMakeLists.txt (+1)
  • (added) clang/tools/clang-installapi/CMakeLists.txt (+20)
  • (added) clang/tools/clang-installapi/ClangInstallAPI.cpp (+124)
  • (added) clang/tools/clang-installapi/Options.cpp (+106)
  • (added) clang/tools/clang-installapi/Options.h (+85)
diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h
index 2768e2f5df1a9e..04fa8b01b418f8 100644
--- a/clang/include/clang/Driver/Action.h
+++ b/clang/include/clang/Driver/Action.h
@@ -59,7 +59,6 @@ class Action {
     PreprocessJobClass,
     PrecompileJobClass,
     ExtractAPIJobClass,
-    InstallAPIJobClass,
     AnalyzeJobClass,
     MigrateJobClass,
     CompileJobClass,
@@ -449,17 +448,6 @@ class ExtractAPIJobAction : public JobAction {
   void addHeaderInput(Action *Input) { getInputs().push_back(Input); }
 };
 
-class InstallAPIJobAction : public JobAction {
-  void anchor() override;
-
-public:
-  InstallAPIJobAction(Action *Input, types::ID OutputType);
-
-  static bool classof(const Action *A) {
-    return A->getKind() == InstallAPIJobClass;
-  }
-};
-
 class AnalyzeJobAction : public JobAction {
   void anchor() override;
 
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 53f23f9abb4c96..6e58e63590b675 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -336,8 +336,6 @@ class AnalyzerOpts<string base>
   : KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {}
 class MigratorOpts<string base>
   : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
-class InstallAPIOpts<string base>
-  : KeyPathAndMacro<"InstallAPIOpts.", base, "INSTALLAPI_"> {}
 
 // A boolean option which is opt-in in CC1. The positive option exists in CC1 and
 // Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
@@ -1143,8 +1141,7 @@ def config_user_dir_EQ : Joined<["--"], "config-user-dir=">,
 def coverage : Flag<["-", "--"], "coverage">, Group<Link_Group>,
   Visibility<[ClangOption, CLOption]>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>;
-def current__version : JoinedOrSeparate<["-"], "current_version">,
-  Visibility<[ClangOption, CC1Option]>;
+def current__version : JoinedOrSeparate<["-"], "current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
   HelpText<"Add directory to the C++ SYSTEM include search path">,
   Visibility<[ClangOption, CC1Option]>,
@@ -4324,9 +4321,7 @@ def verify_pch : Flag<["-"], "verify-pch">, Group<Action_Group>,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Load and verify that a pre-compiled header file is not stale">;
 def init : Separate<["-"], "init">;
-def install__name : Separate<["-"], "install_name">,
-  Visibility<[ClangOption, CC1Option]>,
-  MarshallingInfoString<InstallAPIOpts<"InstallName">>;
+def install__name : Separate<["-"], "install_name">;
 def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Set the -iwithprefix/-iwithprefixbefore prefix">, MetaVarName<"<dir>">;
diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def
index 570a53441d1c74..f72c27e1ee7019 100644
--- a/clang/include/clang/Driver/Types.def
+++ b/clang/include/clang/Driver/Types.def
@@ -94,7 +94,6 @@ TYPE("lto-bc",                   LTO_BC,       INVALID,         "o",      phases
 TYPE("ast",                      AST,          INVALID,         "ast",    phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("ifs",                      IFS,          INVALID,         "ifs",    phases::IfsMerge)
 TYPE("ifs-cpp",                  IFS_CPP,      INVALID,         "ifs",    phases::Compile, phases::IfsMerge)
-TYPE("tbd",                      TextAPI,      INVALID,         "tbd",    phases::Precompile)
 TYPE("pcm",                      ModuleFile,   INVALID,         "pcm",    phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("header-unit",              HeaderUnit,   INVALID,         "pcm",    phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("plist",                    Plist,        INVALID,         "plist",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index 6eb7972f86ca5b..ac2f940769fbe9 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -294,13 +294,6 @@ class CompilerInstance : public ModuleLoader {
     return Invocation->getFrontendOpts();
   }
 
-  InstallAPIOptions &getInstallAPIOpts() {
-    return Invocation->getInstallAPIOpts();
-  }
-  const InstallAPIOptions &getInstallAPIOpts() const {
-    return Invocation->getInstallAPIOpts();
-  }
-
   HeaderSearchOptions &getHeaderSearchOpts() {
     return Invocation->getHeaderSearchOpts();
   }
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index a01d9695dce203..8d75efdd23488b 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/LangStandard.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendOptions.h"
-#include "clang/Frontend/InstallAPIOptions.h"
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
@@ -112,9 +111,6 @@ class CompilerInvocationBase {
   /// Options controlling preprocessed output.
   std::shared_ptr<PreprocessorOutputOptions> PreprocessorOutputOpts;
 
-  /// Options controlling InstallAPI operations and output.
-  std::shared_ptr<InstallAPIOptions> InstallAPIOpts;
-
   /// Dummy tag type whose instance can be passed into the constructor to
   /// prevent creation of the reference-counted option objects.
   struct EmptyConstructor {};
@@ -149,7 +145,6 @@ class CompilerInvocationBase {
   const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
     return *PreprocessorOutputOpts;
   }
-  const InstallAPIOptions &getInstallAPIOpts() const { return *InstallAPIOpts; }
   /// @}
 
   /// Command line generation.
@@ -229,20 +224,19 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @{
   // Note: These need to be pulled in manually. Otherwise, they get hidden by
   // the mutable getters with the same names.
-  using CompilerInvocationBase::getLangOpts;
-  using CompilerInvocationBase::getTargetOpts;
-  using CompilerInvocationBase::getDiagnosticOpts;
-  using CompilerInvocationBase::getHeaderSearchOpts;
-  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getAnalyzerOpts;
-  using CompilerInvocationBase::getMigratorOpts;
   using CompilerInvocationBase::getAPINotesOpts;
   using CompilerInvocationBase::getCodeGenOpts;
+  using CompilerInvocationBase::getDependencyOutputOpts;
+  using CompilerInvocationBase::getDiagnosticOpts;
   using CompilerInvocationBase::getFileSystemOpts;
   using CompilerInvocationBase::getFrontendOpts;
-  using CompilerInvocationBase::getDependencyOutputOpts;
+  using CompilerInvocationBase::getHeaderSearchOpts;
+  using CompilerInvocationBase::getLangOpts;
+  using CompilerInvocationBase::getMigratorOpts;
+  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getPreprocessorOutputOpts;
-  using CompilerInvocationBase::getInstallAPIOpts;
+  using CompilerInvocationBase::getTargetOpts;
   /// @}
 
   /// Mutable getters.
@@ -264,7 +258,6 @@ class CompilerInvocation : public CompilerInvocationBase {
   PreprocessorOutputOptions &getPreprocessorOutputOpts() {
     return *PreprocessorOutputOpts;
   }
-  InstallAPIOptions &getInstallAPIOpts() { return *InstallAPIOpts; }
   /// @}
 
   /// Base class internals.
diff --git a/clang/include/clang/Frontend/FrontendActions.h b/clang/include/clang/Frontend/FrontendActions.h
index b8229252f5ed22..fcce31ac0590ff 100644
--- a/clang/include/clang/Frontend/FrontendActions.h
+++ b/clang/include/clang/Frontend/FrontendActions.h
@@ -130,16 +130,6 @@ class GenerateModuleAction : public ASTFrontendAction {
   bool shouldEraseOutputFiles() override;
 };
 
-class InstallAPIAction : public ASTFrontendAction {
-protected:
-  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
-                                                 StringRef InFile) override;
-
-public:
-  static std::unique_ptr<llvm::raw_pwrite_stream>
-  CreateOutputFile(CompilerInstance &CI, StringRef InFile);
-};
-
 class GenerateInterfaceStubsAction : public ASTFrontendAction {
 protected:
   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h
index 62d16ba542ea4d..53a8681cfdbba0 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -100,9 +100,6 @@ enum ActionKind {
   /// Only execute frontend initialization.
   InitOnly,
 
-  // Create TextAPI stub.
-  InstallAPI,
-
   /// Dump information about a module file.
   ModuleFileInfo,
 
diff --git a/clang/include/clang/Frontend/InstallAPIOptions.h b/clang/include/clang/Frontend/InstallAPIOptions.h
deleted file mode 100644
index cf65a3350c6de6..00000000000000
--- a/clang/include/clang/Frontend/InstallAPIOptions.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===--- InstallAPIOptions.h ------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_FRONTEND_INSTALLAPIOPTIONS_H
-#define LLVM_CLANG_FRONTEND_INSTALLAPIOPTIONS_H
-
-#include "llvm/TextAPI/PackedVersion.h"
-
-namespace clang {
-
-/// InstallAPIOptions - Options for controlling InstallAPI verification and
-/// TextAPI output.
-class InstallAPIOptions {
-public:
-  /// The install name which is apart of the library's ID.
-  std::string InstallName;
-
-  /// The current version which is apart of the library's ID.
-  llvm::MachO::PackedVersion CurrentVersion;
-};
-} // namespace clang
-
-#endif
diff --git a/clang/include/clang/InstallAPI/Context.h b/clang/include/clang/InstallAPI/Context.h
index a1ff7c12a2f835..649e62529b9743 100644
--- a/clang/include/clang/InstallAPI/Context.h
+++ b/clang/include/clang/InstallAPI/Context.h
@@ -15,7 +15,8 @@
 #define LLVM_CLANG_INSTALLAPI_CONTEXT_H
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/Basic/Diagnostic.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/TextAPI/InterfaceFile.h"
 #include "llvm/TextAPI/RecordVisitor.h"
@@ -35,12 +36,6 @@ struct InstallAPIContext {
   /// Active target triple to parse.
   llvm::Triple TargetTriple{};
 
-  /// Output stream to write TextAPI file to.
-  std::unique_ptr<llvm::raw_pwrite_stream> OS = nullptr;
-
-  /// DiagnosticsEngine to report errors.
-  llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags = nullptr;
-
   /// File Path of output location.
   StringRef OutputLoc{};
 
@@ -48,6 +43,12 @@ struct InstallAPIContext {
   llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;
 };
 
+class InstallAPIAction : public ASTFrontendAction {
+public:
+  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+                                                 StringRef InFile) override;
+};
+
 class InstallAPIConsumer : public ASTConsumer {
 public:
   InstallAPIConsumer(InstallAPIContext InstallAPICtx)
diff --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp
index 7b1a1bb0228c41..741d6cd5a3945c 100644
--- a/clang/lib/Driver/Action.cpp
+++ b/clang/lib/Driver/Action.cpp
@@ -31,9 +31,8 @@ const char *Action::getClassName(ActionClass AC) {
   case MigrateJobClass: return "migrator";
   case CompileJobClass: return "compiler";
   case BackendJobClass: return "backend";
-  case AssembleJobClass: return "assembler";
-  case InstallAPIJobClass:
-    return "installapi";
+  case AssembleJobClass:
+    return "assembler";
   case IfsMergeJobClass: return "interface-stub-merger";
   case LinkJobClass: return "linker";
   case LipoJobClass: return "lipo";
@@ -364,11 +363,6 @@ void ExtractAPIJobAction::anchor() {}
 ExtractAPIJobAction::ExtractAPIJobAction(Action *Inputs, types::ID OutputType)
     : JobAction(ExtractAPIJobClass, Inputs, OutputType) {}
 
-void InstallAPIJobAction::anchor() {}
-
-InstallAPIJobAction::InstallAPIJobAction(Action *Inputs, types::ID OutputType)
-    : JobAction(InstallAPIJobClass, Inputs, OutputType) {}
-
 void AnalyzeJobAction::anchor() {}
 
 AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5a323bf4c0c5f4..00e14071a4afec 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4189,11 +4189,6 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
         break;
       }
 
-      if (isa<InstallAPIJobAction>(Current)) {
-        Current = nullptr;
-        break;
-      }
-
       // FIXME: Should we include any prior module file outputs as inputs of
       // later actions in the same command line?
 
@@ -4324,13 +4319,6 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
     if (!MergerInputs.empty())
       Actions.push_back(
           C.MakeAction<IfsMergeJobAction>(MergerInputs, types::TY_Image));
-  } else if (Args.hasArg(options::OPT_installapi)) {
-    // TODO: Lift restriction once operation can handle multiple inputs.
-    assert(Inputs.size() == 1 && "InstallAPI action can only handle 1 input");
-    const auto [InputType, InputArg] = Inputs.front();
-    Action *Current = C.MakeAction<InputAction>(*InputArg, InputType);
-    Actions.push_back(
-        C.MakeAction<InstallAPIJobAction>(Current, types::TY_TextAPI));
   }
 
   for (auto Opt : {options::OPT_print_supported_cpus,
@@ -4774,8 +4762,6 @@ Action *Driver::ConstructPhaseAction(
       return C.MakeAction<VerifyPCHJobAction>(Input, types::TY_Nothing);
     if (Args.hasArg(options::OPT_extract_api))
       return C.MakeAction<ExtractAPIJobAction>(Input, types::TY_API_INFO);
-    if (Args.hasArg(options::OPT_installapi))
-      return C.MakeAction<InstallAPIJobAction>(Input, types::TY_TextAPI);
     return C.MakeAction<CompileJobAction>(Input, types::TY_LLVM_BC);
   }
   case phases::Backend: {
@@ -6455,7 +6441,7 @@ bool Driver::ShouldUseClangCompiler(const JobAction &JA) const {
   // And say "no" if this is not a kind of action clang understands.
   if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) &&
       !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA) &&
-      !isa<ExtractAPIJobAction>(JA) && !isa<InstallAPIJobAction>(JA))
+      !isa<ExtractAPIJobAction>(JA))
     return false;
 
   return true;
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 657577cea6c7d8..388030592b4836 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -532,7 +532,6 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
   case Action::PrecompileJobClass:
   case Action::PreprocessJobClass:
   case Action::ExtractAPIJobClass:
-  case Action::InstallAPIJobClass:
   case Action::AnalyzeJobClass:
   case Action::MigrateJobClass:
   case Action::VerifyPCHJobClass:
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 47305f798c5fee..4459d86e77d5d9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4939,17 +4939,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     if (Arg *ExtractAPIIgnoresFileArg =
             Args.getLastArg(options::OPT_extract_api_ignores_EQ))
       ExtractAPIIgnoresFileArg->render(Args, CmdArgs);
-  } else if (isa<InstallAPIJobAction>(JA)) {
-    if (!Triple.isOSDarwin())
-      D.Diag(diag::err_drv_installapi_unsupported) << Triple.str();
-
-    CmdArgs.push_back("-installapi");
-    // Add necessary library arguments for InstallAPI.
-    if (const Arg *A = Args.getLastArg(options::OPT_install__name))
-      A->render(Args, CmdArgs);
-    if (const Arg *A = Args.getLastArg(options::OPT_current__version))
-      A->render(Args, CmdArgs);
-
   } else {
     assert((isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) &&
            "Invalid action for clang tool.");
diff --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index f443d88b5d30cb..a9166672088459 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -7,7 +7,6 @@ set(LLVM_LINK_COMPONENTS
   ProfileData
   Support
   TargetParser
-  TextAPI
   )
 
 add_clang_library(clangFrontend
@@ -28,7 +27,6 @@ add_clang_library(clangFrontend
   HeaderIncludeGen.cpp
   InitPreprocessor.cpp
   LayoutOverrideSource.cpp
-  InstallAPIConsumer.cpp
   LogDiagnosticPrinter.cpp
   ModuleDependencyCollector.cpp
   MultiplexConsumer.cpp
@@ -55,7 +53,6 @@ add_clang_library(clangFrontend
   clangBasic
   clangDriver
   clangEdit
-  clangInstallAPI
   clangLex
   clangParse
   clangSema
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index bcb31243056b7e..8d7b75b56d6129 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -149,8 +149,7 @@ CompilerInvocationBase::CompilerInvocationBase()
       FSOpts(std::make_shared<FileSystemOptions>()),
       FrontendOpts(std::make_shared<FrontendOptions>()),
       DependencyOutputOpts(std::make_shared<DependencyOutputOptions>()),
-      PreprocessorOutputOpts(std::make_shared<PreprocessorOutputOptions>()),
-      InstallAPIOpts(std::make_shared<InstallAPIOptions>()) {}
+      PreprocessorOutputOpts(std::make_shared<PreprocessorOutputOptions>()) {}
 
 CompilerInvocationBase &
 CompilerInvocationBase::deep_copy_assign(const CompilerInvocationBase &X) {
@@ -168,7 +167,6 @@ CompilerInvocationBase::deep_copy_assign(const CompilerInvocationBase &X) {
     FrontendOpts = make_shared_copy(X.getFrontendOpts());
     DependencyOutputOpts = make_shared_copy(X.getDependencyOutputOpts());
     PreprocessorOutputOpts = make_shared_copy(X.getPreprocessorOutputOpts());
-    InstallAPIOpts = make_shared_copy(X.getInstallAPIOpts());
   }
   return *this;
 }
@@ -189,7 +187,6 @@ CompilerInvocationBase::shallow_copy_assign(const CompilerInvocationBase &X) {
     FrontendOpts = X.FrontendOpts;
     DependencyOutputOpts = X.DependencyOutputOpts;
     PreprocessorOutputOpts = X.PreprocessorOutputOpts;
-    InstallAPIOpts = X.InstallAPIOpts;
   }
   return *this;
 }
@@ -2161,34 +2158,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 
-static bool ParseInstallAPIArgs(InstallAPIOptions &Opts, ArgList &Args,
-                                DiagnosticsEngine &Diags,
-                                frontend::ActionKind Action) {
-  unsigned NumErrorsBefore = Diags.getNumErrors();
-
-  InstallAPIOptions &InstallAPIOpts = Opts;
-#define INSTALLAPI_OPTION_WITH_MARSHALLING(...)                                \
-  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
-#include "clang/Driver/Options.inc"
-#undef INSTALLAPI_OPTION_WITH_MARSHALLING
-  if (Arg *A = Args.getLastArg(options::OPT_current__version))
-    Opts.CurrentVersion.parse64(A->getValue());
-
-  return Diags.getNumErrors() == NumErrorsBefore;
-}
-
-static void GenerateInstallAPIArgs(const InstallAPIOptions &Opts,
-                                   ArgumentConsumer Consumer) {
-  const InstallAPIOptions &InstallAPIOpts = Opts;
-#define INSTALLAPI_OPTION_WITH_MARSHALLING(...)                                \
-  GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
-#include "clang/Driver/Options.inc"
-#undef INSTALLAPI_OPTION_WITH_MARSHALLING
-  if (!Opts.CurrentVersion.empty())
-    GenerateArg(Consumer, OPT_current__version,
-                std::string(Opts.CurrentVersion));
-}
-
 static void GenerateDependencyOutputArgs(const DependencyOutputOptions &Opts,
                                          ArgumentConsumer Consumer) {
   const DependencyOutputOptions &DependencyOutputOpts = Opts;
@@ -2588,7 +2557,6 @@ static const auto &getFro...
[truncated]

Copy link

github-actions bot commented Feb 20, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff ba3c1f9ce30cf4f8aee5f1961df74d65e11d53bc 1ac97d5cbd4b4988a7892ac3649a873b3e818544 -- clang/tools/clang-installapi/ClangInstallAPI.cpp clang/tools/clang-installapi/Options.cpp clang/tools/clang-installapi/Options.h clang/include/clang/Driver/Action.h clang/include/clang/Frontend/CompilerInstance.h clang/include/clang/Frontend/CompilerInvocation.h clang/include/clang/Frontend/FrontendActions.h clang/include/clang/Frontend/FrontendOptions.h clang/include/clang/InstallAPI/Context.h clang/lib/Driver/Action.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
View the diff from clang-format here.
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index c6528779bd..8d75efdd23 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -21,8 +21,8 @@
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include <memory>
 #include <string>
 
@@ -224,19 +224,19 @@ public:
   /// @{
   // Note: These need to be pulled in manually. Otherwise, they get hidden by
   // the mutable getters with the same names.
-  using CompilerInvocationBase::getLangOpts;
-  using CompilerInvocationBase::getTargetOpts;
-  using CompilerInvocationBase::getDiagnosticOpts;
-  using CompilerInvocationBase::getHeaderSearchOpts;
-  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getAnalyzerOpts;
-  using CompilerInvocationBase::getMigratorOpts;
   using CompilerInvocationBase::getAPINotesOpts;
   using CompilerInvocationBase::getCodeGenOpts;
+  using CompilerInvocationBase::getDependencyOutputOpts;
+  using CompilerInvocationBase::getDiagnosticOpts;
   using CompilerInvocationBase::getFileSystemOpts;
   using CompilerInvocationBase::getFrontendOpts;
-  using CompilerInvocationBase::getDependencyOutputOpts;
+  using CompilerInvocationBase::getHeaderSearchOpts;
+  using CompilerInvocationBase::getLangOpts;
+  using CompilerInvocationBase::getMigratorOpts;
+  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getPreprocessorOutputOpts;
+  using CompilerInvocationBase::getTargetOpts;
   /// @}
 
   /// Mutable getters.
diff --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp
index 849bf6035e..741d6cd5a3 100644
--- a/clang/lib/Driver/Action.cpp
+++ b/clang/lib/Driver/Action.cpp
@@ -31,7 +31,8 @@ const char *Action::getClassName(ActionClass AC) {
   case MigrateJobClass: return "migrator";
   case CompileJobClass: return "compiler";
   case BackendJobClass: return "backend";
-  case AssembleJobClass: return "assembler";
+  case AssembleJobClass:
+    return "assembler";
   case IfsMergeJobClass: return "interface-stub-merger";
   case LinkJobClass: return "linker";
   case LipoJobClass: return "lipo";
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 925879a68c..7ea0b85a52 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -70,7 +70,8 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
   case GeneratePCH:            return std::make_unique<GeneratePCHAction>();
   case GenerateInterfaceStubs:
     return std::make_unique<GenerateInterfaceStubsAction>();
-  case InitOnly:               return std::make_unique<InitOnlyAction>();
+  case InitOnly:
+    return std::make_unique<InitOnlyAction>();
   case ParseSyntaxOnly:        return std::make_unique<SyntaxOnlyAction>();
   case ModuleFileInfo:         return std::make_unique<DumpModuleInfoAction>();
   case VerifyPCH:              return std::make_unique<VerifyPCHAction>();

@cyndyishida cyndyishida force-pushed the eng/PR-clangInstallAPIPartialRevert branch 2 times, most recently from 5f4e937 to bddd3cc Compare February 20, 2024 02:41
@cyndyishida cyndyishida force-pushed the eng/PR-clangInstallAPIPartialRevert branch from bddd3cc to 21bd0e0 Compare February 20, 2024 18:52
@llvmbot llvmbot added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Feb 20, 2024
Installapi has important distinctions when compared to the clang driver, so much that, it doesn't make much sense to try to integrate into it.
This patch partially reverts the CC1 action & driver support to replace with its own driver as a clang tool.
For distribution, we could use LLVM_TOOL_LLVM_DRIVER_BUILD mechanism for integrating the functionality into clang such that the toolchain size is less impacted.
@cyndyishida cyndyishida force-pushed the eng/PR-clangInstallAPIPartialRevert branch from 7fe9b2a to 1ac97d5 Compare February 21, 2024 04:09
Copy link
Collaborator

@ributzka ributzka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyndyishida cyndyishida merged commit 0a518db into llvm:main Feb 21, 2024
@cyndyishida cyndyishida deleted the eng/PR-clangInstallAPIPartialRevert branch February 21, 2024 17:39
MaskRay added a commit that referenced this pull request Feb 28, 2024
mylai-mtk pushed a commit to mylai-mtk/llvm-project that referenced this pull request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants