From 06bf1dda55b5db4ab6f583be1c2adf8af00109e3 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 18 Feb 2014 21:42:51 +0000 Subject: [PATCH] clang-cl /fallback: emit a note when falling back 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 | 2 ++ include/clang/Driver/Job.h | 2 ++ lib/Driver/Job.cpp | 8 ++++++++ test/Driver/cl-fallback.c | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index cc7d8969f3..214b203dfb 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -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='">; + +def note_drv_invoking_fallback : Note<"falling back to %0">; } diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h index 1dd49a7923..d7e74a9ce8 100644 --- a/include/clang/Driver/Job.h +++ b/include/clang/Driver/Job.h @@ -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) { diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index ee68e6f14d..7fd43e3c56 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -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; } diff --git a/test/Driver/cl-fallback.c b/test/Driver/cl-fallback.c index 9b33b0c0a7..f58aa3262f 100644 --- a/test/Driver/cl-fallback.c +++ b/test/Driver/cl-fallback.c @@ -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." -- 2.40.0