diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 175 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 36 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 20 | ||||
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 41 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 16 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/AttributeList.cpp | 109 | ||||
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 1 |
13 files changed, 241 insertions, 196 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 6928d0d6d0..976e60f0c9 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -33,7 +33,7 @@ using namespace clang; TypeResult Parser::ParseTypeName(SourceRange *Range, Declarator::TheContext Context) { // Parse the common declaration-specifiers piece. - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); // Parse the abstract-declarator, if present. @@ -126,8 +126,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, if (Tok.is(tok::r_paren)) { // __attribute__(( mode(byte) )) ConsumeParen(); // ignore the right paren loc for now - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, - ParmName, ParmLoc, 0, 0)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + ParmName, ParmLoc, 0, 0); } else if (Tok.is(tok::comma)) { ConsumeToken(); // __attribute__(( format(printf, 1, 2) )) @@ -150,9 +150,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, } if (ArgExprsOk && Tok.is(tok::r_paren)) { ConsumeParen(); // ignore the right paren loc for now - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, - AttrNameLoc, ParmName, ParmLoc, - ArgExprs.take(), ArgExprs.size())); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + ParmName, ParmLoc, ArgExprs.take(), ArgExprs.size()); } } } else { // not an identifier @@ -161,8 +160,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, // parse a possibly empty comma separated list of expressions // __attribute__(( nonnull() )) ConsumeParen(); // ignore the right paren loc for now - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, - 0, SourceLocation(), 0, 0)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + 0, SourceLocation(), 0, 0); break; case tok::kw_char: case tok::kw_wchar_t: @@ -179,9 +178,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, case tok::kw_void: case tok::kw_typeof: { AttributeList *attr - = AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, - 0, SourceLocation(), 0, 0); - attrs.add(attr); + = attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + 0, SourceLocation(), 0, 0); if (attr->getKind() == AttributeList::AT_IBOutletCollection) Diag(Tok, diag::err_iboutletcollection_builtintype); // If it's a builtin type name, eat it and expect a rparen @@ -213,16 +211,16 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, // Match the ')'. if (ArgExprsOk && Tok.is(tok::r_paren)) { ConsumeParen(); // ignore the right paren loc for now - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, - AttrNameLoc, 0, SourceLocation(), - ArgExprs.take(), ArgExprs.size())); + attrs.addNew(AttrName, AttrNameLoc, 0, + AttrNameLoc, 0, SourceLocation(), + ArgExprs.take(), ArgExprs.size()); } break; } } } else { - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, - 0, SourceLocation(), 0, 0)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + 0, SourceLocation(), 0, 0); } } if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) @@ -264,14 +262,14 @@ void Parser::ParseMicrosoftDeclSpec(ParsedAttributes &attrs) { ExprResult ArgExpr(ParseAssignmentExpression()); if (!ArgExpr.isInvalid()) { Expr *ExprList = ArgExpr.take(); - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), &ExprList, 1, true)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, + SourceLocation(), &ExprList, 1, true); } if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) SkipUntil(tok::r_paren, false); } else { - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, - 0, SourceLocation(), 0, 0, true)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + 0, SourceLocation(), 0, 0, true); } } if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) @@ -290,8 +288,8 @@ void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) { if (Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64)) // FIXME: Support these properly! continue; - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), 0, 0, true)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, + SourceLocation(), 0, 0, true); } } @@ -300,8 +298,8 @@ void Parser::ParseBorlandTypeAttributes(ParsedAttributes &attrs) { while (Tok.is(tok::kw___pascal)) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); - attrs.add(AttrFactory.Create(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), 0, 0, true)); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, + SourceLocation(), 0, 0, true); } } @@ -309,9 +307,9 @@ void Parser::ParseOpenCLAttributes(ParsedAttributes &attrs) { // Treat these like attributes while (Tok.is(tok::kw___kernel)) { SourceLocation AttrNameLoc = ConsumeToken(); - attrs.add(AttrFactory.Create(PP.getIdentifierInfo("opencl_kernel_function"), - AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), 0, 0, false)); + attrs.addNew(PP.getIdentifierInfo("opencl_kernel_function"), + AttrNameLoc, 0, AttrNameLoc, 0, + SourceLocation(), 0, 0, false); } } @@ -321,45 +319,45 @@ void Parser::ParseOpenCLQualifiers(DeclSpec &DS) { // OpenCL qualifiers: case tok::kw___private: case tok::kw_private: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("address_space"), Loc, 0)); + PP.getIdentifierInfo("address_space"), Loc, 0); break; case tok::kw___global: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_global)); + PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_global); break; case tok::kw___local: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_local)); + PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_local); break; case tok::kw___constant: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_constant)); + PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_constant); break; case tok::kw___read_only: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_read_only)); + PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_read_only); break; case tok::kw___write_only: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_write_only)); + PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_write_only); break; case tok::kw___read_write: - DS.addAttributes(AttrFactory.CreateIntegerAttribute( + DS.getAttributes().addNewInteger( Actions.getASTContext(), - PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_read_write)); + PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_read_write); break; default: break; } @@ -592,12 +590,12 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, *endLoc = RParenLoc; // Record this attribute - attrs.add(AttrFactory.Create(&Availability, AvailabilityLoc, - 0, SourceLocation(), - Platform, PlatformLoc, - Changes[Introduced], - Changes[Deprecated], - Changes[Obsoleted], false, false)); + attrs.addNew(&Availability, AvailabilityLoc, + 0, SourceLocation(), + Platform, PlatformLoc, + Changes[Introduced], + Changes[Deprecated], + Changes[Obsoleted], false, false); } void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs) { @@ -2175,7 +2173,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, } // Parse all the comma separated declarators. - DeclSpec DS; + DeclSpec DS(AttrFactory); if (!Tok.is(tok::at)) { struct CFieldCallback : FieldCallback { @@ -2236,7 +2234,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc); - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); // If attributes exist after struct contents, parse them. MaybeParseGNUAttributes(attrs); @@ -2286,7 +2284,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, } // If attributes exist after tag, parse them. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseGNUAttributes(attrs); CXXScopeSpec &SS = DS.getTypeSpecScope(); @@ -2526,7 +2524,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) { SourceLocation IdentLoc = ConsumeToken(); // If attributes exist after the enumerator, parse them. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseGNUAttributes(attrs); SourceLocation EqualLoc; @@ -2570,7 +2568,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) { SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc); // If attributes exist after the identifier list, parse them. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseGNUAttributes(attrs); Actions.ActOnEnumBody(StartLoc, LBraceLoc, RBraceLoc, EnumDecl, @@ -2918,7 +2916,7 @@ bool Parser::isConstructorDeclarator() { DeclScopeObj.EnterDeclaratorScope(); // Optionally skip Microsoft attributes. - ParsedAttributes Attrs; + ParsedAttributes Attrs(AttrFactory); MaybeParseMicrosoftAttributes(Attrs); // Check whether the next token(s) are part of a declaration @@ -2946,7 +2944,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, bool CXX0XAttributesAllowed) { if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) { SourceLocation Loc = Tok.getLocation(); - ParsedAttributesWithRange attrs; + ParsedAttributesWithRange attrs(AttrFactory); ParseCXX0XAttributes(attrs); if (CXX0XAttributesAllowed) DS.takeAttributesFrom(attrs); @@ -3092,7 +3090,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, SourceLocation Loc = ConsumeToken(); D.SetRangeEnd(Loc); - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseTypeQualifierListOpt(DS); D.ExtendWithDeclSpec(DS); @@ -3102,7 +3100,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, // Sema will have to catch (syntactically invalid) pointers into global // scope. It has to catch pointers into namespace scope anyway. D.AddTypeInfo(DeclaratorChunk::getMemberPointer(SS,DS.getTypeQualifiers(), - Loc, DS.takeAttributes()), + Loc), + DS.getAttributes(), /* Don't replace range end. */SourceLocation()); return; } @@ -3126,7 +3125,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, if (Kind == tok::star || Kind == tok::caret) { // Is a pointer. - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseTypeQualifierListOpt(DS); D.ExtendWithDeclSpec(DS); @@ -3138,17 +3137,18 @@ void Parser::ParseDeclaratorInternal(Declarator &D, D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc, DS.getConstSpecLoc(), DS.getVolatileSpecLoc(), - DS.getRestrictSpecLoc(), - DS.takeAttributes()), + DS.getRestrictSpecLoc()), + DS.getAttributes(), SourceLocation()); else // Remember that we parsed a Block type, and remember the type-quals. D.AddTypeInfo(DeclaratorChunk::getBlockPointer(DS.getTypeQualifiers(), - Loc, DS.takeAttributes()), + Loc), + DS.getAttributes(), SourceLocation()); } else { // Is a reference - DeclSpec DS; + DeclSpec DS(AttrFactory); // Complain about rvalue references in C++03, but then go on and build // the declarator. @@ -3196,8 +3196,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, // Remember that we parsed a reference type. It doesn't have type-quals. D.AddTypeInfo(DeclaratorChunk::getReference(DS.getTypeQualifiers(), Loc, - DS.takeAttributes(), Kind == tok::amp), + DS.getAttributes(), SourceLocation()); } } @@ -3362,7 +3362,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { if (!isCXXFunctionDeclarator(warnIfAmbiguous)) break; } - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); ParseFunctionDeclarator(ConsumeParen(), D, attrs); } else if (Tok.is(tok::l_square)) { ParseBracketDeclarator(D); @@ -3399,7 +3399,7 @@ void Parser::ParseParenDeclarator(Declarator &D) { // In either case, we need to eat any attributes to be able to determine what // sort of paren this is. // - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); bool RequiresArg = false; if (Tok.is(tok::kw___attribute)) { ParseGNUAttributes(attrs); @@ -3445,13 +3445,12 @@ void Parser::ParseParenDeclarator(Declarator &D) { if (isGrouping) { bool hadGroupingParens = D.hasGroupingParens(); D.setGroupingParens(true); - if (!attrs.empty()) - D.addAttributes(attrs.getList(), SourceLocation()); ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator); // Match the ')'. SourceLocation EndLoc = MatchRHSPunctuation(tok::r_paren, StartLoc); - D.AddTypeInfo(DeclaratorChunk::getParen(StartLoc, EndLoc), EndLoc); + D.AddTypeInfo(DeclaratorChunk::getParen(StartLoc, EndLoc), + attrs, EndLoc); D.setGroupingParens(hadGroupingParens); return; @@ -3518,7 +3517,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, SourceLocation EndLoc = ConsumeParen(); // Eat the closing ')'. // cv-qualifier-seq[opt]. - DeclSpec DS; + DeclSpec DS(AttrFactory); SourceLocation RefQualifierLoc; bool RefQualifierIsLValueRef = true; ExceptionSpecificationType ESpecType = EST_None; @@ -3559,8 +3558,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, // Remember that we parsed a function type, and remember the attributes. // int() -> no prototype, no '...'. - D.AddTypeInfo(DeclaratorChunk::getFunction(attrs, - /*prototype*/getLang().CPlusPlus, + D.AddTypeInfo(DeclaratorChunk::getFunction(/*prototype*/getLang().CPlusPlus, /*variadic*/ false, SourceLocation(), /*arglist*/ 0, 0, @@ -3575,7 +3573,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, NoexceptExpr.get() : 0, LParenLoc, EndLoc, D, TrailingReturnType), - EndLoc); + attrs, EndLoc); return; } @@ -3639,7 +3637,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, // Parse the declaration-specifiers. // Just use the ParsingDeclaration "scope" of the declarator. - DeclSpec DS; + DeclSpec DS(AttrFactory); // Skip any Microsoft attributes before a param. if (getLang().Microsoft && Tok.is(tok::l_square)) @@ -3765,7 +3763,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, // If we have the closing ')', eat it. SourceLocation EndLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); - DeclSpec DS; + DeclSpec DS(AttrFactory); SourceLocation RefQualifierLoc; bool RefQualifierIsLValueRef = true; ExceptionSpecificationType ESpecType = EST_None; @@ -3814,8 +3812,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, PrototypeScope.Exit(); // Remember that we parsed a function type, and remember the attributes. - D.AddTypeInfo(DeclaratorChunk::getFunction(attrs, - /*proto*/true, IsVariadic, + D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/true, IsVariadic, EllipsisLoc, ParamInfo.data(), ParamInfo.size(), DS.getTypeQualifiers(), @@ -3829,7 +3826,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, NoexceptExpr.get() : 0, LParenLoc, EndLoc, D, TrailingReturnType), - EndLoc); + attrs, EndLoc); } /// ParseFunctionDeclaratorIdentifierList - While parsing a function declarator @@ -3898,15 +3895,15 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc, // Remember that we parsed a function type, and remember the attributes. This // function type is always a K&R style function type, which is not varargs and // has no prototype. - D.AddTypeInfo(DeclaratorChunk::getFunction(ParsedAttributes(), - /*proto*/false, /*varargs*/false, + ParsedAttributes attrs(AttrFactory); + D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/false, /*varargs*/false, SourceLocation(), &ParamInfo[0], ParamInfo.size(), /*TypeQuals*/0, true, SourceLocation(), EST_None, SourceLocation(), 0, 0, 0, 0, LParenLoc, RLoc, D), - RLoc); + attrs, RLoc); } /// [C90] direct-declarator '[' constant-expression[opt] ']' @@ -3921,14 +3918,14 @@ void Parser::ParseBracketDeclarator(Declarator &D) { // This code does a fast path to handle some of the most obvious cases. if (Tok.getKind() == tok::r_square) { SourceLocation EndLoc = MatchRHSPunctuation(tok::r_square, StartLoc); - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); // Remember that we parsed the empty array type. ExprResult NumElements; - D.AddTypeInfo(DeclaratorChunk::getArray(0, attrs, false, false, 0, + D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false, 0, StartLoc, EndLoc), - EndLoc); + attrs, EndLoc); return; } else if (Tok.getKind() == tok::numeric_constant && GetLookAheadToken(1).is(tok::r_square)) { @@ -3937,14 +3934,14 @@ void Parser::ParseBracketDeclarator(Declarator &D) { ConsumeToken(); SourceLocation EndLoc = MatchRHSPunctuation(tok::r_square, StartLoc); - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); // Remember that we parsed a array type, and remember its features. - D.AddTypeInfo(DeclaratorChunk::getArray(0, attrs, false, 0, + D.AddTypeInfo(DeclaratorChunk::getArray(0, false, 0, ExprRes.release(), StartLoc, EndLoc), - EndLoc); + attrs, EndLoc); return; } @@ -3955,7 +3952,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) { // If there is a type-qualifier-list, read it now. // Type qualifiers in an array subscript are a C99 feature. - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseTypeQualifierListOpt(DS, false /*no attributes*/); // If we haven't already read 'static', check to see if there is one after the @@ -4003,15 +4000,15 @@ void Parser::ParseBracketDeclarator(Declarator &D) { SourceLocation EndLoc = MatchRHSPunctuation(tok::r_square, StartLoc); - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); // Remember that we parsed a array type, and remember its features. - D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(), attrs, + D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(), StaticLoc.isValid(), isStar, NumElements.release(), StartLoc, EndLoc), - EndLoc); + attrs, EndLoc); } /// [GNU] typeof-specifier: diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index ee8690fc69..4d454313d8 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -69,11 +69,9 @@ Decl *Parser::ParseNamespace(unsigned Context, } // Read label attributes, if present. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); if (Tok.is(tok::kw___attribute)) { attrTok = Tok; - - // FIXME: save these somewhere. ParseGNUAttributes(attrs); } @@ -118,7 +116,7 @@ Decl *Parser::ParseNamespace(unsigned Context, "parsing namespace"); while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) { - ParsedAttributesWithRange attrs; + ParsedAttributesWithRange attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); MaybeParseMicrosoftAttributes(attrs); ParseExternalDeclaration(attrs); @@ -138,9 +136,9 @@ Decl *Parser::ParseNamespace(unsigned Context, /// alias definition. /// Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc, - SourceLocation AliasLoc, - IdentifierInfo *Alias, - SourceLocation &DeclEnd) { + SourceLocation AliasLoc, + IdentifierInfo *Alias, + SourceLocation &DeclEnd) { assert(Tok.is(tok::equal) && "Not equal token"); ConsumeToken(); // eat the '='. @@ -199,7 +197,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) { Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation()); - ParsedAttributesWithRange attrs; + ParsedAttributesWithRange attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); MaybeParseMicrosoftAttributes(attrs); @@ -216,7 +214,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) { SourceLocation LBrace = ConsumeBrace(); while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) { - ParsedAttributesWithRange attrs; + ParsedAttributesWithRange attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); MaybeParseMicrosoftAttributes(attrs); ParseExternalDeclaration(attrs); @@ -380,7 +378,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context, } // Parse (optional) attributes (most likely GNU strong-using extension). - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseGNUAttributes(attrs); // Eat ';'. @@ -590,7 +588,7 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation, EndLocation = IdLoc; // Fake up a Declarator to use with ActOnTypeName. - DeclSpec DS; + DeclSpec DS(AttrFactory); DS.SetRangeStart(IdLoc); DS.SetRangeEnd(EndLocation); DS.getTypeSpecScope() = SS; @@ -677,7 +675,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, SuppressingAccessChecks = true; } - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); // If attributes exist after tag, parse them. if (Tok.is(tok::kw___attribute)) ParseGNUAttributes(attrs); @@ -1488,7 +1486,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // is a bitfield. ColonProtectionRAIIObject X(*this); - ParsedAttributesWithRange attrs; + ParsedAttributesWithRange attrs(AttrFactory); // Optional C++0x attribute-specifier MaybeParseCXX0XAttributes(attrs); MaybeParseMicrosoftAttributes(attrs); @@ -1837,7 +1835,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, } // If attributes exist after class contents, parse them. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); MaybeParseGNUAttributes(attrs); if (TagDecl) @@ -2309,8 +2307,8 @@ void Parser::ParseCXX0XAttributes(ParsedAttributesWithRange &attrs, break; } - attrs.add(AttrFactory.Create(AttrName, AttrLoc, 0, AttrLoc, 0, - SourceLocation(), 0, 0, false, true)); + attrs.addNew(AttrName, AttrLoc, 0, AttrLoc, 0, + SourceLocation(), 0, 0, false, true); AttrParsed = true; break; } @@ -2330,9 +2328,9 @@ void Parser::ParseCXX0XAttributes(ParsedAttributesWithRange &attrs, ExprVector ArgExprs(Actions); ArgExprs.push_back(ArgExpr.release()); - attrs.add(AttrFactory.Create(AttrName, AttrLoc, 0, AttrLoc, - 0, ParamLoc, ArgExprs.take(), 1, - false, true)); + attrs.addNew(AttrName, AttrLoc, 0, AttrLoc, + 0, ParamLoc, ArgExprs.take(), 1, + false, true); AttrParsed = true; break; diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index ecc02ac42e..510e2c2801 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -683,7 +683,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope())) if (Typ.get()->isObjCObjectOrInterfaceType()) { // Fake up a Declarator to use with ActOnTypeName. - DeclSpec DS; + DeclSpec DS(AttrFactory); DS.SetRangeStart(ILoc); DS.SetRangeEnd(ILoc); const char *PrevSpec = 0; @@ -826,7 +826,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, ParsedType Type = getTypeAnnotation(Tok); // Fake up a Declarator to use with ActOnTypeName. - DeclSpec DS; + DeclSpec DS(AttrFactory); DS.SetRangeStart(Tok.getLocation()); DS.SetRangeEnd(Tok.getLastLoc()); @@ -876,7 +876,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, // postfix-expression: simple-type-specifier '(' expression-list[opt] ')' // - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseCXXSimpleTypeSpecifier(DS); if (Tok.isNot(tok::l_paren)) return ExprError(Diag(Tok, diag::err_expected_lparen_after_type) @@ -1634,7 +1634,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { Diag(Tok, diag::ext_gnu_statement_expr); - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); StmtResult Stmt(ParseCompoundStatement(attrs, true)); ExprType = CompoundStmt; @@ -1850,7 +1850,7 @@ void Parser::ParseBlockId() { } // Parse the specifier-qualifier-list piece. - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); // Parse the block-declarator. @@ -1858,7 +1858,7 @@ void Parser::ParseBlockId() { ParseDeclarator(DeclaratorInfo); // We do this for: ^ __attribute__((noreturn)) {, as DS has the attributes. - DeclaratorInfo.addAttributes(DS.takeAttributes()); + DeclaratorInfo.takeAttributes(DS.getAttributes(), SourceLocation()); MaybeParseGNUAttributes(DeclaratorInfo); @@ -1894,7 +1894,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { Actions.ActOnBlockStart(CaretLoc, getCurScope()); // Parse the return type if present. - DeclSpec DS; + DeclSpec DS(AttrFactory); Declarator ParamInfo(DS, Declarator::BlockLiteralContext); // FIXME: Since the return type isn't actually parsed, it can't be used to // fill ParamInfo with an initial valid range, so do it manually. @@ -1926,8 +1926,8 @@ ExprResult Parser::ParseBlockLiteralExpression() { ParseBlockId(); } else { // Otherwise, pretend we saw (void). - ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(ParsedAttributes(), - true, false, + ParsedAttributes attrs(AttrFactory); + ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(true, false, SourceLocation(), 0, 0, 0, true, SourceLocation(), @@ -1936,7 +1936,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { 0, 0, 0, 0, CaretLoc, CaretLoc, ParamInfo), - CaretLoc); + attrs, CaretLoc); MaybeParseGNUAttributes(ParamInfo); diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 422b915b68..1f41f5dbc5 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -800,7 +800,7 @@ bool Parser::ParseCXXCondition(ExprResult &ExprOut, } // type-specifier-seq - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); // declarator @@ -1391,7 +1391,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, // ptr-operator conversion-declarator[opt] // Parse the type-specifier-seq. - DeclSpec DS; + DeclSpec DS(AttrFactory); if (ParseCXXTypeSpecifierSeq(DS)) // FIXME: ObjectType? return true; @@ -1644,7 +1644,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) { SourceLocation PlacementLParen, PlacementRParen; SourceRange TypeIdParens; - DeclSpec DS; + DeclSpec DS(AttrFactory); Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); if (Tok.is(tok::l_paren)) { // If it turns out to be a placement, we change the type location. @@ -1746,10 +1746,12 @@ void Parser::ParseDirectNewDeclarator(Declarator &D) { first = false; SourceLocation RLoc = MatchRHSPunctuation(tok::r_square, LLoc); - D.AddTypeInfo(DeclaratorChunk::getArray(0, ParsedAttributes(), + + ParsedAttributes attrs(AttrFactory); + D.AddTypeInfo(DeclaratorChunk::getArray(0, /*static=*/false, /*star=*/false, Size.release(), LLoc, RLoc), - RLoc); + attrs, RLoc); if (RLoc.isInvalid()) return; diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index dab63548a4..14f2bbedbe 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -41,11 +41,11 @@ Decl *Parser::ParseObjCAtDirectives() { case tok::objc_class: return ParseObjCAtClassDeclaration(AtLoc); case tok::objc_interface: { - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); return ParseObjCAtInterfaceDeclaration(AtLoc, attrs); } case tok::objc_protocol: { - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); return ParseObjCAtProtocolDeclaration(AtLoc, attrs); } case tok::objc_implementation: @@ -371,7 +371,7 @@ void Parser::ParseObjCInterfaceDeclList(Decl *interfaceDecl, // FIXME: as the name implies, this rule allows function definitions. // We could pass a flag or check for functions during semantic analysis. - ParsedAttributes attrs; + ParsedAttributes attrs(AttrFactory); allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(attrs)); continue; } @@ -439,7 +439,7 @@ void Parser::ParseObjCInterfaceDeclList(Decl *interfaceDecl, OCDS, AtLoc, MethodImplKind); // Parse all the comma separated declarators. - DeclSpec DS; + DeclSpec DS(AttrFactory); ParseStructDeclaration(DS, Callback); ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list, "", @@ -843,9 +843,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ReturnType = ParseObjCTypeName(DSRet, OTN_ResultType); // If attributes exist before the method, parse them. - ParsedAttributes attrs; + ParsedAttributes methodAttrs(AttrFactory); if (getLang().ObjC2) - MaybeParseGNUAttributes(attrs); + MaybeParseGNUAttributes(methodAttrs); if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus, @@ -870,7 +870,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, if (Tok.isNot(tok::colon)) { // If attributes exist after the method, parse them. if (getLang().ObjC2) - MaybeParseGNUAttributes(attrs); |