[PATCH] D71727: [clang][Tooling] Prefer -x over -std when interpolating
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 20 02:20:55 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2377eae286b: [clang][Tooling] Prefer -x over -std when interpolating (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71727/new/
https://reviews.llvm.org/D71727
Files:
clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
clang/unittests/Tooling/CompilationDatabaseTest.cpp
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===================================================================
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -749,6 +749,7 @@
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 @@
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) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===================================================================
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,7 +191,8 @@
OldArgs.data() + OldPos, OldArgs.data() + Pos);
}
- if (Std != LangStandard::lang_unspecified) // -std take precedence over -x
+ // Make use of -std iff -x was missing.
+ if (Type == types::TY_INVALID && Std != LangStandard::lang_unspecified)
Type = toType(LangStandard::getLangStandardForKind(Std).getLanguage());
Type = foldType(*Type);
// The contract is to store None instead of TY_INVALID.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71727.234843.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191220/8efaa356/attachment.bin>
More information about the cfe-commits
mailing list