[clang] [Clang] [NFC] Tablegen component diags headers (PR #134777)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 8 07:50:11 PDT 2025


================
@@ -1562,6 +1563,60 @@ void clang::EmitClangDiagsCompatIDs(const llvm::RecordKeeper &Records,
     OS << "DIAG_COMPAT_IDS_END()\n";
 }
 
+/// ClangDiagsIntefaceEmitter - Emit the diagnostics interface header for
+/// a Clang component.
+void clang::EmitClangDiagsInterface(llvm::raw_ostream &OS,
+                                    const std::string &Component) {
+  if (Component.empty())
+    PrintFatalError("'-gen-clang-diags-iface' requires a component name");
+
+  std::string ComponentUpper = StringRef(Component).upper();
+  const char *Comp = Component.c_str();
+  const char *Upper = ComponentUpper.c_str();
+
+  OS << llvm::format(R"c++(
+namespace clang {
----------------
Sirraide wrote:

> BUT I can't htink of a way to do that which doesn't require preprocessor string-replacement inside of a `#include` or `define` identifier, which, IIRC is UB?

Yeah, I think the preprocessor directives are the main problem, e.g. the `#define ASTSTART`; there isn’t really a way to do this just in the preprocessor unfortunately...

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


More information about the cfe-commits mailing list