[PATCH] D11778: Improvements on Diagnostic in Macro Expansions

Richard Trieu rtrieu at google.com
Wed Aug 5 14:54:23 PDT 2015


rtrieu added a comment.

Some questions about your tests.


================
Comment at: test/Misc/reduced-diags-macros-backtrace.cpp:27
@@ +26,3 @@
+// ALL-NEXT: {{.*}}:7:23: note: expanded from macro 'LEVEL4'
+// ALL-NEXT: #define LEVEL4(x) ADD(p,x)
+// ALL-NEXT:                       ^
----------------
Why are macro notes printed after this one?  Clang found 'p' so it does not need to give any more information.

================
Comment at: test/Misc/reduced-diags-macros-backtrace.cpp:36
@@ +35,3 @@
+// ALL-NEXT: {{.*}}:12:16: error: use of undeclared identifier 'b'
+// ALL-NEXT: int a = LEVEL1(b);
+// ALL-NEXT:                ^
----------------
Same question, why are notes still printed after this one?

================
Comment at: test/Misc/reduced-diags-macros-backtrace.cpp:53-78
@@ +52,27 @@
+// SKIP: {{.*}}:12:9: error: use of undeclared identifier 'p'
+// SKIP-ALL: int a = LEVEL1(b);
+// SKIP-ALL:         ^
+// SKIP-ALL: {{.*}}:10:19: note: expanded from macro 'LEVEL1'
+// SKIP-ALL: #define LEVEL1(x) LEVEL2(x)
+// SKIP-ALL:                   ^
+// SKIP-ALL: note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+// SKIP-ALL: {{.*}}:6:20: note: expanded from macro 'ADD'
+// SKIP-ALL: #define ADD(x,y) G(x) + y
+// SKIP-ALL:                    ^
+// SKIP-ALL: {{.*}}:5:16: note: expanded from macro 'G'
+// SKIP-ALL: #define G(x) F(x) + 2
+// SKIP-ALL:                ^
+// SKIP-ALL: {{.*}}:12:16: error: use of undeclared identifier 'b'
+// SKIP-ALL: int a = LEVEL1(b);
+// SKIP-ALL:                ^
+// SKIP-ALL: {{.*}}:10:26: note: expanded from macro 'LEVEL1'
+// SKIP-ALL: #define LEVEL1(x) LEVEL2(x)
+// SKIP-ALL:                          ^
+// SKIP-ALL: note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+// SKIP-ALL: {{.*}}:8:26: note: expanded from macro 'LEVEL3'
+// SKIP-ALL: #define LEVEL3(x) LEVEL4(x)
+// SKIP-ALL:                          ^
+// SKIP-ALL: {{.*}}:7:25: note: expanded from macro 'LEVEL4'
+// SKIP-ALL: #define LEVEL4(x) ADD(p,x)
+// SKIP-ALL:                         ^
+// SKIP-ALL: 2 errors generated.
----------------
Did you mean "SKIP-NEXT"?

================
Comment at: test/Misc/reduced-diags-macros.cpp:13-14
@@ +12,4 @@
+// CHECK-NEXT: {{.*}}:3:34: note: expanded from macro 'NO_INITIATION'
+// CHECK-NEXT: #define NO_INITIATION(x) int a = x * 2
+// CHECK-NEXT:                                  ^
+
----------------
If this had one more macro expansion, would it be printed or not?

================
Comment at: test/Misc/reduced-diags-macros.cpp:27-29
@@ +26,5 @@
+
+// CHECK: {{.*}}:25:23: error: use of undeclared identifier 'x'
+// CHECK-NEXT: int  p = SWAP_ARGU(3, x);
+// CHECK-NEXT:                       ^
+// CHECK-NEXT: {{.*}}:23:28: note: expanded from macro 'SWAP_ARGU'
----------------
How is this different than the test for 'b' above?  Specifically, why does the error for 'b' print no macros notes while the error for 'x' prints two notes?


http://reviews.llvm.org/D11778





More information about the cfe-commits mailing list