diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-08-28 16:15:56 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-08-28 16:15:56 +0000 |
commit | 5167e2d1afc5a6c89cbbfea4243864b58a8ce37a (patch) | |
tree | a6142d04b9abae6f18539759857f3c561ce0246b /clang/unittests/Tooling/CompilationDatabaseTest.cpp | |
parent | 6a92b5e1e2a608cfb726bdcd5b043aee2cc350c5 (diff) | |
download | llvm-5167e2d1afc5a6c89cbbfea4243864b58a8ce37a.zip llvm-5167e2d1afc5a6c89cbbfea4243864b58a8ce37a.tar.gz llvm-5167e2d1afc5a6c89cbbfea4243864b58a8ce37a.tar.bz2 |
Parse compile commands lazily in InterpolatingCompilationDatabase
Summary:
This greatly reduces the time to read 'compile_commands.json'.
For Chromium on my machine it's now 0.7 seconds vs 30 seconds before the
change.
Reviewers: sammccall, jfb
Reviewed By: sammccall
Subscribers: mgrang, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D51314
llvm-svn: 340838
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/CompilationDatabaseTest.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp index ffc1d5b..cbe4d28 100644 --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -707,6 +707,7 @@ TEST_F(InterpolateTest, Nearby) { TEST_F(InterpolateTest, Language) { add("dir/foo.cpp", "-std=c++17"); + add("dir/bar.c", ""); add("dir/baz.cee", "-x c"); // .h is ambiguous, so we add explicit language flags @@ -716,9 +717,11 @@ TEST_F(InterpolateTest, Language) { 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 language - EXPECT_EQ(getCommand("foo.c"), "clang -D dir/baz.cee"); - Entries.erase(path(StringRef("dir/baz.cee"))); + // 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"); } |