[PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows
Zachary Turner via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 17 13:12:38 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278964: [Tooling] Parse compilation database command lines on Windows. (authored by zturner).
Changed prior to commit:
https://reviews.llvm.org/D23455?vs=67947&id=68407#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23455
Files:
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===================================================================
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,7 +16,10 @@
#include "clang/Tooling/CompilationDatabasePluginRegistry.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
#include <system_error>
namespace clang {
@@ -113,6 +116,21 @@
std::vector<std::string> unescapeCommandLine(
StringRef EscapedCommandLine) {
+ llvm::Triple Triple(llvm::sys::getProcessTriple());
+ if (Triple.getOS() == llvm::Triple::OSType::Win32) {
+ // Assume Windows command line parsing on Win32 unless the triple explicitly
+ // tells us otherwise.
+ if (!Triple.hasEnvironment() ||
+ Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) {
+ llvm::BumpPtrAllocator Alloc;
+ llvm::StringSaver Saver(Alloc);
+ llvm::SmallVector<const char *, 64> T;
+ llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+ std::vector<std::string> Result(T.begin(), T.end());
+ return Result;
+ }
+ }
+
CommandLineArgumentParser parser(EscapedCommandLine);
return parser.parse();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23455.68407.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160817/a628cb72/attachment.bin>
More information about the cfe-commits
mailing list