r201604 - clang-cl /fallback: emit a note when falling back

Hans Wennborg hans at hanshq.net
Tue Feb 18 13:42:51 PST 2014


Author: hans
Date: Tue Feb 18 15:42:51 2014
New Revision: 201604

URL: http://llvm.org/viewvc/llvm-project?rev=201604&view=rev
Log:
clang-cl /fallback: emit a note when falling back

This makes it a lot easier to see what's going on from the output.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=201604&r1=201603&r2=201604&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Feb 18 15:42:51 2014
@@ -170,4 +170,6 @@ def err_analyzer_config_multiple_values
 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">;
 }

Modified: cfe/trunk/include/clang/Driver/Job.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=201604&r1=201603&r2=201604&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Job.h (original)
+++ cfe/trunk/include/clang/Driver/Job.h Tue Feb 18 15:42:51 2014
@@ -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) {

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=201604&r1=201603&r2=201604&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Tue Feb 18 15:42:51 2014
@@ -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 Strin
   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;
 }

Modified: cfe/trunk/test/Driver/cl-fallback.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-fallback.c?rev=201604&r1=201603&r2=201604&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-fallback.c (original)
+++ cfe/trunk/test/Driver/cl-fallback.c Tue Feb 18 15:42:51 2014
@@ -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."





More information about the cfe-commits mailing list