aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authornebulark <nebulark@users.noreply.github.com>2024-09-16 19:29:42 +0200
committerGitHub <noreply@github.com>2024-09-16 19:29:42 +0200
commitf5ba3e1fa6b5f862789786fbb4b342dfc2c27c33 (patch)
treef8f7689f19479208cfbeb10f3fbf9132d42dfbd8 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parent5c348f692a8dff98a3780d0b859fb0949eccbaca (diff)
downloadllvm-f5ba3e1fa6b5f862789786fbb4b342dfc2c27c33.zip
llvm-f5ba3e1fa6b5f862789786fbb4b342dfc2c27c33.tar.gz
llvm-f5ba3e1fa6b5f862789786fbb4b342dfc2c27c33.tar.bz2
[CodeView] Flatten cmd args in frontend for LF_BUILDINFO (#106369)
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp43
1 files changed, 5 insertions, 38 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7700ffd..f184f32 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -893,37 +893,6 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder &TypeTable,
return TypeTable.writeLeafType(SIR);
}
-static std::string flattenCommandLine(ArrayRef<std::string> Args,
- StringRef MainFilename) {
- std::string FlatCmdLine;
- raw_string_ostream OS(FlatCmdLine);
- bool PrintedOneArg = false;
- if (!StringRef(Args[0]).contains("-cc1")) {
- llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
- PrintedOneArg = true;
- }
- for (unsigned i = 0; i < Args.size(); i++) {
- StringRef Arg = Args[i];
- if (Arg.empty())
- continue;
- if (Arg == "-main-file-name" || Arg == "-o") {
- i++; // Skip this argument and next one.
- continue;
- }
- if (Arg.starts_with("-object-file-name") || Arg == MainFilename)
- continue;
- // Skip fmessage-length for reproduciability.
- if (Arg.starts_with("-fmessage-length"))
- continue;
- if (PrintedOneArg)
- OS << " ";
- llvm::sys::printArg(OS, Arg, /*Quote=*/true);
- PrintedOneArg = true;
- }
- OS.flush();
- return FlatCmdLine;
-}
-
void CodeViewDebug::emitBuildInfo() {
// First, make LF_BUILDINFO. It's a sequence of strings with various bits of
// build info. The known prefix is:
@@ -947,13 +916,11 @@ void CodeViewDebug::emitBuildInfo() {
// FIXME: PDB is intentionally blank unless we implement /Zi type servers.
BuildInfoArgs[BuildInfoRecord::TypeServerPDB] =
getStringIdTypeIdx(TypeTable, "");
- if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
- BuildInfoArgs[BuildInfoRecord::BuildTool] =
- getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
- BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
- TypeTable, flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
- MainSourceFile->getFilename()));
- }
+ BuildInfoArgs[BuildInfoRecord::BuildTool] =
+ getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
+ BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
+ TypeTable, Asm->TM.Options.MCOptions.CommandlineArgs);
+
BuildInfoRecord BIR(BuildInfoArgs);
TypeIndex BuildInfoIndex = TypeTable.writeLeafType(BIR);