[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

Ravi Ramaseshan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 18:21:44 PST 2020


ravi-ramaseshan created this revision.
ravi-ramaseshan added reviewers: scott.linder, rjmccall.
Herald added a project: clang.

Similar to the rest of the command line that is recorded, the program
path must also have spaces and backslashes escaped. Without this
parsing the recorded command line becomes hard on platforms like
Windows where spaces and backslashes are common.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74811

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
       Arg->render(Args, OriginalArgs);
 
     SmallString<256> Flags;
-    Flags += Exec;
+    EscapeSpacesAndBackslashes(Exec, Flags);
     for (const char *OriginalArg : OriginalArgs) {
       SmallString<128> EscapedArg;
       EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
     SmallString<256> Flags;
     const char *Exec = getToolChain().getDriver().getClangProgramPath();
-    Flags += Exec;
+    EscapeSpacesAndBackslashes(Exec, Flags);
     for (const char *OriginalArg : OriginalArgs) {
       SmallString<128> EscapedArg;
       EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74811.245313.patch
Type: text/x-patch
Size: 845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200219/eb3abac4/attachment.bin>


More information about the cfe-commits mailing list