[PATCH] D66555: [driver] add a new option `-gen-cdb-fragment-path` to emit a fragment of a compilation database for each compilation

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 14:24:46 PDT 2019


jkorous added inline comments.


================
Comment at: clang/lib/Driver/Driver.cpp:1044
+  if (const Arg *A = Args.getLastArg(options::OPT_gen_cdb_fragment_path))
+    PathToCDBFragmentDir = A->getValue();
   // FIXME: TargetTriple is used by the target-prefixed calls to as/ld
----------------
IIUC this feature might end up being used from some test script. I'm wondering - what would happen had the argument been an empty string?

```
clang -c foo.c -gen-cdb-fragment-path ""
```


================
Comment at: clang/lib/Driver/Driver.cpp:4868
+
+void Driver::emitCompilationDatabaseFragment(StringRef DestDir,
+                                             StringRef Executable,
----------------
I am just wondering whether we shouldn't notice user about failures, possibly with some error message.


================
Comment at: clang/lib/Driver/Driver.cpp:4896
+    for (char C : Arg) {
+      if (C == ' ' || C == '\'' || C == '"' || C == '\\')
+        OS << '\\';
----------------
It feels like this might have been already implemented somewhere else.

Couldn't we use for example `llvm::yaml::escape()`?

https://llvm.org/doxygen/namespacellvm_1_1yaml.html#aefed9cb3f107aee0cff4d325c7d689ae


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66555/new/

https://reviews.llvm.org/D66555





More information about the cfe-commits mailing list