diff options
author | Michael Han <Michael.Han@autodesk.com> | 2012-10-03 01:56:22 +0000 |
---|---|---|
committer | Michael Han <Michael.Han@autodesk.com> | 2012-10-03 01:56:22 +0000 |
commit | 6880f492365cc4fa4c941aa83688635003ee7498 (patch) | |
tree | 75cf9a2e19776577855988ee5cfd7789b5d3fa03 /lib/Parse/ParseDecl.cpp | |
parent | 48314cf6a289bc5a082d8c769c58a38f924c93b7 (diff) |
Improve C++11 attribute parsing.
- General C++11 attributes were previously parsed and ignored. Now they are parsed and stored in AST.
- Add support to parse arguments of attributes that in 'gnu' namespace.
- Differentiate unknown attributes and known attributes that can't be applied to statements when emitting diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 674cd2d22f..e90d0eb9fe 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -154,7 +154,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, Eof.setLocation(Tok.getLocation()); LA->Toks.push_back(Eof); } else { - ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc); + ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc, + 0, AttrNameLoc, AttributeList::AS_GNU); } } else { attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, @@ -173,11 +174,15 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, } -/// Parse the arguments to a parameterized GNU attribute +/// Parse the arguments to a parameterized GNU attribute or +/// a C++11 attribute in "gnu" namespace. void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs, - SourceLocation *EndLoc) { + SourceLocation *EndLoc, + IdentifierInfo *ScopeName, + SourceLocation ScopeLoc, + AttributeList::Syntax Syntax) { assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); @@ -278,9 +283,9 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, SourceLocation RParen = Tok.getLocation(); if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) { AttributeList *attr = - Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc, - ParmName, ParmLoc, ArgExprs.data(), ArgExprs.size(), - AttributeList::AS_GNU); + Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), + ScopeName, ScopeLoc, ParmName, ParmLoc, + ArgExprs.data(), ArgExprs.size(), Syntax); if (BuiltinType && attr->getKind() == AttributeList::AT_IBOutletCollection) Diag(Tok, diag::err_iboutletcollection_builtintype); } @@ -923,7 +928,8 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA, if (HasFunScope) Actions.ActOnReenterFunctionContext(Actions.CurScope, D); - ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc); + ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc, + 0, LA.AttrNameLoc, AttributeList::AS_GNU); if (HasFunScope) { Actions.ActOnExitFunctionContext(); @@ -935,7 +941,8 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA, } else { // If there are multiple decls, then the decl cannot be within the // function scope. - ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc); + ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc, + 0, LA.AttrNameLoc, AttributeList::AS_GNU); } } else { Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName(); |