[PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows
Zachary Turner via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 10:46:41 PDT 2016
zturner created this revision.
zturner added reviewers: alexfh, djasper.
zturner added a subscriber: cfe-commits.
Herald added a subscriber: klimek.
When a compilation database is used on Windows, the command lines cannot be parsed using the standard GNU style syntax. LLVM provides functions for parsing Windows style command lines, so use them.
This is a break-off from D23409. Just uploading this here for now as a placeholder, will try to work on a test for this in the meantime.
https://reviews.llvm.org/D23455
Files:
lib/Tooling/JSONCompilationDatabase.cpp
Index: lib/Tooling/JSONCompilationDatabase.cpp
===================================================================
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ 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,8 +116,17 @@
std::vector<std::string> unescapeCommandLine(
StringRef EscapedCommandLine) {
+#if defined(LLVM_ON_WIN32)
+ 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;
+#else
CommandLineArgumentParser parser(EscapedCommandLine);
return parser.parse();
+#endif
}
class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23455.67856.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160812/4acfbda7/attachment.bin>
More information about the cfe-commits
mailing list