aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/CompilationDatabaseTest.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-12-19 22:22:01 +0100
committerKadir Cetinkaya <kadircet@google.com>2019-12-20 11:10:36 +0100
commitc2377eae286bbe616267bef772ee736b030dd007 (patch)
tree0fe97afeef4533fd328a5a2ea2b432fbf136146b /clang/unittests/Tooling/CompilationDatabaseTest.cpp
parent29bd2194979c50097edb39a4beb714bff8c153a1 (diff)
downloadllvm-c2377eae286bbe616267bef772ee736b030dd007.zip
llvm-c2377eae286bbe616267bef772ee736b030dd007.tar.gz
llvm-c2377eae286bbe616267bef772ee736b030dd007.tar.bz2
[clang][Tooling] Prefer -x over -std when interpolating
Summary: Currently interpolation logic prefers -std over -x. But the latter is a more strong signal, so this patch inverts the order and only makes use of -std if -x didn't exist. Fixes https://github.com/clangd/clangd/issues/185 Thanks @sammccall for tracking this down! Reviewers: sammccall Subscribers: ilya-biryukov, usaxena95, cfe-commits, sammccall Tags: #clang Differential Revision: https://reviews.llvm.org/D71727
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 91685c0..56ebadc 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -749,6 +749,7 @@ TEST_F(InterpolateTest, Language) {
add("dir/foo.cpp", "-std=c++17");
add("dir/bar.c", "");
add("dir/baz.cee", "-x c");
+ add("dir/aux.cpp", "-std=c++17 -x objective-c++");
// .h is ambiguous, so we add explicit language flags
EXPECT_EQ(getCommand("foo.h"),
@@ -767,6 +768,9 @@ TEST_F(InterpolateTest, Language) {
Entries.erase(path(StringRef("dir/bar.c")));
// Now we transfer across languages, so drop -std too.
EXPECT_EQ(getCommand("foo.c"), "clang -D dir/foo.cpp");
+ // Prefer -x over -std when overriding language.
+ EXPECT_EQ(getCommand("aux.h"),
+ "clang -D dir/aux.cpp -x objective-c++-header -std=c++17");
}
TEST_F(InterpolateTest, Strip) {