r189901 - clang-cl: Avoid confusing diagnostics when clang-cl is called just cl.exe

Reid Kleckner reid at kleckner.net
Tue Sep 3 18:37:22 PDT 2013


Author: rnk
Date: Tue Sep  3 20:37:22 2013
New Revision: 189901

URL: http://llvm.org/viewvc/llvm-project?rev=189901&view=rev
Log:
clang-cl: Avoid confusing diagnostics when clang-cl is called just cl.exe

Modified:
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=189901&r1=189900&r2=189901&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Tue Sep  3 20:37:22 2013
@@ -346,7 +346,14 @@ int main(int argc_, const char **argv_)
   // DiagnosticOptions instance.
   TextDiagnosticPrinter *DiagClient
     = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
-  DiagClient->setPrefix(llvm::sys::path::filename(Path));
+
+  // If the clang binary happens to be named cl.exe for compatibility reasons,
+  // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC.
+  StringRef ExeBasename(llvm::sys::path::filename(Path));
+  if (ExeBasename.trim().equals_lower("cl.exe"))
+    ExeBasename = "clang-cl.exe";
+  DiagClient->setPrefix(ExeBasename);
+
   IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
 
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);





More information about the cfe-commits mailing list