[cfe-commits] r148930 - in /cfe/trunk: lib/Frontend/DiagnosticRenderer.cpp test/Misc/diag-macro-backtrace.c

Ted Kremenek kremenek at apple.com
Tue Jan 24 22:07:16 PST 2012


Author: kremenek
Date: Wed Jan 25 00:07:15 2012
New Revision: 148930

URL: http://llvm.org/viewvc/llvm-project?rev=148930&view=rev
Log:
Fix -fmacro-backtrace-limit=0 to show the entire macro backtrace.

Added:
    cfe/trunk/test/Misc/diag-macro-backtrace.c
Modified:
    cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp

Modified: cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp?rev=148930&r1=148929&r2=148930&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp Wed Jan 25 00:07:15 2012
@@ -260,7 +260,8 @@
   Loc = getImmediateMacroCalleeLoc(SM, Loc);
   
   unsigned MacroSkipStart = 0, MacroSkipEnd = 0;
-  if (MacroDepth > DiagOpts.MacroBacktraceLimit) {
+  if (MacroDepth > DiagOpts.MacroBacktraceLimit &&
+      DiagOpts.MacroBacktraceLimit != 0) {
     MacroSkipStart = DiagOpts.MacroBacktraceLimit / 2 +
     DiagOpts.MacroBacktraceLimit % 2;
     MacroSkipEnd = MacroDepth - DiagOpts.MacroBacktraceLimit / 2;

Added: cfe/trunk/test/Misc/diag-macro-backtrace.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-macro-backtrace.c?rev=148930&view=auto
==============================================================================
--- cfe/trunk/test/Misc/diag-macro-backtrace.c (added)
+++ cfe/trunk/test/Misc/diag-macro-backtrace.c Wed Jan 25 00:07:15 2012
@@ -0,0 +1,53 @@
+// RUN: %clang -fsyntax-only -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s
+
+#define FOO 1+"hi" 
+#define BAR FOO
+#define BAZ BAR
+#define QUZ BAZ
+#define TAZ QUZ
+#define ABA TAZ
+#define BAB ABA
+#define ZAZ BAB
+#define WAZ ZAZ
+#define DROOL WAZ
+#define FOOL DROOL
+
+FOOL
+
+// CHECK: :15:1: error: expected identifier or '('
+// CHECK: FOOL
+// CHECK: ^
+// CHECK: :13:14: note: expanded from macro 'FOOL'
+// CHECK: #define FOOL DROOL
+// CHECK:              ^
+// CHECK: :12:15: note: expanded from macro 'DROOL'
+// CHECK: #define DROOL WAZ
+// CHECK:               ^
+// CHECK: :11:13: note: expanded from macro 'WAZ'
+// CHECK: #define WAZ ZAZ
+// CHECK:             ^
+// CHECK: :10:13: note: expanded from macro 'ZAZ'
+// CHECK: #define ZAZ BAB
+// CHECK:             ^
+// CHECK: :9:13: note: expanded from macro 'BAB'
+// CHECK: #define BAB ABA
+// CHECK:             ^
+// CHECK: :8:13: note: expanded from macro 'ABA'
+// CHECK: #define ABA TAZ
+// CHECK:             ^
+// CHECK: :7:13: note: expanded from macro 'TAZ'
+// CHECK: #define TAZ QUZ
+// CHECK:             ^
+// CHECK: :6:13: note: expanded from macro 'QUZ'
+// CHECK: #define QUZ BAZ
+// CHECK:             ^
+// CHECK: :5:13: note: expanded from macro 'BAZ'
+// CHECK: #define BAZ BAR
+// CHECK:             ^
+// CHECK: :4:13: note: expanded from macro 'BAR'
+// CHECK: #define BAR FOO
+// CHECK:             ^
+// CHECK: :3:13: note: expanded from macro 'FOO'
+// CHECK: #define FOO 1+"hi" 
+// CHECK:             ^
+// CHECK: 1 error generated.





More information about the cfe-commits mailing list