blob: ff4e97b1d458761a1c3d59103f0982acca0b8d79 [file] [log] [blame]
Daniel Dunbar2ba38ba2009-03-16 05:25:36 +00001//===--- ToolChain.cpp - Collections of tools for one platform ----------*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/Driver/ToolChain.h"
11
12#include "clang/Driver/Action.h"
13#include "clang/Driver/Driver.h"
14
15using namespace clang::driver;
16
17ToolChain::ToolChain(Driver &_TheDriver, const char *_Arch,
18 const char *_Platform, const char *_OS)
19 : TheDriver(_TheDriver), Arch(_Arch), Platform(_Platform), OS(_OS) {
20}
21
22ToolChain::~ToolChain() {
23}
24
25llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
26 const char *Name) const {
27 return TheDriver.GetFilePath(Name, this);
28
29}
30
31llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
32 const char *Name) const {
33 return TheDriver.GetProgramPath(Name, this);
34}
35
36bool ToolChain::ShouldUseClangCompiler(const Compilation &C,
37 const JobAction &JA) const {
38 // Check if user requested no clang, or clang doesn't understand
39 // this type (we only handle single inputs for now).
40 if (TheDriver.CCCNoClang || JA.size() != 1 ||
41 !types::isAcceptedByClang((*JA.begin())->getType()))
42 return false;
43
44 // Otherwise make sure this is an action clang undertands.
45 if (isa<PreprocessJobAction>(JA)) {
46 if (TheDriver.CCCNoClangCPP)
47 return false;
48 } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
49 return false;
50
51 // Avoid CXX if the user requested.
52 if (TheDriver.CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
53 return false;
54
55 // Finally, don't use clang if this isn't one of the user specified
56 // archs to build.
57 if (!TheDriver.CCCClangArchs.empty() &&
58 TheDriver.CCCClangArchs.count(getArchName()))
59 return false;
60
61 return true;
62}