]> granicus.if.org Git - clang/commitdiff
Driver: Run 'clang' in C++ mode based on the name it was invoked by. We match
authorDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 18:47:41 +0000 (18:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 18:47:41 +0000 (18:47 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86697 91177308-0d34-0410-b5e6-96231b3b80d8

tools/driver/driver.cpp

index 9d204ce6c0c23d57f023186f30d3c787c5712c2a..1947bac99b50161b2461039bb7079bbcf1a1f2b4 100644 (file)
@@ -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