summaryrefslogtreecommitdiffstats
path: root/clang/test/Misc/macro-backtrace-limit.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-04 17:13:42 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-04 17:13:42 +0000
commitcd121fb0137d628527f40d8e980bc61b81119f66 (patch)
tree519a0ce3fceab69f324922b1420ea081b7b5e2fe /clang/test/Misc/macro-backtrace-limit.c
parenta5c0cc329e44601b1318f9223af1e60a45196dc8 (diff)
downloadbcm5719-llvm-cd121fb0137d628527f40d8e980bc61b81119f66.tar.gz
bcm5719-llvm-cd121fb0137d628527f40d8e980bc61b81119f66.zip
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
Diffstat (limited to 'clang/test/Misc/macro-backtrace-limit.c')
-rw-r--r--clang/test/Misc/macro-backtrace-limit.c32
1 files changed, 32 insertions, 0 deletions
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)) { }
+}
OpenPOWER on IntegriCloud