]> granicus.if.org Git - clang/commitdiff
Switch to a more natural formatting of the macro name printing.
authorChandler Carruth <chandlerc@gmail.com>
Mon, 24 Oct 2011 18:51:08 +0000 (18:51 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 24 Oct 2011 18:51:08 +0000 (18:51 +0000)
Suggested by John McCall.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142836 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/TextDiagnostic.cpp
test/Misc/caret-diags-macros.c
test/Misc/include-stack-for-note-flag.cpp
test/Misc/macro-backtrace.c

index 8b901ae310ee9fc42f75b16dba3f9c1f73aace6b..425bc26fccfcf04eb07944cabcf4959abd624e95 100644 (file)
@@ -760,8 +760,8 @@ void TextDiagnostic::emitMacroExpansionsAndCarets(
 
   llvm::SmallString<100> MessageStorage;
   llvm::raw_svector_ostream Message(MessageStorage);
-  Message << "expanded from macro"
-          << getImmediateMacroName(MacroLoc, SM, LangOpts);
+  Message << "expanded from macro '"
+          << getImmediateMacroName(MacroLoc, SM, LangOpts) << "'";
   emitDiagnostic(SM.getSpellingLoc(Loc), DiagnosticsEngine::Note,
                  Message.str(),
                  Ranges, ArrayRef<FixItHint>());
index 38a1e9946b07c400339586c61d778b98127be7ee..de1ee76ed1bee73bcd9728ed2f5305b222e2b240 100644 (file)
@@ -6,8 +6,8 @@ void foo() {
   M1(
     M2);
   // CHECK: :7:{{[0-9]+}}: warning: expression result unused
-  // CHECK: :4:{{[0-9]+}}: note: expanded from macro: M2
-  // CHECK: :3:{{[0-9]+}}: note: expanded from macro: M1
+  // CHECK: :4:{{[0-9]+}}: note: expanded from macro 'M2'
+  // CHECK: :3:{{[0-9]+}}: note: expanded from macro 'M1'
 }
 
 #define A 1
@@ -16,9 +16,9 @@ void foo() {
 void bar() {
   C;
   // CHECK: :17:3: warning: expression result unused
-  // CHECK: :15:11: note: expanded from macro: C
-  // CHECK: :14:11: note: expanded from macro: B
-  // CHECK: :13:11: note: expanded from macro: A
+  // CHECK: :15:11: note: expanded from macro 'C'
+  // CHECK: :14:11: note: expanded from macro 'B'
+  // CHECK: :13:11: note: expanded from macro 'A'
 }
 
 // rdar://7597492
@@ -46,28 +46,28 @@ void test() {
   // its easy to FileCheck.
   // CHECK-NEXT: macro_args3(1);
   // CHECK-NEXT: ~~~~~~~~~~~~^~
-  // CHECK: {{.*}}:36:36: note: expanded from macro: macro_args3
-  // CHECK: {{.*}}:35:36: note: expanded from macro: macro_args2
-  // CHECK: {{.*}}:34:24: note: expanded from macro: macro_args1
+  // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3'
+  // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+  // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
 
   macro_many_args3(
     1,
     2,
     3);
   // CHECK: {{.*}}:55:5: warning: expression result unused
-  // CHECK: {{.*}}:40:55: note: expanded from macro: macro_many_args3
-  // CHECK: {{.*}}:39:55: note: expanded from macro: macro_many_args2
-  // CHECK: {{.*}}:38:35: note: expanded from macro: macro_many_args1
+  // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+  // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+  // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
 
   macro_many_args3(
     1,
     M2,
     3);
   // CHECK: {{.*}}:64:5: warning: expression result unused
-  // CHECK: {{.*}}:4:12: note: expanded from macro: M2
-  // CHECK: {{.*}}:40:55: note: expanded from macro: macro_many_args3
-  // CHECK: {{.*}}:39:55: note: expanded from macro: macro_many_args2
-  // CHECK: {{.*}}:38:35: note: expanded from macro: macro_many_args1
+  // CHECK: {{.*}}:4:12: note: expanded from macro 'M2'
+  // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+  // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+  // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
 
   macro_many_args3(
     1,
@@ -78,11 +78,11 @@ void test() {
   // arguments.
   // CHECK-NEXT: macro_args2(2),
   // CHECK-NEXT: ~~~~~~~~~~~~^~~
-  // CHECK: {{.*}}:35:36: note: expanded from macro: macro_args2
-  // CHECK: {{.*}}:34:24: note: expanded from macro: macro_args1
-  // CHECK: {{.*}}:40:55: note: expanded from macro: macro_many_args3
-  // CHECK: {{.*}}:39:55: note: expanded from macro: macro_many_args2
-  // CHECK: {{.*}}:38:35: note: expanded from macro: macro_many_args1
+  // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+  // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
+  // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+  // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+  // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
 }
 
 #define variadic_args1(x, y, ...) y
@@ -94,9 +94,9 @@ void test2() {
   // CHECK: {{.*}}:93:21: warning: expression result unused
   // CHECK-NEXT: variadic_args3(1, 2, 3, 4);
   // CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~
-  // CHECK: {{.*}}:90:53: note: expanded from macro: variadic_args3
-  // CHECK: {{.*}}:89:50: note: expanded from macro: variadic_args2
-  // CHECK: {{.*}}:88:35: note: expanded from macro: variadic_args1
+  // CHECK: {{.*}}:90:53: note: expanded from macro 'variadic_args3'
+  // CHECK: {{.*}}:89:50: note: expanded from macro 'variadic_args2'
+  // CHECK: {{.*}}:88:35: note: expanded from macro 'variadic_args1'
 }
 
 #define variadic_pasting_args1(x, y, z) y
@@ -108,13 +108,13 @@ void test2() {
 void test3() {
   variadic_pasting_args3(1, 2, 3, 4);
   // CHECK: {{.*}}:109:32: warning: expression result unused
-  // CHECK: {{.*}}:105:72: note: expanded from macro: variadic_pasting_args3
-  // CHECK: {{.*}}:103:68: note: expanded from macro: variadic_pasting_args2
-  // CHECK: {{.*}}:102:41: note: expanded from macro: variadic_pasting_args1
+  // CHECK: {{.*}}:105:72: note: expanded from macro 'variadic_pasting_args3'
+  // CHECK: {{.*}}:103:68: note: expanded from macro 'variadic_pasting_args2'
+  // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
 
   variadic_pasting_args3a(1, 2, 3, 4);
   // CHECK: {{.*}}:115:30: warning: expression result unused
-  // CHECK: {{.*}}:106:71: note: expanded from macro: variadic_pasting_args3a
-  // CHECK: {{.*}}:104:70: note: expanded from macro: variadic_pasting_args2a
-  // CHECK: {{.*}}:102:41: note: expanded from macro: variadic_pasting_args1
+  // CHECK: {{.*}}:106:71: note: expanded from macro 'variadic_pasting_args3a'
+  // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a'
+  // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
 }
index 7058cb0774f9f5bb74730acb6d2f935f7adba066..b41284fd607e75f3b1f50ab190e90ac65473e56e 100644 (file)
@@ -18,11 +18,11 @@ bool macro(int x, int y) {
 // STACK: note: candidate function not viable
 // STACK: error: comparison between pointer and integer
 // STACK:  In file included from
-// STACK: note: expanded from macro:
+// STACK: note: expanded from macro
 
 // STACKLESS: error: no matching function for call to 'foo'
 // STACKLESS-NOT:  In file included from
 // STACKLESS: note: candidate function not viable
 // STACKLESS: error: comparison between pointer and integer
 // STACKLESS-NOT:  In file included from
-// STACKLESS: note: expanded from macro:
+// STACKLESS: note: expanded from macro
index 71244dc69b0c7aa91b4c01fad6d8366bedd4d86f..7aeaf21a13d53048542f3f7d4e79182300113069 100644 (file)
@@ -20,28 +20,28 @@ void f(int *ip, float *fp) {
   // RUN:   | FileCheck %s -check-prefix=CHECK-LIMIT
   // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
   // CHECK-LIMIT: if (M12(ip, fp)) { }
-  // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro: M12
+  // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
   // CHECK-LIMIT: #define M12(A, B) M11(A, B)
-  // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro: M11
+  // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
   // CHECK-LIMIT: #define M11(A, B) M10(A, B)
   // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
-  // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro: M3
+  // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
   // CHECK-LIMIT: #define M3(A, B) M2(A, B)
-  // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro: M2
+  // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
   // CHECK-LIMIT: #define M2(A, B) M1(A, B)
-  // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro: M1
+  // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
   // CHECK-LIMIT: #define M1(A, B) ((A) < (B))
 
   // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \
   // RUN:   | FileCheck %s -check-prefix=CHECK-NO-CARETS
   // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro: M12
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro: M11
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro: M10
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro 'M10'
   // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro: M3
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro: M2
-  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro: M1
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
+  // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
 
   // Check that the expansion notes respect the same formatting options as
   // other diagnostics.