]> granicus.if.org Git - clang/commitdiff
clang-cl /fallback: emit a note when falling back
authorHans Wennborg <hans@hanshq.net>
Tue, 18 Feb 2014 21:42:51 +0000 (21:42 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 18 Feb 2014 21:42:51 +0000 (21:42 +0000)
This makes it a lot easier to see what's going on from the output.

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

include/clang/Basic/DiagnosticDriverKinds.td
include/clang/Driver/Job.h
lib/Driver/Job.cpp
test/Driver/cl-fallback.c

index cc7d8969f37992048fba7a03567a128a99d5aa22..214b203dfbb22e3ba010063cde7315d738110550 100644 (file)
@@ -170,4 +170,6 @@ def err_analyzer_config_multiple_values : Error<
 def err_drv_modules_validate_once_requires_timestamp : Error<
   "option '-fmodules-validate-once-per-build-session' requires "
   "'-fbuild-session-timestamp=<seconds since Epoch>'">;
+
+def note_drv_invoking_fallback : Note<"falling back to %0">;
 }
index 1dd49a792356672a6fa9e1518ae05d6fac635766..d7e74a9ce83e7e3a5f74d886e176b4f3ca08afb2 100644 (file)
@@ -88,6 +88,8 @@ public:
   /// getCreator - Return the Tool which caused the creation of this job.
   const Tool &getCreator() const { return Creator; }
 
+  const char *getExecutable() const { return Executable; }
+
   const llvm::opt::ArgStringList &getArguments() const { return Arguments; }
 
   static bool classof(const Job *J) {
index ee68e6f14d51cbeeebe5462df4e4cbcbf8e3df41..7fd43e3c56cad972528b4094628a1f1458d43d0f 100644 (file)
@@ -7,7 +7,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Job.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -159,6 +163,10 @@ int FallbackCommand::Execute(const StringRef **Redirects, std::string *ErrMsg,
   if (ExecutionFailed)
     *ExecutionFailed = false;
 
+  const Driver &D = getCreator().getToolChain().getDriver();
+  D.Diag(diag::note_drv_invoking_fallback).setForceEmit()
+      << Fallback->getExecutable();
+
   int SecondaryStatus = Fallback->Execute(Redirects, ErrMsg, ExecutionFailed);
   return SecondaryStatus;
 }
index 9b33b0c0a74843b40b2e6fb78b4314bd0d47ec78..f58aa3262fe24be12bb9ebd10587537362f2f32b 100644 (file)
@@ -44,3 +44,9 @@
 // RUN: %clang_cl /fallback /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
 // P-NOT: ||
 // P-NOT: "cl.exe"
+
+// RUN: not %clang_cl /fallback /c -- %s 2>&1 | \
+// RUN:     FileCheck -check-prefix=ErrNote %s
+// ErrNote: note: falling back to cl.exe
+
+#error "This fails to compile."