From: Reid Kleckner Date: Wed, 4 Sep 2013 01:37:22 +0000 (+0000) Subject: clang-cl: Avoid confusing diagnostics when clang-cl is called just cl.exe X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b7fd838f24f67920d5287962765b772592e905e;p=clang clang-cl: Avoid confusing diagnostics when clang-cl is called just cl.exe git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189901 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 88863ab066..15936bf219 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -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 DiagID(new DiagnosticIDs()); DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);