summaryrefslogtreecommitdiffstats
path: root/clang/tools/driver/driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-10 18:47:41 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-10 18:47:41 +0000
commitf76c9d270a9b4021ee432a80f07dd98efb86c2c5 (patch)
tree205c0b0eae6b826fd3625ad14b2d261f5a8597d1 /clang/tools/driver/driver.cpp
parentef2919f1fa4cc5e497fa2a37fa3981967c7688db (diff)
downloadbcm5719-llvm-f76c9d270a9b4021ee432a80f07dd98efb86c2c5.tar.gz
bcm5719-llvm-f76c9d270a9b4021ee432a80f07dd98efb86c2c5.zip
Driver: Run 'clang' in C++ mode based on the name it was invoked by. We match
anything that ends with ++ or ++-FOO (e.g., c++, clang++, clang++-1.1) as being a "C++ compiler". This allows easy testing of the C++ compiler by 'ln -s clang clang++', or by 'cp clang clang++'. Based on patch by Roman Divacky. llvm-svn: 86697
Diffstat (limited to 'clang/tools/driver/driver.cpp')
-rw-r--r--clang/tools/driver/driver.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 9d204ce6c0c..1947bac99b5 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -197,6 +197,15 @@ int main(int argc, const char **argv) {
llvm::sys::getHostTriple().c_str(),
"a.out", IsProduction, Diags);
+ // Check for ".*++" or ".*++-[^-]*" to determine if we are a C++
+ // compiler. This matches things like "c++", "clang++", and "clang++-1.1".
+ //
+ // Note that we intentionally want to use argv[0] here, to support "clang++"
+ // being a symlink.
+ llvm::StringRef ProgName(llvm::sys::Path(argv[0]).getBasename());
+ if (ProgName.endswith("++") || ProgName.rsplit('-').first.endswith("++"))
+ TheDriver.CCCIsCXX = true;
+
llvm::OwningPtr<Compilation> C;
// Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a
OpenPOWER on IntegriCloud