From f5f1f63df1b65b19c63a06ff10921f08ce043a81 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 30 Jun 2017 13:21:27 +0000 Subject: [Driver] Actually report errors during parsing instead of stopping when there's an error somewhere. This is a more principled version of r303756. That change was both very brittle about the state of the Diags object going into the driver and also broke tooling in funny ways. In particular it prevented tools from capturing diagnostics properly and made the compilation database logic fail to provide arguments to the tool, falling back to scanning directories for JSON files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306822 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Driver/ToolChainTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'unittests') diff --git a/unittests/Driver/ToolChainTest.cpp b/unittests/Driver/ToolChainTest.cpp index bce2748aa2..ec50560b20 100644 --- a/unittests/Driver/ToolChainTest.cpp +++ b/unittests/Driver/ToolChainTest.cpp @@ -152,5 +152,16 @@ TEST(ToolChainTest, DefaultDriverMode) { EXPECT_TRUE(CXXDriver.CCCIsCXX()); EXPECT_TRUE(CLDriver.IsCLMode()); } +TEST(ToolChainTest, InvalidArgument) { + IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); + struct TestDiagnosticConsumer : public DiagnosticConsumer {}; + IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); + DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); + Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags); + std::unique_ptr C(TheDriver.BuildCompilation( + {"-fsyntax-only", "-fan-unknown-option", "foo.cpp"})); + EXPECT_TRUE(C); + EXPECT_TRUE(C->containsError()); +} } // end anonymous namespace. -- cgit v1.2.3