diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2016-12-01 23:37:45 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2016-12-01 23:37:45 +0000 |
commit | 399aea300f220ee3715cb22b32ac90bb57eca30d (patch) | |
tree | 5743382e90a275740cedb4cfe9ef5f638cf515b0 /clang/unittests/Tooling/CompilationDatabaseTest.cpp | |
parent | 85c2184a8e75df6cad959dd93275ef31dcf53834 (diff) | |
download | llvm-399aea300f220ee3715cb22b32ac90bb57eca30d.zip llvm-399aea300f220ee3715cb22b32ac90bb57eca30d.tar.gz llvm-399aea300f220ee3715cb22b32ac90bb57eca30d.tar.bz2 |
Extend CompilationDatabase by a field for the output filename
In bigger projects like an Operating System, the same source code is
often compiled in slightly different ways. This could be the difference
between PIC and non-PIC code for static vs dynamic libraries, it could
also be the difference between size optimised versions of tools for
ramdisk images. At the moment, the compilation database has no way to
distinguish such cases. As first step, add a field in the JSON format
for it and process it accordingly.
Differential Revision: https://reviews.llvm.org/D27138
llvm-svn: 288436
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/CompilationDatabaseTest.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp index 4853983..1a6fffe 100644 --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -44,6 +44,7 @@ TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) { expectFailure("[{\"directory\":\"\",\"command\":[],\"file\":\"\"}]", "Command not string"); expectFailure("[{\"directory\":\"\",\"arguments\":[[]],\"file\":\"\"}]", "Arguments contain non-string"); + expectFailure("[{\"output\":[]}]", "Expected strings as value."); } static std::vector<std::string> getAllFiles(StringRef JSONDatabase, @@ -105,16 +106,19 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) { StringRef Directory1("//net/dir1"); StringRef FileName1("file1"); StringRef Command1("command1"); + StringRef Output1("file1.o"); StringRef Directory2("//net/dir2"); StringRef FileName2("file2"); StringRef Command2("command2"); + StringRef Output2(""); std::vector<CompileCommand> Commands = getAllCompileCommands( JSONCommandLineSyntax::Gnu, ("[{\"directory\":\"" + Directory1 + "\"," + "\"command\":\"" + Command1 + "\"," "\"file\":\"" + - FileName1 + "\"}," + FileName1 + "\", \"output\":\"" + + Output1 + "\"}," " {\"directory\":\"" + Directory2 + "\"," + "\"command\":\"" + Command2 + "\"," "\"file\":\"" + @@ -124,10 +128,12 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) { EXPECT_EQ(2U, Commands.size()) << ErrorMessage; EXPECT_EQ(Directory1, Commands[0].Directory) << ErrorMessage; EXPECT_EQ(FileName1, Commands[0].Filename) << ErrorMessage; + EXPECT_EQ(Output1, Commands[0].Output) << ErrorMessage; ASSERT_EQ(1u, Commands[0].CommandLine.size()); EXPECT_EQ(Command1, Commands[0].CommandLine[0]) << ErrorMessage; EXPECT_EQ(Directory2, Commands[1].Directory) << ErrorMessage; EXPECT_EQ(FileName2, Commands[1].Filename) << ErrorMessage; + EXPECT_EQ(Output2, Commands[1].Output) << ErrorMessage; ASSERT_EQ(1u, Commands[1].CommandLine.size()); EXPECT_EQ(Command2, Commands[1].CommandLine[0]) << ErrorMessage; |