+static SourceLocation getDiagLoc(Declarator &D, SourceLocation Loc) {

This is a very generic name for quite a specific behavior.
'getMissingDeclaratorIdLoc' or similar?


+    if (Tok.is(tok::l_square)) {

Maybe factor this out into a separate function.
'ParseMisplacedBracketDeclarator' or similar?


+      SavedBracketInfo SavedInfo;
+      SourceLocation Loc = Tok.getLocation();
+
+      while (Tok.is(tok::l_square)) {
+        ParseBracketDeclarator(D, &SavedInfo);

Is it possible to handle this by parsing into a new Declarator here (and
copying its chunks into D once we're done), instead of introducing a
separate SavedBracketInfo code path into ParseBracketDeclarator?


+      // Something went wrong parsing the parens, in which case,
[...]
+      // Adding back the paren info to the end of the Declarator.

Please say "brackets" rather than "parens"; we're pretty consistent about
using "parens" to mean () and not [].


+      SavedInfo->push_back(
+          {DeclaratorChunk::getArray(0, false, false, 0,
T.getOpenLocation(),

MSVC doesn't support this syntax.


On Tue, May 13, 2014 at 3:44 PM, Richard Trieu <[email protected]> wrote:

> Switching to a recursive solution for misplaced brackets.  Upon seeing a
> bracket before the identifier, parse the brackets and store the info.  Call
> ParseDirectDeclarator again to continue parsing.  After that returns,
> attach the bracket info the Declarator and emit the misplaced bracket error
> with fix-it hint to move the brackets after the identifier.  Additionally,
> store the location of the beginning of the brackets so that other error
> messages may point to a better location.
>
> http://reviews.llvm.org/D2712
>
> Files:
>   include/clang/Basic/DiagnosticParseKinds.td
>   include/clang/Parse/Parser.h
>   lib/Parse/ParseDecl.cpp
>   test/Parser/brackets.c
>   test/Parser/brackets.cpp
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to