[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)
Alexandre Ganea via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 12:49:34 PDT 2024
================
@@ -321,6 +322,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
Action != Backend_EmitLL;
}
+static std::string flattenClangCommandLine(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.
----------------
aganea wrote:
This should read "reproducibility"
https://github.com/llvm/llvm-project/pull/106369
More information about the cfe-commits
mailing list