diff options
author | Sam McCall <sam.mccall@gmail.com> | 2019-05-07 14:34:06 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-05-07 14:34:06 +0000 |
commit | 87ad30be5ffa6fa2acbc703e4a85a73fd1181016 (patch) | |
tree | 2fcfecb10be0b63d47f555042ac92e19176bd419 /clang/unittests/Tooling/CompilationDatabaseTest.cpp | |
parent | d6865b7d71bc4bd0d7251a1ab1979e54c57856cd (diff) | |
download | bcm5719-llvm-87ad30be5ffa6fa2acbc703e4a85a73fd1181016.tar.gz bcm5719-llvm-87ad30be5ffa6fa2acbc703e4a85a73fd1181016.zip |
[Tooling] Add -x flags when inferring compile commands for files with no/invalid extension.
Summary: We treat them as headers, as the motivating case is C++ standard library.
Reviewers: kadircet
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D61633
llvm-svn: 360153
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/CompilationDatabaseTest.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp index 4e27df71d87..19b797a0a64 100644 --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -723,14 +723,17 @@ TEST_F(InterpolateTest, Language) { // .h is ambiguous, so we add explicit language flags EXPECT_EQ(getCommand("foo.h"), "clang -D dir/foo.cpp -x c++-header -std=c++17"); + // Same thing if we have no extension. (again, we treat as header). + EXPECT_EQ(getCommand("foo"), "clang -D dir/foo.cpp -x c++-header -std=c++17"); + // and invalid extensions. + EXPECT_EQ(getCommand("foo.cce"), + "clang -D dir/foo.cpp -x c++-header -std=c++17"); // and don't add -x if the inferred language is correct. EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17"); // respect -x if it's already there. EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header"); // prefer a worse match with the right extension. EXPECT_EQ(getCommand("foo.c"), "clang -D dir/bar.c"); - // make sure we don't crash on queries with invalid extensions. - EXPECT_EQ(getCommand("foo.cce"), "clang -D dir/foo.cpp"); 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"); |