From cf1b401909b5e54edfd80656b1a18eaa31f9f6f1 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 1 Jul 2017 13:24:05 +0000 Subject: Vendor import of clang trunk r306956: https://llvm.org/svn/llvm-project/cfe/trunk@306956 --- unittests/Tooling/CompilationDatabaseTest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'unittests/Tooling/CompilationDatabaseTest.cpp') diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index 5a6693eb4dbb6..fd8afe6b79762 100644 --- a/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/unittests/Tooling/CompilationDatabaseTest.cpp @@ -586,6 +586,27 @@ TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) { EXPECT_EQ(2, Argc); } +TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) { + // Adjust the given command line arguments to ensure that any positional + // arguments in them are stripped. + const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"}; + int Argc = llvm::array_lengthof(Argv); + std::string ErrorMessage; + std::unique_ptr Database = + FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage); + ASSERT_TRUE((bool)Database); + ASSERT_TRUE(ErrorMessage.empty()); + std::vector Result = Database->getCompileCommands("source"); + ASSERT_EQ(1ul, Result.size()); + ASSERT_EQ(".", Result[0].Directory); + std::vector Expected; + Expected.push_back("clang-tool"); + Expected.push_back("-fsyntax-only"); + Expected.push_back("-DDEF3"); + Expected.push_back("source"); + ASSERT_EQ(Expected, Result[0].CommandLine); +} + TEST(ParseFixedCompilationDatabase, HandlesArgv0) { const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"}; int Argc = sizeof(Argv) / sizeof(char*); -- cgit v1.2.3