[llvm] [TableGen] Strip directories from filename prefixes. (PR #168355)

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 09:22:18 PST 2025


keith wrote:

something like this would solve that:

```diff
diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
index ef7b13e8940f..286d5bf637ce 100644
--- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
@@ -104,7 +105,7 @@ static void emitInclude(StringRef FilenamePrefix, StringRef IncludeFile,
                         StringRef GuardMacro, raw_ostream &OS) {
   OS << "#ifdef " << GuardMacro << '\n';
   OS << "#undef " << GuardMacro << '\n';
-  OS << "#include \"" << FilenamePrefix << IncludeFile << "\"\n";
+  OS << "#include \"" << sys::path::stem(FilenamePrefix) << IncludeFile << "\"\n";
   OS << "#endif\n\n";
 }
```

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


More information about the llvm-commits mailing list