[clang] [InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action (PR #82293)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 16:58:58 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 030d07574f0252c21ed28ae258a5af0e577ea37b a98cd84ae140c4e78c12e61d2a40049b070c7bcf -- 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 clang/lib/InstallAPI/Context.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/tools/clang-installapi/ClangInstallAPI.cpp b/clang/tools/clang-installapi/ClangInstallAPI.cpp
index 2047b3e555..4e40fc4975 100644
--- a/clang/tools/clang-installapi/ClangInstallAPI.cpp
+++ b/clang/tools/clang-installapi/ClangInstallAPI.cpp
@@ -45,18 +45,19 @@ static bool run(ArrayRef<const char *> CommandArgs, const char *ProgName) {
 
   // Setup Diagnostics engine.
   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
-  const llvm::opt::OptTable &ClangOpts= clang::driver::getDriverOptTable();
+  const llvm::opt::OptTable &ClangOpts = clang::driver::getDriverOptTable();
   unsigned MissingArgIndex, MissingArgCount;
   llvm::opt::InputArgList ParsedArgs = ClangOpts.ParseArgs(
       ArrayRef(Args).slice(1), MissingArgIndex, MissingArgCount);
   ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
-  
+
   IntrusiveRefCntPtr<DiagnosticsEngine> Diag = new clang::DiagnosticsEngine(
       new clang::DiagnosticIDs(), DiagOpts.get(),
       new clang::TextDiagnosticPrinter(llvm::errs(), DiagOpts.get()));
-  
+
   // Create file manager for all file operations.
-  IntrusiveRefCntPtr<clang::FileManager> FM(new FileManager(clang::FileSystemOptions()));
+  IntrusiveRefCntPtr<clang::FileManager> FM(
+      new FileManager(clang::FileSystemOptions()));
 
   // Set up driver to parse input arguments.
   auto DriverArgs = llvm::ArrayRef(Args).slice(1);
@@ -69,8 +70,8 @@ static bool run(ArrayRef<const char *> CommandArgs, const char *ProgName) {
   bool HasError = false;
   llvm::opt::InputArgList ArgList =
       Driver.ParseArgStrings(DriverArgs, /*UseDriverMode=*/true, HasError);
-  if (HasError) 
-    return EXIT_FAILURE; 
+  if (HasError)
+    return EXIT_FAILURE;
   Driver.setCheckInputsExist(false);
 
   // Capture InstallAPI specific options and diagnose any option errors.
@@ -87,7 +88,7 @@ static bool run(ArrayRef<const char *> CommandArgs, const char *ProgName) {
                                   /*RemoveFileOnSignal=*/false,
                                   /*UseTemporary=*/false,
                                   /*CreateMissingDirectories=*/false);
-  if (!Out) 
+  if (!Out)
     return EXIT_FAILURE;
 
   // Assign attributes for serialization.
@@ -102,7 +103,7 @@ static bool run(ArrayRef<const char *> CommandArgs, const char *ProgName) {
     Diag->Report(diag::err_cannot_open_file) << Ctx.OutputLoc;
     CI->clearOutputFiles(/*EraseFiles=*/true);
     return EXIT_FAILURE;
-  } 
+  }
 
   CI->clearOutputFiles(/*EraseFiles=*/false);
   return EXIT_SUCCESS;
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
index 700f65062f..5b5cf71d66 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -1,6 +1,6 @@
 #include "Options.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/Support/Program.h"
 #include "llvm/TargetParser/Host.h"
 
@@ -12,7 +12,7 @@ using namespace llvm::MachO;
 namespace clang {
 namespace installapi {
 
-bool Options::processDriverOptions(InputArgList& Args) {
+bool Options::processDriverOptions(InputArgList &Args) {
   // Handle inputs.
   llvm::vfs::Status Stat;
   for (const auto &Path : Args.getAllArgValues(OPT_INPUT)) {
@@ -96,11 +96,11 @@ bool Options::processLinkerOptions(InputArgList &Args) {
 Options::Options(DiagnosticsEngine &Diag, FileManager *FM,
                  InputArgList &ArgList)
     : Diags(&Diag), FM(FM) {
-  if (!processDriverOptions(ArgList)) 
+  if (!processDriverOptions(ArgList))
     return;
 
   if (!processLinkerOptions(ArgList))
     return;
 }
-}
-}
+} // namespace installapi
+} // namespace clang
diff --git a/clang/tools/clang-installapi/Options.h b/clang/tools/clang-installapi/Options.h
index 85eaeb4ee8..7ce2d1b106 100644
--- a/clang/tools/clang-installapi/Options.h
+++ b/clang/tools/clang-installapi/Options.h
@@ -56,7 +56,6 @@ struct LinkerOptions {
 
   /// \brief Set if we should scan for a dynamic library and not a framework.
   bool IsDylib = false;
-  
 };
 
 class Options {
@@ -65,7 +64,6 @@ private:
   bool processLinkerOptions(llvm::opt::InputArgList &Args);
 
 public:
-
   /// The various options grouped together.
   DriverOptions DriverOptions;
   LinkerOptions LinkerOptions;
@@ -73,13 +71,14 @@ public:
   Options() = delete;
 
   /// \brief Constructor for options.
-  Options(clang::DiagnosticsEngine &Diag, FileManager* FM, llvm::opt::InputArgList& Args);
+  Options(clang::DiagnosticsEngine &Diag, FileManager *FM,
+          llvm::opt::InputArgList &Args);
 
 private:
-  DiagnosticsEngine* Diags;
-  FileManager* FM;
+  DiagnosticsEngine *Diags;
+  FileManager *FM;
 };
 
-}
-}
-#endif 
+} // namespace installapi
+} // namespace clang
+#endif

``````````

</details>


https://github.com/llvm/llvm-project/pull/82293


More information about the cfe-commits mailing list