[PATCH] D54657: [clang] Add -MJJ for appending to compilation databases.
Tom Roeder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 19 13:15:17 PST 2018
tmroeder updated this revision to Diff 174676.
tmroeder added a comment.
Change CompilationDatabase to not output entries that use -E.
These entries cannot be used by the tooling, so they can be skipped. This removes the other code and adds tests to make sure that neither -E or -### entries write a file.
Repository:
rC Clang
https://reviews.llvm.org/D54657
Files:
lib/Driver/ToolChains/Clang.cpp
test/Driver/compilation_database.c
Index: test/Driver/compilation_database.c
===================================================================
--- test/Driver/compilation_database.c
+++ test/Driver/compilation_database.c
@@ -1,6 +1,10 @@
// RUN: mkdir -p %t && cd %t
// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
// RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=ERROR %s
+// RUN: %clang -E -c -x c %s -MJ E.json
+// RUN: test ! -f E.json
+// RUN: %clang -### -c -x c %s -MJ hash_hash_hash.json
+// RUN: test ! -f hash_hash_hash.json
// CHECK: { "directory": "{{.*}}", "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
// CHECK: { "directory": "{{.*}}", "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1910,8 +1910,9 @@
void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
StringRef Target, const InputInfo &Output,
const InputInfo &Input, const ArgList &Args) const {
- // If this is a dry run, do not create the compilation database file.
- if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
+ // If this is a dry run or a pre-processing-only run, then do not create the
+ // compilation database file.
+ if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH, options::OPT_E))
return;
using llvm::yaml::escape;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54657.174676.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181119/1da5c83e/attachment.bin>
More information about the cfe-commits
mailing list