[PATCH] Better macro error messages involving initializer lists
Richard Smith
richard at metafoo.co.uk
Fri Jul 19 15:17:57 PDT 2013
================
Comment at: lib/Lex/PPMacroExpansion.cpp:482
@@ +481,3 @@
+
+ // If the argument starts with a brace,
+ if (FoundSeparatorToken && ArgStartIterator->is(tok::l_brace)) {
----------------
Incomplete comment.
================
Comment at: lib/Lex/PPMacroExpansion.cpp:443
@@ +442,3 @@
+ unsigned Braces = 0;
+ unsigned Parens = 0;
+
----------------
This variable seems to be unused.
================
Comment at: lib/Lex/PPMacroExpansion.cpp:693-696
@@ +692,6 @@
+ diag::note_init_list_at_beginning_of_macro_argument);
+ for (SmallVector<SourceRange, 4>::iterator
+ Range = InitLists.begin(), RangeEnd = InitLists.end();
+ Range != RangeEnd; ++Range)
+ DB << *Range;
+ }
----------------
It looks like DiagnosticBuilder will assert if given more than 10 ranges. Maybe guard this with DB.hasMaxRanges()?
================
Comment at: lib/Lex/PPMacroExpansion.cpp:704-709
@@ +703,8 @@
+ DiagnosticBuilder DB = Diag(MacroName, diag::note_suggest_parens_for_macro);
+ for (SmallVector<SourceRange, 4>::iterator
+ ParenLocation = ParenHints.begin(), ParenEnd = ParenHints.end();
+ ParenLocation != ParenEnd; ++ParenLocation) {
+ DB << FixItHint::CreateInsertion(ParenLocation->getBegin(), "(")
+ << FixItHint::CreateInsertion(ParenLocation->getEnd(), ")");
+ }
+ ArgTokens.swap(FixedArgTokens);
----------------
Likewise w/fixits.
================
Comment at: test/Preprocessor/macro_with_initializer_list.cpp:140
@@ +139,3 @@
+// make it no longer an initializer list.
+// TODO: Add note for initializer list at beginning of macro argument.
+void test() {
----------------
This is done, right?
http://llvm-reviews.chandlerc.com/D986
More information about the cfe-commits
mailing list