11aaddf2030a66762a97dc27265948694a1ecc546Chandler Carruth// Tests for macro expansion backtraces. The RUN and CHECK lines are grouped 21aaddf2030a66762a97dc27265948694a1ecc546Chandler Carruth// below the test code to reduce noise when updating them. 36c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor 46c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M1(A, B) ((A) < (B)) 56c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M2(A, B) M1(A, B) 66c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M3(A, B) M2(A, B) 76c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M4(A, B) M3(A, B) 86c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M5(A, B) M4(A, B) 96c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M6(A, B) M5(A, B) 106c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M7(A, B) M6(A, B) 116c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M8(A, B) M7(A, B) 126c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M9(A, B) M8(A, B) 136c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M10(A, B) M9(A, B) 146c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M11(A, B) M10(A, B) 156c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor#define M12(A, B) M11(A, B) 166c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor 176c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregorvoid f(int *ip, float *fp) { 181aaddf2030a66762a97dc27265948694a1ecc546Chandler Carruth if (M12(ip, fp)) { } 19e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s 2>&1 \ 20e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // RUN: | FileCheck %s -check-prefix=CHECK-LIMIT 21e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') 22e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: if (M12(ip, fp)) { } 23fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro 'M12' 24e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: #define M12(A, B) M11(A, B) 25fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro 'M11' 26e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: #define M11(A, B) M10(A, B) 27e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) 28fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro 'M3' 29e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: #define M3(A, B) M2(A, B) 30fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro 'M2' 31e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: #define M2(A, B) M1(A, B) 32fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro 'M1' 33e0376c03b7f7af8053b21c9d2f0c3b28f75e90b6Chandler Carruth // CHECK-LIMIT: #define M1(A, B) ((A) < (B)) 344ba55659982bf45eedc9d32851815e5c4b6d8460Chandler Carruth 354ba55659982bf45eedc9d32851815e5c4b6d8460Chandler Carruth // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \ 364ba55659982bf45eedc9d32851815e5c4b6d8460Chandler Carruth // RUN: | FileCheck %s -check-prefix=CHECK-NO-CARETS 374ba55659982bf45eedc9d32851815e5c4b6d8460Chandler Carruth // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') 38fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro 'M12' 39fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro 'M11' 40fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro 'M10' 414ba55659982bf45eedc9d32851815e5c4b6d8460Chandler Carruth // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) 42fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro 'M3' 43fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro 'M2' 44fd40ad41764a319d488fe30d86a9cb88c953b9a9Chandler Carruth // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro 'M1' 454c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth 464c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // Check that the expansion notes respect the same formatting options as 474c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // other diagnostics. 484c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-format vi %s 2>&1 \ 494c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // RUN: | FileCheck %s -check-prefix=CHECK-NOTE-FORMAT 504c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +18:7: warning: 514c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +15:19: note: 524c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +14:19: note: 534c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: note: 544c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +6:18: note: 554c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +5:18: note: 564c3fd511a6a83a0d729a40d659f1fa6bedbebd07Chandler Carruth // CHECK-NOTE-FORMAT: macro-backtrace.c +4:23: note: 576c1cb9916e9988dcdd65b9266dbe24afd173427aDouglas Gregor} 58