diff options
author | John McCall <rjmccall@apple.com> | 2010-12-24 02:08:15 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-12-24 02:08:15 +0000 |
commit | 7f040a9d817cd1c72b565e92abff473510bf9e1d (patch) | |
tree | 4f168629b32435bb24409a5f6ee03a82ede2de23 /lib/Parse/ParseExpr.cpp | |
parent | 6e4e17de3df88ead7eaf51b3503a6be1718438c0 (diff) |
Refactor how we collect attributes during parsing, and add slots for attributes
on array and function declarators. This is pretty far from complete, and I'll
revisit it later if someone doesn't beat me to it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 47b60b5f47..92bbbd7bf9 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -1522,7 +1522,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { Diag(Tok, diag::ext_gnu_statement_expr); - StmtResult Stmt(ParseCompoundStatement(0, true)); + ParsedAttributes attrs; + StmtResult Stmt(ParseCompoundStatement(attrs, true)); ExprType = CompoundStmt; // If the substmt parsed correctly, build the AST node. @@ -1741,14 +1742,9 @@ void Parser::ParseBlockId() { ParseDeclarator(DeclaratorInfo); // We do this for: ^ __attribute__((noreturn)) {, as DS has the attributes. - DeclaratorInfo.AddAttributes(DS.TakeAttributes(), - SourceLocation()); + DeclaratorInfo.addAttributes(DS.takeAttributes()); - if (Tok.is(tok::kw___attribute)) { - SourceLocation Loc; - AttributeList *AttrList = ParseGNUAttributes(&Loc); - DeclaratorInfo.AddAttributes(AttrList, Loc); - } + MaybeParseGNUAttributes(DeclaratorInfo); // Inform sema that we are starting a block. Actions.ActOnBlockArguments(DeclaratorInfo, getCurScope()); @@ -1806,11 +1802,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { return ExprError(); } - if (Tok.is(tok::kw___attribute)) { - SourceLocation Loc; - AttributeList *AttrList = ParseGNUAttributes(&Loc); - ParamInfo.AddAttributes(AttrList, Loc); - } + MaybeParseGNUAttributes(ParamInfo); // Inform sema that we are starting a block. Actions.ActOnBlockArguments(ParamInfo, getCurScope()); @@ -1818,7 +1810,8 @@ ExprResult Parser::ParseBlockLiteralExpression() { ParseBlockId(); } else { // Otherwise, pretend we saw (void). - ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(true, false, + ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(ParsedAttributes(), + true, false, SourceLocation(), 0, 0, 0, false, SourceLocation(), @@ -1827,11 +1820,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { ParamInfo), CaretLoc); - if (Tok.is(tok::kw___attribute)) { - SourceLocation Loc; - AttributeList *AttrList = ParseGNUAttributes(&Loc); - ParamInfo.AddAttributes(AttrList, Loc); - } + MaybeParseGNUAttributes(ParamInfo); // Inform sema that we are starting a block. Actions.ActOnBlockArguments(ParamInfo, getCurScope()); |