[llvm] [NFC][TableGen] Add `InclusionGuardEmitter` to emit header inclusion guards (PR #163283)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 14 10:13:54 PDT 2025


================
@@ -34,6 +34,22 @@ class IfDefEmitter {
   raw_ostream &OS;
 };
 
+// Simple RAII helper for emitting header inclusion guard (i.e,
+// ifndef-define-endif).
+class InclusionGuardEmitter {
+public:
+  InclusionGuardEmitter(raw_ostream &OS, StringRef Name)
+      : Name(Name.str()), OS(OS) {
+    OS << "#ifndef " << Name << "\n"
+       << "#define " << Name << "\n\n";
+  }
+  ~InclusionGuardEmitter() { OS << "\n#endif // " << Name << "\n\n"; }
----------------
jurahul wrote:

Done.

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


More information about the llvm-commits mailing list