aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index df71c97215..1e10ac5c8f 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -981,3 +981,30 @@ const HostInfo *Driver::GetHostInfo(const char *Triple) const {
return createUnknownHostInfo(*this, Arch.c_str(), Platform.c_str(),
OS.c_str());
}
+
+bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
+ const std::string &ArchName) const {
+ // Check if user requested no clang, or clang doesn't understand
+ // this type (we only handle single inputs for now).
+ if (CCCNoClang || JA.size() != 1 ||
+ !types::isAcceptedByClang((*JA.begin())->getType()))
+ return false;
+
+ // Otherwise make sure this is an action clang undertands.
+ if (isa<PreprocessJobAction>(JA)) {
+ if (CCCNoClangCPP)
+ return false;
+ } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
+ return false;
+
+ // Avoid CXX if the user requested.
+ if (CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
+ return false;
+
+ // Finally, don't use clang if this isn't one of the user specified
+ // archs to build.
+ if (!CCCClangArchs.empty() && !CCCClangArchs.count(ArchName))
+ return false;
+
+ return true;
+}