diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 85bf89ab8b..513f3287b1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -256,7 +256,7 @@ static bool AllowOverloadingOfFunction(Decl *PrevDecl, ASTContext &Context) { if (isa<OverloadedFunctionDecl>(PrevDecl)) return true; - return PrevDecl->getAttr<OverloadableAttr>(Context) != 0; + return PrevDecl->getAttr<OverloadableAttr>() != 0; } /// Add this decl to the scope shadowed decl chains. @@ -612,8 +612,8 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { /// DeclhasAttr - returns true if decl Declaration already has the target /// attribute. static bool -DeclHasAttr(ASTContext &Context, const Decl *decl, const Attr *target) { - for (const Attr *attr = decl->getAttrs(Context); attr; attr = attr->getNext()) +DeclHasAttr(const Decl *decl, const Attr *target) { + for (const Attr *attr = decl->getAttrs(); attr; attr = attr->getNext()) if (attr->getKind() == target->getKind()) return true; @@ -622,11 +622,11 @@ DeclHasAttr(ASTContext &Context, const Decl *decl, const Attr *target) { /// MergeAttributes - append attributes from the Old decl to the New one. static void MergeAttributes(Decl *New, Decl *Old, ASTContext &C) { - for (const Attr *attr = Old->getAttrs(C); attr; attr = attr->getNext()) { - if (!DeclHasAttr(C, New, attr) && attr->isMerged()) { + for (const Attr *attr = Old->getAttrs(); attr; attr = attr->getNext()) { + if (!DeclHasAttr(New, attr) && attr->isMerged()) { Attr *NewAttr = attr->clone(C); NewAttr->setInherited(true); - New->addAttr(C, NewAttr); + New->addAttr(NewAttr); } } } @@ -1851,8 +1851,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (Expr *E = (Expr*) D.getAsmLabel()) { // The parser guarantees this is a string. StringLiteral *SE = cast<StringLiteral>(E); - NewVD->addAttr(Context, - ::new (Context) AsmLabelAttr(std::string(SE->getStrData(), + NewVD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(), SE->getByteLength()))); } @@ -1931,11 +1930,11 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl, } if (NewVD->hasLocalStorage() && T.isObjCGCWeak() - && !NewVD->hasAttr<BlocksAttr>(Context)) + && !NewVD->hasAttr<BlocksAttr>()) Diag(NewVD->getLocation(), diag::warn_attribute_weak_on_local); bool isVM = T->isVariablyModifiedType(); - if (isVM || NewVD->hasAttr<CleanupAttr>(Context)) + if (isVM || NewVD->hasAttr<CleanupAttr>()) CurFunctionNeedsScopeChecking = true; if ((isVM && NewVD->hasLinkage()) || @@ -1990,12 +1989,12 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl, return NewVD->setInvalidDecl(); } - if (!NewVD->hasLocalStorage() && NewVD->hasAttr<BlocksAttr>(Context)) { + if (!NewVD->hasLocalStorage() && NewVD->hasAttr<BlocksAttr>()) { Diag(NewVD->getLocation(), diag::err_block_on_nonlocal); return NewVD->setInvalidDecl(); } - if (isVM && NewVD->hasAttr<BlocksAttr>(Context)) { + if (isVM && NewVD->hasAttr<BlocksAttr>()) { Diag(NewVD->getLocation(), diag::err_block_on_vm); return NewVD->setInvalidDecl(); } @@ -2251,8 +2250,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (Expr *E = (Expr*) D.getAsmLabel()) { // The parser guarantees this is a string. StringLiteral *SE = cast<StringLiteral>(E); - NewFD->addAttr(Context, - ::new (Context) AsmLabelAttr(std::string(SE->getStrData(), + NewFD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(), SE->getByteLength()))); } @@ -2371,7 +2369,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, ProcessDeclAttributes(S, NewFD, D); AddKnownFunctionAttributes(NewFD); - if (OverloadableAttrRequired && !NewFD->getAttr<OverloadableAttr>(Context)) { + if (OverloadableAttrRequired && !NewFD->getAttr<OverloadableAttr>()) { // If a function name is overloadable in C, then every function // with that name must be marked "overloadable". Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing) @@ -2379,7 +2377,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (PrevDecl) Diag(PrevDecl->getLocation(), diag::note_attribute_overloadable_prev_overload); - NewFD->addAttr(Context, ::new (Context) OverloadableAttr()); + NewFD->addAttr(::new (Context) OverloadableAttr()); } // If this is a locally-scoped extern C function, update the @@ -2998,7 +2996,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { ProcessDeclAttributes(S, New, D); - if (New->hasAttr<BlocksAttr>(Context)) { + if (New->hasAttr<BlocksAttr>()) { Diag(New->getLocation(), diag::err_block_on_nonlocal); } return DeclPtrTy::make(New); @@ -3128,10 +3126,10 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { // Checking attributes of current function definition // dllimport attribute. - if (FD->getAttr<DLLImportAttr>(Context) && - (!FD->getAttr<DLLExportAttr>(Context))) { + if (FD->getAttr<DLLImportAttr>() && + (!FD->getAttr<DLLExportAttr>())) { // dllimport attribute cannot be applied to definition. - if (!(FD->getAttr<DLLImportAttr>(Context))->isInherited()) { + if (!(FD->getAttr<DLLImportAttr>())->isInherited()) { Diag(FD->getLocation(), diag::err_attribute_can_be_applied_only_to_symbol_declaration) << "dllimport"; @@ -3313,9 +3311,8 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { unsigned FormatIdx; bool HasVAListArg; if (Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) { - if (!FD->getAttr<FormatAttr>(Context)) - FD->addAttr(Context, - ::new (Context) FormatAttr("printf", FormatIdx + 1, + if (!FD->getAttr<FormatAttr>()) + FD->addAttr(::new (Context) FormatAttr("printf", FormatIdx + 1, HasVAListArg ? 0 : FormatIdx + 2)); } @@ -3324,8 +3321,8 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { // IRgen to use LLVM intrinsics for such functions. if (!getLangOptions().MathErrno && Context.BuiltinInfo.isConstWithoutErrno(BuiltinID)) { - if (!FD->getAttr<ConstAttr>(Context)) - FD->addAttr(Context, ::new (Context) ConstAttr()); + if (!FD->getAttr<ConstAttr>()) + FD->addAttr(::new (Context) ConstAttr()); } } @@ -3343,17 +3340,15 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { return; if (Name->isStr("NSLog") || Name->isStr("NSLogv")) { - if (const FormatAttr *Format = FD->getAttr<FormatAttr>(Context)) { + if (const FormatAttr *Format = FD->getAttr<FormatAttr>()) { // FIXME: We known better than our headers. const_cast<FormatAttr *>(Format)->setType("printf"); } else - FD->addAttr(Context, - ::new (Context) FormatAttr("printf", 1, + FD->addAttr(::new (Context) FormatAttr("printf", 1, Name->isStr("NSLogv") ? 0 : 2)); } else if (Name->isStr("asprintf") || Name->isStr("vasprintf")) { - if (!FD->getAttr<FormatAttr>(Context)) - FD->addAttr(Context, - ::new (Context) FormatAttr("printf", 2, + if (!FD->getAttr<FormatAttr>()) + FD->addAttr(::new (Context) FormatAttr("printf", 2, Name->isStr("vasprintf") ? 0 : 3)); } } @@ -3709,7 +3704,7 @@ CreateNewDecl: // the #pragma tokens are effectively skipped over during the // parsing of the struct). if (unsigned Alignment = getPragmaPackAlignment()) - New->addAttr(Context, ::new (Context) PackedAttr(Alignment * 8)); + New->addAttr(::new (Context) PackedAttr(Alignment * 8)); } if (getLangOptions().CPlusPlus && SS.isEmpty() && Name && !Invalid) { @@ -4560,7 +4555,7 @@ void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, // FIXME: This implementation is an ugly hack! if (PrevDecl) { - PrevDecl->addAttr(Context, ::new (Context) WeakAttr()); + PrevDecl->addAttr(::new (Context) WeakAttr()); return; } Diag(PragmaLoc, diag::err_unsupported_pragma_weak); @@ -4576,8 +4571,8 @@ void Sema::ActOnPragmaWeakAlias(IdentifierInfo* Name, // FIXME: This implementation is an ugly hack! if (PrevDecl) { - PrevDecl->addAttr(Context, ::new (Context) AliasAttr(AliasName->getName())); - PrevDecl->addAttr(Context, ::new (Context) WeakAttr()); + PrevDecl->addAttr(::new (Context) AliasAttr(AliasName->getName())); + PrevDecl->addAttr(::new (Context) WeakAttr()); return; } Diag(PragmaLoc, diag::err_unsupported_pragma_weak); |