From cd121fb0137d628527f40d8e980bc61b81119f66 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 4 May 2010 17:13:42 +0000 Subject: 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. llvm-svn: 103014 --- clang/test/Misc/macro-backtrace-limit.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 clang/test/Misc/macro-backtrace-limit.c (limited to 'clang/test/Misc/macro-backtrace-limit.c') diff --git a/clang/test/Misc/macro-backtrace-limit.c b/clang/test/Misc/macro-backtrace-limit.c new file mode 100644 index 00000000000..bc7a4da93a5 --- /dev/null +++ b/clang/test/Misc/macro-backtrace-limit.c @@ -0,0 +1,32 @@ +// RUN: %clang-cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s > %t 2>&1 +// RUN: FileCheck %s < %t + +#define M1(A, B) ((A) < (B)) +#define M2(A, B) M1(A, B) +#define M3(A, B) M2(A, B) +#define M4(A, B) M3(A, B) +#define M5(A, B) M4(A, B) +#define M6(A, B) M5(A, B) +#define M7(A, B) M6(A, B) +#define M8(A, B) M7(A, B) +#define M9(A, B) M8(A, B) +#define M10(A, B) M9(A, B) +#define M11(A, B) M10(A, B) +#define M12(A, B) M11(A, B) + +void f(int *ip, float *fp) { + // CHECK: macro-backtrace-limit.c:31:7: warning: comparison of distinct pointer types ('int *' and 'float *') + // CHECK: if (M12(ip, fp)) { } + // CHECK: macro-backtrace-limit.c:15:19: note: instantiated from: + // CHECK: #define M12(A, B) M11(A, B) + // CHECK: macro-backtrace-limit.c:14:19: note: instantiated from: + // CHECK: #define M11(A, B) M10(A, B) + // CHECK: note: (skipping 7 contexts in backtrace; use -fmacro-backtrace-limit=0 to see all) + // CHECK: macro-backtrace-limit.c:6:18: note: instantiated from: + // CHECK: #define M3(A, B) M2(A, B) + // CHECK: macro-backtrace-limit.c:5:18: note: instantiated from: + // CHECK: #define M2(A, B) M1(A, B) + // CHECK: macro-backtrace-limit.c:4:23: note: instantiated from: + // CHECK: #define M1(A, B) ((A) < (B)) + if (M12(ip, fp)) { } +} -- cgit v1.2.3