summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-09-27 08:14:45 +0000
committerHans Wennborg <hans@hanshq.net>2019-09-27 08:14:45 +0000
commit362345769a36814f3f3bb9f711643aa05b6b5697 (patch)
tree8641264363bd30d2f7351f822aa1b8e48da4509b
parent8ef97e1aad77bfb8f562c2b5ee0944a5eca44e84 (diff)
downloadbcm5719-llvm-362345769a36814f3f3bb9f711643aa05b6b5697.tar.gz
bcm5719-llvm-362345769a36814f3f3bb9f711643aa05b6b5697.zip
Fix the 'directory' field in DumpCompilationDatabase and add test
This broke in r371027 due to a missing negation (llvm::sys::fs::current_path returns false on success). llvm-svn: 373049
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp2
-rw-r--r--clang/test/Driver/compilation_database.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5484a9289cd..309ce7fdc75 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2027,7 +2027,7 @@ void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
}
auto &CDB = *CompilationDatabase;
SmallString<128> Buf;
- if (!llvm::sys::fs::current_path(Buf))
+ if (llvm::sys::fs::current_path(Buf))
Buf = ".";
CDB << "{ \"directory\": \"" << escape(Buf) << "\"";
CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
diff --git a/clang/test/Driver/compilation_database.c b/clang/test/Driver/compilation_database.c
index 017178d60cd..343b76aa44f 100644
--- a/clang/test/Driver/compilation_database.c
+++ b/clang/test/Driver/compilation_database.c
@@ -1,8 +1,8 @@
-// RUN: mkdir -p %t && cd %t
+// RUN: mkdir -p %t.workdir && cd %t.workdir
// 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
-// CHECK: { "directory": "{{.*}}", "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir", "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={{[^"]+}}"]},
// ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
OpenPOWER on IntegriCloud