diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-30 02:34:44 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-30 02:34:44 +0000 |
commit | 40b598eea1310ec9ed554d56ce3e25b34c585458 (patch) | |
tree | 8e2c3592f8ed4ac239504747ebffb388d5b170d6 /lib/Sema | |
parent | e4f2142d00fa5fdb580c4e2413da91882d955381 (diff) |
Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.
This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/JumpDiagnostics.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Sema/SemaAttr.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 65 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 105 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 18 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 6 |
10 files changed, 104 insertions, 114 deletions
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp index 425d804439..ae863f2df1 100644 --- a/lib/Sema/JumpDiagnostics.cpp +++ b/lib/Sema/JumpDiagnostics.cpp @@ -77,11 +77,11 @@ JumpScopeChecker::JumpScopeChecker(Stmt *Body, Sema &s) : S(s) { /// GetDiagForGotoScopeDecl - If this decl induces a new goto scope, return a /// diagnostic that should be emitted if control goes over it. If not, return 0. -static unsigned GetDiagForGotoScopeDecl(ASTContext &Context, const Decl *D) { +static unsigned GetDiagForGotoScopeDecl(const Decl *D) { if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { if (VD->getType()->isVariablyModifiedType()) return diag::note_protected_by_vla; - if (VD->hasAttr<CleanupAttr>(Context)) + if (VD->hasAttr<CleanupAttr>()) return diag::note_protected_by_cleanup; } else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) { if (TD->getUnderlyingType()->isVariablyModifiedType()) @@ -125,7 +125,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) { for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end(); I != E; ++I) { // If this decl causes a new scope, push and switch to it. - if (unsigned Diag = GetDiagForGotoScopeDecl(this->S.Context, *I)) { + if (unsigned Diag = GetDiagForGotoScopeDecl(*I)) { Scopes.push_back(GotoScope(ParentScope, Diag, (*I)->getLocation())); ParentScope = Scopes.size()-1; } diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index cbd4f58d48..0fa66c4937 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -485,7 +485,7 @@ public: void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) { for (; Param != ParamEnd; ++Param) { if (!(*Param)->isUsed() && (*Param)->getDeclName() && - !(*Param)->template hasAttr<UnusedAttr>(Context)) + !(*Param)->template hasAttr<UnusedAttr>()) Diag((*Param)->getLocation(), diag::warn_unused_parameter) << (*Param)->getDeclName(); } diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index cbfa56a691..1bf8444c42 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -205,7 +205,7 @@ void Sema::ActOnPragmaUnused(ExprTy **Exprs, unsigned NumExprs, // Otherwise, add the 'unused' attribute to each referenced declaration. for (unsigned i = 0; i < NumExprs; ++i) { DeclRefExpr *DR = (DeclRefExpr*) Exprs[i]; - DR->getDecl()->addAttr(Context, ::new (Context) UnusedAttr()); + DR->getDecl()->addAttr(::new (Context) UnusedAttr()); DR->Destroy(Context); } } diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 4f0553de7c..4eed018722 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -166,7 +166,7 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) { // handlers. // Printf checking. - if (const FormatAttr *Format = FDecl->getAttr<FormatAttr>(Context)) { + if (const FormatAttr *Format = FDecl->getAttr<FormatAttr>()) { if (Format->getType() == "printf") { bool HasVAListArg = Format->getFirstArg() == 0; if (!HasVAListArg) { @@ -178,7 +178,7 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) { HasVAListArg ? 0 : Format->getFirstArg() - 1); } } - for (const Attr *attr = FDecl->getAttrs(Context); + for (const Attr *attr = FDecl->getAttrs(); attr; attr = attr->getNext()) { if (const NonNullAttr *NonNull = dyn_cast<NonNullAttr>(attr)) CheckNonNullArguments(NonNull, TheCall); @@ -192,7 +192,7 @@ Sema::CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall) { OwningExprResult TheCallResult(Owned(TheCall)); // Printf checking. - const FormatAttr *Format = NDecl->getAttr<FormatAttr>(Context); + const FormatAttr *Format = NDecl->getAttr<FormatAttr>(); if (!Format) return move(TheCallResult); const VarDecl *V = dyn_cast<VarDecl>(NDecl); @@ -794,7 +794,7 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, = dyn_cast<ImplicitCastExpr>(CE->getCallee())) { if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr())) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) { - if (const FormatArgAttr *FA = FD->getAttr<FormatArgAttr>(Context)) { + if (const FormatArgAttr *FA = FD->getAttr<FormatArgAttr>()) { unsigned ArgIndex = FA->getFormatIdx(); const Expr *Arg = CE->getArg(ArgIndex - 1); 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); diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index f7dd9303cb..e251cab24a 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -284,7 +284,7 @@ static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) { } if (TagDecl *TD = dyn_cast<TagDecl>(d)) - TD->addAttr(S.Context, ::new (S.Context) PackedAttr(1)); + TD->addAttr(::new (S.Context) PackedAttr(1)); else if (FieldDecl *FD = dyn_cast<FieldDecl>(d)) { // If the alignment is less than or equal to 8 bits, the packed attribute // has no effect. @@ -293,7 +293,7 @@ static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) { S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type) << Attr.getName() << FD->getType(); else - FD->addAttr(S.Context, ::new (S.Context) PackedAttr(1)); + FD->addAttr(::new (S.Context) PackedAttr(1)); } else S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName(); } @@ -308,7 +308,7 @@ static void HandleIBOutletAttr(Decl *d, const AttributeList &Attr, Sema &S) { // The IBOutlet attribute only applies to instance variables of Objective-C // classes. if (isa<ObjCIvarDecl>(d) || isa<ObjCPropertyDecl>(d)) - d->addAttr(S.Context, ::new (S.Context) IBOutletAttr()); + d->addAttr(::new (S.Context) IBOutletAttr()); else S.Diag(Attr.getLoc(), diag::err_attribute_iboutlet); } @@ -380,7 +380,7 @@ static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) { unsigned* start = &NonNullArgs[0]; unsigned size = NonNullArgs.size(); std::sort(start, start + size); - d->addAttr(S.Context, ::new (S.Context) NonNullAttr(start, size)); + d->addAttr(::new (S.Context) NonNullAttr(start, size)); } static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -405,7 +405,7 @@ static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) { // FIXME: check if target symbol exists in current file - d->addAttr(S.Context, ::new (S.Context) AliasAttr(std::string(Alias, AliasLen))); + d->addAttr(::new (S.Context) AliasAttr(std::string(Alias, AliasLen))); } static void HandleAlwaysInlineAttr(Decl *d, const AttributeList &Attr, @@ -422,7 +422,7 @@ static void HandleAlwaysInlineAttr(Decl *d, const AttributeList &Attr, return; } - d->addAttr(S.Context, ::new (S.Context) AlwaysInlineAttr()); + d->addAttr(::new (S.Context) AlwaysInlineAttr()); } static bool HandleCommonNoReturnAttr(Decl *d, const AttributeList &Attr, @@ -447,13 +447,13 @@ static bool HandleCommonNoReturnAttr(Decl *d, const AttributeList &Attr, static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) { if (HandleCommonNoReturnAttr(d, Attr, S)) - d->addAttr(S.Context, ::new (S.Context) NoReturnAttr()); + d->addAttr(::new (S.Context) NoReturnAttr()); } static void HandleAnalyzerNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) { if (HandleCommonNoReturnAttr(d, Attr, S)) - d->addAttr(S.Context, ::new (S.Context) AnalyzerNoReturnAttr()); + d->addAttr(::new (S.Context) AnalyzerNoReturnAttr()); } static void HandleUnusedAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -469,7 +469,7 @@ static void HandleUnusedAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) UnusedAttr()); + d->addAttr(::new (S.Context) UnusedAttr()); } static void HandleUsedAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -490,7 +490,7 @@ static void HandleUsedAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) UsedAttr()); + d->addAttr(::new (S.Context) UsedAttr()); } static void HandleConstructorAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -519,7 +519,7 @@ static void HandleConstructorAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) ConstructorAttr(priority)); + d->addAttr(::new (S.Context) ConstructorAttr(priority)); } static void HandleDestructorAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -548,7 +548,7 @@ static void HandleDestructorAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) DestructorAttr(priority)); + d->addAttr(::new (S.Context) DestructorAttr(priority)); } static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -558,7 +558,7 @@ static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) DeprecatedAttr()); + d->addAttr(::new (S.Context) DeprecatedAttr()); } static void HandleUnavailableAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -568,7 +568,7 @@ static void HandleUnavailableAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) UnavailableAttr()); + d->addAttr(::new (S.Context) UnavailableAttr()); } static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -605,7 +605,7 @@ static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) VisibilityAttr(type)); + d->addAttr(::new (S.Context) VisibilityAttr(type)); } static void HandleObjCExceptionAttr(Decl *D, const AttributeList &Attr, @@ -621,7 +621,7 @@ static void HandleObjCExceptionAttr(Decl *D, const AttributeList &Attr, return; } - D->addAttr(S.Context, ::new (S.Context) ObjCExceptionAttr()); + D->addAttr(::new (S.Context) ObjCExceptionAttr()); } static void HandleObjCNSObject(Decl *D, const AttributeList &Attr, Sema &S) { @@ -637,7 +637,7 @@ static void HandleObjCNSObject(Decl *D, const AttributeList &Attr, Sema &S) { return; } } - D->addAttr(S.Context, ::new (S.Context) ObjCNSObjectAttr()); + D->addAttr(::new (S.Context) ObjCNSObjectAttr()); } static void @@ -652,7 +652,7 @@ HandleOverloadableAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - D->addAttr(S.Context, ::new (S.Context) OverloadableAttr()); + D->addAttr(::new (S.Context) OverloadableAttr()); } static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -676,7 +676,7 @@ static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) BlocksAttr(type)); + d->addAttr(::new (S.Context) BlocksAttr(type)); } static void HandleSentinelAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -768,7 +768,7 @@ static void HandleSentinelAttr(Decl *d, const AttributeList &Attr, Sema &S) { << Attr.getName() << 6 /*function, method or block */; return; } - d->addAttr(S.Context, ::new (S.Context) SentinelAttr(sentinel, nullPos)); + d->addAttr(::new (S.Context) SentinelAttr(sentinel, nullPos)); } static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S) { @@ -786,7 +786,7 @@ static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S) return; } - Fn->addAttr(S.Context, ::new (S.Context) WarnUnusedResultAttr()); + Fn->addAttr(::new (S.Context) WarnUnusedResultAttr()); } static void HandleWeakAttr(Decl *D, const AttributeList &Attr, Sema &S) { @@ -803,7 +803,7 @@ static void HandleWeakAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - D->addAttr(S.Context, ::new (S.Context) WeakAttr()); + D->addAttr(::new (S.Context) WeakAttr()); } static void HandleWeakImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { @@ -836,7 +836,7 @@ static void HandleWeakImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - D->addAttr(S.Context, ::new (S.Context) WeakImportAttr()); + D->addAttr(::new (S.Context) WeakImportAttr()); } static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { @@ -848,7 +848,7 @@ static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { // Attribute can be applied only to functions or variables. if (isa<VarDecl>(D)) { - D->addAttr(S.Context, ::new (S.Context) DLLImportAttr()); + D->addAttr(::new (S.Context) DLLImportAttr()); return; } @@ -876,12 +876,12 @@ static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { } } - if (D->getAttr<DLLExportAttr>(S.Context)) { + if (D->getAttr<DLLExportAttr>()) { S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "dllimport"; return; } - D->addAttr(S.Context, ::new (S.Context) DLLImportAttr()); + D->addAttr(::new (S.Context) DLLImportAttr()); } static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { @@ -893,7 +893,7 @@ static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { // Attribute can be applied only to functions or variables. if (isa<VarDecl>(D)) { - D->addAttr(S.Context, ::new (S.Context) DLLExportAttr()); + D->addAttr(::new (S.Context) DLLExportAttr()); return; } @@ -912,7 +912,7 @@ static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - D->addAttr(S.Context, ::new (S.Context) DLLExportAttr()); + D->addAttr(::new (S.Context) DLLExportAttr()); } static void HandleReqdWorkGroupSize(Decl *D, const AttributeList &Attr, @@ -934,8 +934,7 @@ static void HandleReqdWorkGroupSize(Decl *D, const AttributeList &Attr, } WGSize[i] = (unsigned) ArgNum.getZExtValue(); } - D->addAttr(S.Context, - ::new (S.Context) ReqdWorkGroupSizeAttr(WGSize[0], WGSize[1], + D->addAttr(::new (S.Context) ReqdWorkGroupSizeAttr(WGSize[0], WGSize[1], WGSize[2])); } @@ -955,8 +954,7 @@ static void HandleSectionAttr(Decl *D, const AttributeList &Attr, Sema &S) { S.Diag(Attr.getLoc(), diag::err_attribute_annotate_no_string); return; } - D->addAttr(S.Context, - ::new (S.Context) SectionAttr(std::string(SE->getStrData(), + D->addAttr(::new (S.Context) SectionAttr(std::string(SE->getStrData(), SE->getByteLength()))); } @@ -975,13 +973,13 @@ static void HandleStdCallAttr(Decl *d, const AttributeList &Attr, Sema &S) { } // stdcall and fastcall attributes are mutually incompatible. - if (d->getAttr<FastCallAttr>(S.Context)) { + if (d->getAttr<FastCallAttr>()) { S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible) << "stdcall" << "fastcall"; return; } - d->addAttr(S.Context, ::new (S.Context) StdCallAttr()); + d->addAttr(::new (S.Context) StdCallAttr()); } static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -998,13 +996,13 @@ static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) { } // stdcall and fastcall attributes are mutually incompatible. - if (d->getAttr<StdCallAttr>(S.Context)) { + if (d->getAttr<StdCallAttr>()) { S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible) << "fastcall" << "stdcall"; return; } - d->addAttr(S.Context, ::new (S.Context) FastCallAttr()); + d->addAttr(::new (S.Context) FastCallAttr()); } static void HandleNothrowAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1014,7 +1012,7 @@ static void HandleNothrowAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) NoThrowAttr()); + d->addAttr(::new (S.Context) NoThrowAttr()); } static void HandleConstAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1024,7 +1022,7 @@ static void HandleConstAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) ConstAttr()); + d->addAttr(::new (S.Context) ConstAttr()); } static void HandlePureAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1034,7 +1032,7 @@ static void HandlePureAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) PureAttr()); + d->addAttr(::new (S.Context) PureAttr()); } static void HandleCleanupAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1092,7 +1090,7 @@ static void HandleCleanupAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) CleanupAttr(FD)); + d->addAttr(::new (S.Context) CleanupAttr(FD)); } /// Handle __attribute__((format_arg((idx)))) attribute @@ -1155,7 +1153,7 @@ static void HandleFormatArgAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) FormatArgAttr(Idx.getZExtValue())); + d->addAttr(::new (S.Context) FormatArgAttr(Idx.getZExtValue())); } /// Handle __attribute__((format(type,idx,firstarg))) attributes @@ -1296,8 +1294,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, - ::new (S.Context) FormatAttr(std::string(Format, FormatLen), + d->addAttr(::new (S.Context) FormatAttr(std::string(Format, FormatLen), Idx.getZExtValue(), FirstArg.getZExtValue())); } @@ -1365,7 +1362,7 @@ static void HandleTransparentUnionAttr(Decl *d, const AttributeList &Attr, } } - RD->addAttr(S.Context, ::new (S.Context) TransparentUnionAttr()); + RD->addAttr(::new (S.Context) TransparentUnionAttr()); } static void HandleAnnotateAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1383,8 +1380,7 @@ static void HandleAnnotateAttr(Decl *d, const AttributeList &Attr, Sema &S) { S.Diag(Attr.getLoc(), diag::err_attribute_annotate_no_string); return; } - d->addAttr(S.Context, - ::new (S.Context) AnnotateAttr(std::string(SE->getStrData(), + d->addAttr(::new (S.Context) AnnotateAttr(std::string(SE->getStrData(), SE->getByteLength()))); } @@ -1400,7 +1396,7 @@ static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) { // FIXME: This should be the target specific maximum alignment. // (For now we just use 128 bits which is the maximum on X86). Align = 128; - d->addAttr(S.Context, ::new (S.Context) AlignedAttr(Align)); + d->addAttr(::new (S.Context) AlignedAttr(Align)); return; } @@ -1417,7 +1413,7 @@ static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) AlignedAttr(Alignment.getZExtValue() * 8)); + d->addAttr(::new (S.Context) AlignedAttr(Alignment.getZExtValue() * 8)); } /// HandleModeAttr - This attribute modifies the width of a decl with @@ -1598,7 +1594,7 @@ static void HandleNodebugAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) NodebugAttr()); + d->addAttr(::new (S.Context) NodebugAttr()); } static void HandleNoinlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1614,7 +1610,7 @@ static void HandleNoinlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) NoinlineAttr()); + d->addAttr(::new (S.Context) NoinlineAttr()); } static void HandleGNUInlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1636,7 +1632,7 @@ static void HandleGNUInlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, ::new (S.Context) GNUInlineAttr()); + d->addAttr(::new (S.Context) GNUInlineAttr()); } static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) { @@ -1672,8 +1668,7 @@ static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - d->addAttr(S.Context, - ::new (S.Context) RegparmAttr(NumParams.getZExtValue())); + d->addAttr(::new (S.Context) RegparmAttr(NumParams.getZExtValue())); } //===----------------------------------------------------------------------===// @@ -1706,10 +1701,10 @@ static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr, assert(0 && "invalid ownership attribute"); return; case AttributeList::AT_cf_returns_retained: - d->addAttr(S.Context, ::new (S.Context) CFReturnsRetainedAttr()); + d->addAttr(::new (S.Context) CFReturnsRetainedAttr()); return; case AttributeList::AT_ns_returns_retained: - d->addAttr(S.Context, ::new (S.Context) NSReturnsRetainedAttr()); + d->addAttr(::new (S.Context) NSReturnsRetainedAttr()); return; }; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 4be49a0b4a..62106eb58b 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -39,7 +39,7 @@ using namespace clang; /// referenced), false otherwise. bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { // See if the decl is deprecated. - if (D->getAttr<DeprecatedAttr>(Context)) { + if (D->getAttr<DeprecatedAttr>()) { // Implementing deprecated stuff requires referencing deprecated // stuff. Don't warn if we are implementing a deprecated // construct. @@ -48,7 +48,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { if (NamedDecl *ND = getCurFunctionOrMethodDecl()) { // If this reference happens *in* a deprecated function or method, don't // warn. - isSilenced = ND->getAttr<DeprecatedAttr>(Context); + isSilenced = ND->getAttr<DeprecatedAttr>(); // If this is an Objective-C method implementation, check to see if the // method was deprecated on the declaration, not the definition. @@ -61,7 +61,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { MD = Impl->getClassInterface()->getMethod(Context, MD->getSelector(), MD->isInstanceMethod()); - isSilenced |= MD && MD->getAttr<DeprecatedAttr>(Context); + isSilenced |= MD && MD->getAttr<DeprecatedAttr>(); } } } @@ -80,7 +80,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { } // See if the decl is unavailable - if (D->getAttr<UnavailableAttr>(Context)) { + if (D->getAttr<UnavailableAttr>()) { Diag(Loc, diag::warn_unavailable) << D->getDeclName(); Diag(D->getLocation(), diag::note_unavailable_here) << 0; } @@ -95,7 +95,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, Expr **Args, unsigned NumArgs) { - const SentinelAttr *attr = D->getAttr<SentinelAttr>(Context); + const SentinelAttr *attr = D->getAttr<SentinelAttr>(); if (!attr) return; int sentinelPos = attr->getSentinel(); @@ -1158,7 +1158,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, MarkDeclarationReferenced(Loc, VD); QualType ExprTy = VD->getType().getNonReferenceType(); // The BlocksAttr indicates the variable is bound by-reference. - if (VD->getAttr<BlocksAttr>(Context)) + if (VD->getAttr<BlocksAttr>()) return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, true)); // This is to record that a 'const' was actually synthesize and added. bool constAdded = !ExprTy.isConstQualified(); @@ -3489,7 +3489,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) { // If the ArgType is a Union type, we want to handle a potential // transparent_union GCC extension. const RecordType *UT = ArgType->getAsUnionType(); - if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>(Context)) + if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>()) return Incompatible; // The field to initialize within the transparent union. @@ -5226,7 +5226,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { CurBlock->hasPrototype = true; CurBlock->isVariadic = false; // Check for a valid sentinel attribute on this block. - if (CurBlock->TheDecl->getAttr<SentinelAttr>(Context)) { + if (CurBlock->TheDecl->getAttr<SentinelAttr>()) { Diag(ParamInfo.getAttributes()->getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1; // FIXME: remove the attribute. @@ -5275,7 +5275,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { // Check for a valid sentinel attribute on this block. if (!CurBlock->isVariadic && - CurBlock->TheDecl->getAttr<SentinelAttr>(Context)) { + CurBlock->TheDecl->getAttr<SentinelAttr>()) { Diag(ParamInfo.getAttributes()->getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1; // FIXME: remove the attribute. diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index e99217ea57..b7ab86352d 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -903,7 +903,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind, continue; } - if ((*I)->getAttr<OverloadableAttr>(Context)) { + if ((*I)->getAttr<OverloadableAttr>()) { // If this declaration has the "overloadable" attribute, we // might have a set of overloaded functions. diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index e240c04e5d..c63f038cd9 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -3573,7 +3573,7 @@ Sema::BestViableFunction(OverloadCandidateSet& CandidateSet, // Best is the best viable function. if (Best->Function && (Best->Function->isDeleted() || - Best->Function->getAttr<UnavailableAttr>(Context))) + Best->Function->getAttr<UnavailableAttr>())) return OR_Deleted; // C++ [basic.def.odr]p2: @@ -3600,7 +3600,7 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, if (Cand->Viable || !OnlyViable) { if (Cand->Function) { if (Cand->Function->isDeleted() || - Cand->Function->getAttr<UnavailableAttr>(Context)) { + Cand->Function->getAttr<UnavailableAttr>()) { // Deleted or "unavailable" function. Diag(Cand->Function->getLocation(), diag::err_ovl_candidate_deleted) << Cand->Function->isDeleted(); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 914839cbf7..63191e0e00 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -84,7 +84,7 @@ Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R, SourceLocation Loc; SourceRange R1, R2; - if (!E->isUnusedResultAWarning(Loc, R1, R2, Context)) + if (!E->isUnusedResultAWarning(Loc, R1, R2)) continue; Diag(Loc, diag::warn_unused_expr) << R1 << R2; @@ -766,7 +766,7 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { } QualType FnRetType = CurBlock->ReturnType; - if (CurBlock->TheDecl->hasAttr<NoReturnAttr>(Context)) { + if (CurBlock->TheDecl->hasAttr<NoReturnAttr>()) { Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr) << getCurFunctionOrMethodDecl()->getDeclName(); return StmtError(); @@ -842,7 +842,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, FullExprArg rex) { QualType FnRetType; if (const FunctionDecl *FD = getCurFunctionDecl()) { FnRetType = FD->getResultType(); - if (FD->hasAttr<NoReturnAttr>(Context)) + if (FD->hasAttr<NoReturnAttr>()) Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << getCurFunctionOrMethodDecl()->getDeclName(); } else if (ObjCMethodDecl *MD = getCurMethodDecl()) |