summaryrefslogtreecommitdiff
path: root/tools/driver/driver.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-07-18 20:29:38 +0000
committerHans Wennborg <hans@hanshq.net>2013-07-18 20:29:38 +0000
commit76b86c2e79a58910a641d449f229889d671d8a38 (patch)
tree99ba12e631e2994533659c466af0418021bdcdf4 /tools/driver/driver.cpp
parentbbbb0fe4f466d3163fcbf0a64ebf0f5868833efb (diff)
downloadclang-76b86c2e79a58910a641d449f229889d671d8a38.tar.gz
clang-76b86c2e79a58910a641d449f229889d671d8a38.tar.bz2
clang-76b86c2e79a58910a641d449f229889d671d8a38.tar.xz
Turn Driver::CCCIsCXX and CCCIsCPP into a single Mode enum,
and add a new option --driver-mode= to control it explicitly. The CCCIsCXX and CCCIsCPP flags were non-overlapping, i.e. there are currently really three modes that Clang can run in: gcc, g++ or cpp, so it makes sense to represent them as an enum. Having a command line flag to control it helps testing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver/driver.cpp')
-rw-r--r--tools/driver/driver.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 2a40a86c91..b3f2a83e12 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -210,19 +210,18 @@ static void ParseProgName(SmallVectorImpl<const char *> &ArgVector,
// is gets added via -target as implicit first argument.
static const struct {
const char *Suffix;
- bool IsCXX;
- bool IsCPP;
+ const char *ModeFlag;
} suffixes [] = {
- { "clang", false, false },
- { "clang++", true, false },
- { "clang-c++", true, false },
- { "clang-cc", false, false },
- { "clang-cpp", false, true },
- { "clang-g++", true, false },
- { "clang-gcc", false, false },
- { "cc", false, false },
- { "cpp", false, true },
- { "++", true, false },
+ { "clang", 0 },
+ { "clang++", "--driver-mode=g++" },
+ { "clang-c++", "--driver-mode=g++" },
+ { "clang-cc", 0 },
+ { "clang-cpp", "--driver-mode=cpp" },
+ { "clang-g++", "--driver-mode=g++" },
+ { "clang-gcc", 0 },
+ { "cc", 0 },
+ { "cpp", "--driver-mode=cpp" },
+ { "++", "--driver-mode=g++" },
};
std::string ProgName(llvm::sys::path::stem(ArgVector[0]));
StringRef ProgNameRef(ProgName);
@@ -235,10 +234,11 @@ static void ParseProgName(SmallVectorImpl<const char *> &ArgVector,
for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) {
if (ProgNameRef.endswith(suffixes[i].Suffix)) {
FoundMatch = true;
- if (suffixes[i].IsCXX)
- TheDriver.CCCIsCXX = true;
- if (suffixes[i].IsCPP)
- TheDriver.CCCIsCPP = true;
+ SmallVectorImpl<const char *>::iterator it = ArgVector.begin();
+ if (it != ArgVector.end())
+ ++it;
+ if (suffixes[i].ModeFlag)
+ ArgVector.insert(it, suffixes[i].ModeFlag);
break;
}
}