From: Yunzhong Gao Date: Mon, 20 Jul 2015 17:46:56 +0000 (+0000) Subject: Fix quoting of #pragma comment for PS4. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acd9b2d8c8f0967c6ce5cdcf75db43b660489a27;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242689 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index f95b945af4..15e50c1889 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -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; } }; diff --git a/test/CodeGen/pragma-comment.c b/test/CodeGen/pragma-comment.c index fbae9d5323..6da20686e9 100644 --- a/test/CodeGen/pragma-comment.c +++ b/test/CodeGen/pragma-comment.c @@ -30,3 +30,4 @@ // PS4: !{!"\01msvcrt.lib"} // PS4: !{!"\01kernel32"} // PS4: !{!"\01USER32.LIB"} +// PS4: !{!"\01\22with space\22"}