Introduce a limit on the depth of the macro instantiation backtrace
printed in a diagnostic, similar to the limit we already have on the
depth of the template instantiation backtrace. The macro instantiation
backtrace is limited to 10 "instantiated from:" diagnostics; when it's
longer than that, we'll show the first half, then say how many were
suppressed, then show the second half. The limit can be changed with
-fmacro-instantiation-limit=N, and turned off with N=0.
This eliminates a lot of note spew with libraries making use of the
Boost.Preprocess library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 176d491..5a3916d 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -21,6 +21,7 @@
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Util.h"
+#include "clang/Frontend/DiagnosticOptions.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
@@ -1082,11 +1083,19 @@
else
CmdArgs.push_back("19");
+ CmdArgs.push_back("-fmacro-backtrace-limit");
+ if (Arg *A = Args.getLastArg(options::OPT_fmacro_backtrace_limit_EQ))
+ CmdArgs.push_back(A->getValue(Args));
+ else
+ CmdArgs.push_back(Args.MakeArgString(
+ llvm::Twine(DiagnosticOptions::DefaultMacroBacktraceLimit)));
+
CmdArgs.push_back("-ftemplate-backtrace-limit");
if (Arg *A = Args.getLastArg(options::OPT_ftemplate_backtrace_limit_EQ))
CmdArgs.push_back(A->getValue(Args));
else
- CmdArgs.push_back("10");
+ CmdArgs.push_back(Args.MakeArgString(
+ llvm::Twine(DiagnosticOptions::DefaultTemplateBacktraceLimit)));
// Pass -fmessage-length=.
CmdArgs.push_back("-fmessage-length");