[PATCH] Fix JSON compilation database command unescaping.

Manuel Klimek klimek at google.com
Mon Nov 24 05:32:40 PST 2014


================
Comment at: lib/Tooling/JSONCompilationDatabase.cpp:92
@@ -91,2 +91,3 @@
     if (*Position == '\\') {
-      return next();
+      if (next() && *Position == '"')
+        return true;
----------------
I'd rather not --Position.
To me this would be easier to verify:
  if (*Position == '\\' && Position + 1 != Input.end() && *(Position + 1) == '"')
    return next();
  return true;

================
Comment at: unittests/Tooling/CompilationDatabaseTest.cpp:93
@@ -92,3 +92,3 @@
   StringRef FileName1("file1");
-  StringRef Command1("command1");
+  StringRef Command1(R"(command1 -DFOO=\"1\\2\\\" \" -DBAR=\\)");
   StringRef Directory2("//net/dir2");
----------------
Please test this in the style of the extra test functions below and leave this without testing escaping... The test is large enough as it is.

http://reviews.llvm.org/D6376






More information about the cfe-commits mailing list