Skip to content

Commit 36bd45d

Browse files
committed
removed old commanline arguments, applied suggested changes, made Arg0 an owned string
1 parent 6033291 commit 36bd45d

File tree

3 files changed

+9
-56
lines changed

3 files changed

+9
-56
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
521521
Options.MCOptions.IASSearchPaths.push_back(
522522
Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
523523
Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
524-
Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
525-
Options.MCOptions.CommandlineArgsFlat = flattenClangCommandLine(
524+
Options.MCOptions.CommandlineArgs = flattenClangCommandLine(
526525
CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName);
527526
Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
528527
Options.MCOptions.PPCUseFullRegisterNames =

llvm/include/llvm/MC/MCTargetOptions.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,11 @@ class MCTargetOptions {
9595
std::string SplitDwarfFile;
9696
std::string AsSecureLogFile;
9797

98-
const char *Argv0 = nullptr;
98+
// This will be set as compiler path in LF_BUILDINFO
99+
std::string Argv0;
99100

100-
// Deprecated: Use FlatCommandlineArgs instead
101-
// Arguments here are interpreted as coming from clang, formated and end up in LF_BUILDINFO as CommandLineArgs
102-
ArrayRef<std::string> CommandLineArgs;
103-
104-
// Arguments here end up in LF_BUILDINFO as CommandLineArgs without any additional formating
105-
// If empty falls back to CommandLineArgs
106-
std::string CommandlineArgsFlat;
101+
// This will be set as commandline arguments in LF_BUILDINFO
102+
std::string CommandlineArgs;
107103

108104
/// Additional paths to search for `.include` directives when using the
109105
/// integrated assembler.

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -893,39 +893,6 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder &TypeTable,
893893
return TypeTable.writeLeafType(SIR);
894894
}
895895

896-
// This just exists for backwards compatability for the deprecated MCTargetOptions::CommandLineArgs
897-
// It assumed a clang compiler frontend
898-
static std::string flattenCommandLine(ArrayRef<std::string> Args,
899-
StringRef MainFilename) {
900-
std::string FlatCmdLine;
901-
raw_string_ostream OS(FlatCmdLine);
902-
bool PrintedOneArg = false;
903-
if (!StringRef(Args[0]).contains("-cc1")) {
904-
llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
905-
PrintedOneArg = true;
906-
}
907-
for (unsigned i = 0; i < Args.size(); i++) {
908-
StringRef Arg = Args[i];
909-
if (Arg.empty())
910-
continue;
911-
if (Arg == "-main-file-name" || Arg == "-o") {
912-
i++; // Skip this argument and next one.
913-
continue;
914-
}
915-
if (Arg.starts_with("-object-file-name") || Arg == MainFilename)
916-
continue;
917-
// Skip fmessage-length for reproduciability.
918-
if (Arg.starts_with("-fmessage-length"))
919-
continue;
920-
if (PrintedOneArg)
921-
OS << " ";
922-
llvm::sys::printArg(OS, Arg, /*Quote=*/true);
923-
PrintedOneArg = true;
924-
}
925-
OS.flush();
926-
return FlatCmdLine;
927-
}
928-
929896
void CodeViewDebug::emitBuildInfo() {
930897
// First, make LF_BUILDINFO. It's a sequence of strings with various bits of
931898
// build info. The known prefix is:
@@ -949,20 +916,11 @@ void CodeViewDebug::emitBuildInfo() {
949916
// FIXME: PDB is intentionally blank unless we implement /Zi type servers.
950917
BuildInfoArgs[BuildInfoRecord::TypeServerPDB] =
951918
getStringIdTypeIdx(TypeTable, "");
952-
if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
953-
BuildInfoArgs[BuildInfoRecord::BuildTool] =
954-
getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
919+
BuildInfoArgs[BuildInfoRecord::BuildTool] =
920+
getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
921+
BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
922+
TypeTable, Asm->TM.Options.MCOptions.CommandlineArgs);
955923

956-
if (!Asm->TM.Options.MCOptions.CommandlineArgsFlat.empty()) {
957-
BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
958-
TypeTable, Asm->TM.Options.MCOptions.CommandlineArgsFlat);
959-
} else {
960-
BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
961-
TypeTable,
962-
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
963-
MainSourceFile->getFilename()));
964-
}
965-
}
966924
BuildInfoRecord BIR(BuildInfoArgs);
967925
TypeIndex BuildInfoIndex = TypeTable.writeLeafType(BIR);
968926

0 commit comments

Comments
 (0)