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

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 10:39:46 PST 2025


Author: Ivan Kosarev
Date: 2025-11-17T18:39:41Z
New Revision: cc304e5a5cf43d454d597eb9108f0bc7e6605722

URL: https://github.com/llvm/llvm-project/commit/cc304e5a5cf43d454d597eb9108f0bc7e6605722
DIFF: https://github.com/llvm/llvm-project/commit/cc304e5a5cf43d454d597eb9108f0bc7e6605722.diff

LOG: [TableGen] Strip directories from filename prefixes. (#168355)

Fixes https://github.com/llvm/llvm-project/pull/167700 to support
builds where TableGen's output file is specified as full path
rather than just filename.

Added: 
    

Modified: 
    llvm/lib/TableGen/Main.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index c3869c3fb9a5a..3330b70cdc2e1 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -167,12 +167,11 @@ int llvm::TableGenMain(const char *argv0,
 
   // Write output to memory.
   Timer.startBackendTimer("Backend overall");
-  SmallString<128> FilenamePrefix(OutputFilename);
-  sys::path::replace_extension(FilenamePrefix, "");
   TableGenOutputFiles OutFiles;
   unsigned status = 0;
   // ApplyCallback will return true if it did not apply any callback. In that
   // case, attempt to apply the MainFn.
+  StringRef FilenamePrefix(sys::path::stem(OutputFilename));
   if (TableGen::Emitter::ApplyCallback(Records, OutFiles, FilenamePrefix))
     status = MainFn ? MainFn(OutFiles, Records) : 1;
   Timer.stopBackendTimer();
@@ -195,7 +194,7 @@ int llvm::TableGenMain(const char *argv0,
     SmallString<128> Filename(OutputFilename);
     // TODO: Format using the split-file convention when writing to stdout?
     if (Filename != "-") {
-      Filename = FilenamePrefix;
+      sys::path::replace_extension(Filename, "");
       Filename.append(Suffix);
     }
     if (int Ret = WriteOutput(Parser, argv0, Filename, Content))


        


More information about the llvm-commits mailing list