Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion...
Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion generates untraceable warnings The "instantiated from" messages coming from the caret diagnostics system are basically walking the macro expansion tree, emitting each level as it goes. However, it was skipping certain leaves in the tree by skipping up the entire instantiation arm every time it went up one spelling arm. This caused it to miss some things. For example, in this testcase: #define M1(x) x #define M2 1; void foo() { M1(M2) } we now print: /Users/sabre/Desktop/clang-unused-value-macro.c:6:2: warning: expression result unused M1(M2) ^~~~~~ /Users/sabre/Desktop/clang-unused-value-macro.c:6:5: note: instantiated from: M1(M2) ^~ /Users/sabre/Desktop/clang-unused-value-macro.c:3:12: note: instantiated from: #define M2 1; ^ Previously we didn't print the last line, so we never emitted the caret pointing to the 1! Incidentally, the spaces between the lines is really noisy, I think we should reconsider this heuristic (which adds them when the printed code starts too close to the start of the line). The regression test can't use -verify, because -verify doesn't catch notes for macro instantiation history. llvm-svn: 71025
Loading
Please register or sign in to comment