r242689 - Fix quoting of #pragma comment for PS4.

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Mon Jul 20 10:46:57 PDT 2015


Author: ygao
Date: Mon Jul 20 12:46:56 2015
New Revision: 242689

URL: http://llvm.org/viewvc/llvm-project?rev=242689&view=rev
Log:
Fix quoting of #pragma comment for PS4.

This is the PS4 counterpart to r229376, which quotes the library name if the
name contains space. It was discovered that if a library name contains both
double-quote and space characters, quoting the name might produce unexpected
results, but we are mostly concerned with a Windows host environment, which
does not allow double-quote or slashes in file/folder names.

Differential Revision: http://reviews.llvm.org/D11275


Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGen/pragma-comment.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=242689&r1=242688&r2=242689&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Jul 20 12:46:56 2015
@@ -1655,7 +1655,11 @@ public:
   void getDependentLibraryOption(llvm::StringRef Lib,
                                  llvm::SmallString<24> &Opt) const override {
     Opt = "\01";
-    Opt += Lib;
+    // If the argument contains a space, enclose it in quotes.
+    if (Lib.find(" ") != StringRef::npos)
+      Opt += "\"" + Lib.str() + "\"";
+    else
+      Opt += Lib;
   }
 };
 

Modified: cfe/trunk/test/CodeGen/pragma-comment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-comment.c?rev=242689&r1=242688&r2=242689&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/pragma-comment.c (original)
+++ cfe/trunk/test/CodeGen/pragma-comment.c Mon Jul 20 12:46:56 2015
@@ -30,3 +30,4 @@
 // PS4: !{!"\01msvcrt.lib"}
 // PS4: !{!"\01kernel32"}
 // PS4: !{!"\01USER32.LIB"}
+// PS4: !{!"\01\22with space\22"}





More information about the cfe-commits mailing list