[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 17:53:38 PDT 2016


zturner updated this revision to Diff 67947.
zturner added a comment.

After much head banging I think I finally figured this out.  I'm putting this back to my original revision, unchanged.  The problem is not the original patch.  The original patch is perfectly fine.  The problem is the way i was writing my test.  This is just updating the revision back to its original state.  I can't make a cross-repo diff, so I will make a new diff with the test.


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.67947.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160813/9da2bad8/attachment.bin>


More information about the cfe-commits mailing list