diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e020df127e4..76472651e1e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5420,7 +5420,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, } NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), - Context, Label)); + Context, Label, 0)); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier()); @@ -6929,7 +6929,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // The parser guarantees this is a string. StringLiteral *SE = cast<StringLiteral>(E); NewFD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), Context, - SE->getString())); + SE->getString(), 0)); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier()); @@ -7005,7 +7005,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (D.getDeclSpec().isNoreturnSpecified()) NewFD->addAttr( ::new(Context) C11NoReturnAttr(D.getDeclSpec().getNoreturnSpecLoc(), - Context)); + Context, 0)); // Functions returning a variably modified type violate C99 6.7.5.2p2 // because all functions have linkage. @@ -7027,8 +7027,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Attach the attribute to the new decl. Don't apply the attribute if it // returns an instance of the class (e.g. assignment operators). if (!MD || MD->getParent() != Ret) { - NewFD->addAttr(new (Context) WarnUnusedResultAttr(SourceRange(), - Context)); + NewFD->addAttr(WarnUnusedResultAttr::CreateImplicit(Context)); } } @@ -7485,8 +7484,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (OverloadedDecl) Diag(OverloadedDecl->getLocation(), diag::note_attribute_overloadable_prev_overload); - NewFD->addAttr(::new (Context) OverloadableAttr(SourceLocation(), - Context)); + NewFD->addAttr(OverloadableAttr::CreateImplicit(Context)); } } } @@ -7509,8 +7507,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, << Redeclaration << NewFD; Diag(Previous.getFoundDecl()->getLocation(), diag::note_attribute_overloadable_prev_overload); - NewFD->addAttr(::new (Context) OverloadableAttr(SourceLocation(), - Context)); + NewFD->addAttr(OverloadableAttr::CreateImplicit(Context)); } if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl), false)) { Redeclaration = false; @@ -10090,19 +10087,21 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (FormatIdx < NumParams && // NumParams may be 0 (e.g. vfprintf) FD->getParamDecl(FormatIdx)->getType()->isObjCObjectPointerType()) fmt = "NSString"; - FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, + FD->addAttr(FormatAttr::CreateImplicit(Context, &Context.Idents.get(fmt), FormatIdx+1, - HasVAListArg ? 0 : FormatIdx+2)); + HasVAListArg ? 0 : FormatIdx+2, + FD->getLocation())); } } if (Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx, HasVAListArg)) { if (!FD->hasAttr<FormatAttr>()) - FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, + FD->addAttr(FormatAttr::CreateImplicit(Context, &Context.Idents.get("scanf"), FormatIdx+1, - HasVAListArg ? 0 : FormatIdx+2)); + HasVAListArg ? 0 : FormatIdx+2, + FD->getLocation())); } // Mark const if we don't care about errno and that is the only @@ -10111,16 +10110,17 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (!getLangOpts().MathErrno && Context.BuiltinInfo.isConstWithoutErrno(BuiltinID)) { if (!FD->hasAttr<ConstAttr>()) - FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); + FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation())); } if (Context.BuiltinInfo.isReturnsTwice(BuiltinID) && !FD->hasAttr<ReturnsTwiceAttr>()) - FD->addAttr(::new (Context) ReturnsTwiceAttr(FD->getLocation(), Context)); + FD->addAttr(ReturnsTwiceAttr::CreateImplicit(Context, + FD->getLocation())); if (Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->hasAttr<NoThrowAttr>()) - FD->addAttr(::new (Context) NoThrowAttr(FD->getLocation(), Context)); + FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation())); if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr<ConstAttr>()) - FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); + FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation())); } IdentifierInfo *Name = FD->getIdentifier(); @@ -10140,16 +10140,18 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { // FIXME: asprintf and vasprintf aren't C99 functions. Should they be // target-specific builtins, perhaps? if (!FD->hasAttr<FormatAttr>()) - FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, + FD->addAttr(FormatAttr::CreateImplicit(Context, &Context.Idents.get("printf"), 2, - Name->isStr("vasprintf") ? 0 : 3)); + Name->isStr("vasprintf") ? 0 : 3, + FD->getLocation())); } if (Name->isStr("__CFStringMakeConstantString")) { // We already have a __builtin___CFStringMakeConstantString, // but builds that use -fno-constant-cfstrings don't go through that. if (!FD->hasAttr<FormatArgAttr>()) - FD->addAttr(::new (Context) FormatArgAttr(FD->getLocation(), Context, 1)); + FD->addAttr(FormatArgAttr::CreateImplicit(Context, 1, + FD->getLocation())); } } @@ -11697,8 +11699,9 @@ bool Sema::CheckNontrivialField(FieldDecl *FD) { SourceLocation Loc = FD->getLocation(); if (getSourceManager().isInSystemHeader(Loc)) { if (!FD->hasAttr<UnavailableAttr>()) - FD->addAttr(new (Context) UnavailableAttr(Loc, Context, - "this system field has retaining ownership")); + FD->addAttr(UnavailableAttr::CreateImplicit(Context, + "this system field has retaining ownership", + Loc)); return false; } } @@ -12071,8 +12074,9 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, SourceLocation loc = FD->getLocation(); if (getSourceManager().isInSystemHeader(loc)) { if (!FD->hasAttr<UnavailableAttr>()) { - FD->addAttr(new (Context) UnavailableAttr(loc, Context, - "this system field has retaining ownership")); + FD->addAttr(UnavailableAttr::CreateImplicit(Context, + "this system field has retaining ownership", + loc)); } } else { Diag(FD->getLocation(), diag::err_arc_objc_object_in_tag) @@ -13046,8 +13050,8 @@ void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name, SourceLocation AliasNameLoc) { Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName); - AsmLabelAttr *Attr = - ::new (Context) AsmLabelAttr(AliasNameLoc, Context, AliasName->getName()); + AsmLabelAttr *Attr = ::new (Context) AsmLabelAttr(AliasNameLoc, Context, + AliasName->getName(), 0); if (PrevDecl) PrevDecl->addAttr(Attr); @@ -13062,7 +13066,7 @@ void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName); if (PrevDecl) { - PrevDecl->addAttr(::new (Context) WeakAttr(PragmaLoc, Context)); + PrevDecl->addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc)); } else { (void)WeakUndeclaredIdentifiers.insert( std::pair<IdentifierInfo*,WeakInfo> |