summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2016-12-06 16:33:22 +0000
committerJoerg Sonnenberger <joerg@bec.de>2016-12-06 16:33:22 +0000
commitcbc872549cf8be53e2558a13de643e3bb79673f6 (patch)
tree6fa6b673d9d2ac88e6e192e1cff8fd4fc701b848 /clang/test
parent0caaadfc2d8ebc5fdb035533c962fe316e8c9905 (diff)
downloadbcm5719-llvm-cbc872549cf8be53e2558a13de643e3bb79673f6.tar.gz
bcm5719-llvm-cbc872549cf8be53e2558a13de643e3bb79673f6.zip
Allow clang to write compilation database records.
When integrating compilation database output into existing build systems, two approaches dominate so far. Ad-hoc implementation of the JSON output rules or using compiler wrappers. This patch adds a new option "-MJ foo.json" which gives a slightly cleaned up compilation record. The output is a fragment, i.e. you still need to add the array markers, but it allows multiple files to be easy merged. This way the only change in a build system is adding the option with potentially a per-target output file and merging the files with something like (echo '['; cat *.o.json; echo ']' > compilation_database.json or some additional filtering to remove the trailing comma for strict JSON compliance. Differential Revision: https://reviews.llvm.org/D27140 llvm-svn: 288821
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Driver/compilation_database.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Driver/compilation_database.c b/clang/test/Driver/compilation_database.c
new file mode 100644
index 00000000000..bb6c9c7599e
--- /dev/null
+++ b/clang/test/Driver/compilation_database.c
@@ -0,0 +1,10 @@
+// RUN: %clang -MD -MP -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
+// RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck --check-prefix=ERROR %s
+
+// CHECK: { "directory": "[[CWD:[^"]+]]", "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]", "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
+
+int main(void) {
+ return 0;
+}
OpenPOWER on IntegriCloud