[clang] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 07:25:22 PDT 2023


================
@@ -59,4 +60,8 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
   printLine(OS, Prefix, ' ', Suffix);
   printLine(OS, "\\*===", '-', "===*/");
   OS << '\n';
+
+  // Print the path of source file
+  if (!Record.getInputFilename().empty())
+    OS << "// Generated from: " << Record.getInputFilename() << "\n\n";
----------------
AaronBallman wrote:

Good question! I was thinking it would give just the base file name, not the full path to the file: https://github.com/llvm/llvm-project/blob/aa8f5e6156821aec1fed595f2e13d69655ec3311/llvm/lib/TableGen/Main.cpp#L115 -- that looks like it will generate whatever was given on the command line, which could very well be a full path.

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


More information about the cfe-commits mailing list