[llvm] [TableGen] Implement a preprocessor (PR #120113)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 03:25:53 PDT 2025


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 HEAD~1 HEAD --extensions cpp -- llvm/lib/TableGen/Main.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index af02a332c..7dbb9c8b6 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -192,41 +192,41 @@ int llvm::TableGenMain(const char *argv0,
   } else {
     TGParser Parser(SrcMgr, MacroNames, Records, NoWarnOnUnusedTemplateArgs);
 
-  // Always write the depfile, even if the main output hasn't changed.
-  // If it's missing, Ninja considers the output dirty. If this was below
-  // the early exit below and someone deleted the .inc.d file but not the .inc
-  // file, tablegen would never write the depfile.
-  if (!DependFilename.empty()) {
-    if (int Ret = createDependencyFile(Parser, argv0))
-      return Ret;
-  }
+    // Always write the depfile, even if the main output hasn't changed.
+    // If it's missing, Ninja considers the output dirty. If this was below
+    // the early exit below and someone deleted the .inc.d file but not the .inc
+    // file, tablegen would never write the depfile.
+    if (!DependFilename.empty()) {
+      if (int Ret = createDependencyFile(Parser, argv0))
+        return Ret;
+    }
 
-  Timer.startTimer("Write output");
-  bool WriteFile = true;
-  if (WriteIfChanged) {
-    // Only updates the real output file if there are any differences.
-    // This prevents recompilation of all the files depending on it if there
-    // aren't any.
-    if (auto ExistingOrErr =
-            MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
-      if (std::move(ExistingOrErr.get())->getBuffer() == OutString)
-        WriteFile = false;
-  }
-  if (WriteFile) {
-    std::error_code EC;
-    ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
-    if (EC)
-      return reportError(argv0, "error opening " + OutputFilename + ": " +
-                                    EC.message() + "\n");
-    OutFile.os() << OutString;
-    if (ErrorsPrinted == 0)
-      OutFile.keep();
-  }
+    Timer.startTimer("Write output");
+    bool WriteFile = true;
+    if (WriteIfChanged) {
+      // Only updates the real output file if there are any differences.
+      // This prevents recompilation of all the files depending on it if there
+      // aren't any.
+      if (auto ExistingOrErr =
+              MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
+        if (std::move(ExistingOrErr.get())->getBuffer() == OutString)
+          WriteFile = false;
+    }
+    if (WriteFile) {
+      std::error_code EC;
+      ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
+      if (EC)
+        return reportError(argv0, "error opening " + OutputFilename + ": " +
+                                      EC.message() + "\n");
+      OutFile.os() << OutString;
+      if (ErrorsPrinted == 0)
+        OutFile.keep();
+    }
 
-  Timer.stopTimer();
-  Timer.stopPhaseTiming();
+    Timer.stopTimer();
+    Timer.stopPhaseTiming();
 
-  if (ErrorsPrinted > 0)
-    return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n");
-  return 0;
-}
+    if (ErrorsPrinted > 0)
+      return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n");
+    return 0;
+  }

``````````

</details>


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


More information about the llvm-commits mailing list