summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Driver/ToolChainTest.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-08-12 17:47:52 +0000
committerZachary Turner <zturner@google.com>2016-08-12 17:47:52 +0000
commitaff19c3864cfb4f80b3b47863e085d9f4edc8b0e (patch)
treef46725f4cb92de5d2f932e7252b33f1f9ba5168a /clang/unittests/Driver/ToolChainTest.cpp
parent03878729fb6e12e4289676494008663d45963b7a (diff)
downloadbcm5719-llvm-aff19c3864cfb4f80b3b47863e085d9f4edc8b0e.tar.gz
bcm5719-llvm-aff19c3864cfb4f80b3b47863e085d9f4edc8b0e.zip
[Driver] Set the default driver mode based on the executable.
Currently, if --driver-mode is not passed at all, it will default to GCC style driver. This is never an issue for clang because it manually constructs a --driver-mode option and passes it. However, we should still try to do as good as we can even if no --driver-mode is passed. LibTooling, for example, does not pass a --driver-mode option and while it could, it seems like we should still fallback to the best possible default we can. This is one of two steps necessary to get clang-tidy working on Windows. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D23454 llvm-svn: 278535
Diffstat (limited to 'clang/unittests/Driver/ToolChainTest.cpp')
-rw-r--r--clang/unittests/Driver/ToolChainTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index ef21e2d17c6..f7ba3eeab21 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -117,4 +117,29 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
S);
}
+TEST(ToolChainTest, DefaultDriverMode) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
+
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+ DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+ IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ new vfs::InMemoryFileSystem);
+
+ Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+ InMemoryFileSystem);
+ Driver CXXDriver("/home/test/bin/clang++", "arm-linux-gnueabi", Diags,
+ InMemoryFileSystem);
+ Driver CLDriver("/home/test/bin/clang-cl", "arm-linux-gnueabi", Diags,
+ InMemoryFileSystem);
+
+ std::unique_ptr<Compilation> CC(CCDriver.BuildCompilation({"foo.cpp"}));
+ std::unique_ptr<Compilation> CXX(CXXDriver.BuildCompilation({"foo.cpp"}));
+ std::unique_ptr<Compilation> CL(CLDriver.BuildCompilation({"foo.cpp"}));
+
+ EXPECT_TRUE(CCDriver.CCCIsCC());
+ EXPECT_TRUE(CXXDriver.CCCIsCXX());
+ EXPECT_TRUE(CLDriver.IsCLMode());
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud