diff options
author | John McCall <rjmccall@apple.com> | 2010-08-21 09:40:31 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-21 09:40:31 +0000 |
commit | d226f65006733ed7f709c3174f22ce33391cb58f (patch) | |
tree | d26489e12cd9195a683fa4a50ed03839dcbabbbc /lib/Sema | |
parent | 1bf5adf0ee695b892e853c459612be61186b53b4 (diff) |
DeclPtrTy -> Decl *
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/Action.cpp | 37 | ||||
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/IdentifierResolver.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 39 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 219 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 221 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 114 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 14 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 98 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 34 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 128 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 33 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 20 |
17 files changed, 476 insertions, 516 deletions
diff --git a/lib/Sema/Action.cpp b/lib/Sema/Action.cpp index db0779f8b3..32d537d2dc 100644 --- a/lib/Sema/Action.cpp +++ b/lib/Sema/Action.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/Sema/Action.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/Scope.h" #include "clang/Basic/TargetInfo.h" @@ -69,35 +70,35 @@ Action::ObjCMessageKind Action::getObjCMessageKind(Scope *S, } // Defined out-of-line here because of dependecy on AttributeList -Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope, - SourceLocation UsingLoc, - SourceLocation NamespcLoc, - CXXScopeSpec &SS, - SourceLocation IdentLoc, - IdentifierInfo *NamespcName, - AttributeList *AttrList) { +Decl *Action::ActOnUsingDirective(Scope *CurScope, + SourceLocation UsingLoc, + SourceLocation NamespcLoc, + CXXScopeSpec &SS, + SourceLocation IdentLoc, + IdentifierInfo *NamespcName, + AttributeList *AttrList) { // FIXME: Parser seems to assume that Action::ActOn* takes ownership over // passed AttributeList, however other actions don't free it, is it // temporary state or bug? delete AttrList; - return DeclPtrTy(); + return 0; } // Defined out-of-line here because of dependency on AttributeList -Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope, - AccessSpecifier AS, - bool HasUsingKeyword, - SourceLocation UsingLoc, - CXXScopeSpec &SS, - UnqualifiedId &Name, - AttributeList *AttrList, - bool IsTypeName, - SourceLocation TypenameLoc) { +Decl *Action::ActOnUsingDeclaration(Scope *CurScope, + AccessSpecifier AS, + bool HasUsingKeyword, + SourceLocation UsingLoc, + CXXScopeSpec &SS, + UnqualifiedId &Name, + AttributeList *AttrList, + bool IsTypeName, + SourceLocation TypenameLoc) { // FIXME: Parser seems to assume that Action::ActOn* takes ownership over // passed AttributeList, however other actions don't free it, is it // temporary state or bug? delete AttrList; - return DeclPtrTy(); + return 0; } diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 417f8978c7..d1481bfb7b 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -407,14 +407,14 @@ bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, return false; } -void DeclSpec::setProtocolQualifiers(const ActionBase::DeclPtrTy *Protos, +void DeclSpec::setProtocolQualifiers(Decl * const *Protos, unsigned NP, SourceLocation *ProtoLocs, SourceLocation LAngleLoc) { if (NP == 0) return; - ProtocolQualifiers = new ActionBase::DeclPtrTy[NP]; + ProtocolQualifiers = new Decl*[NP]; ProtocolLocs = new SourceLocation[NP]; - memcpy((void*)ProtocolQualifiers, Protos, sizeof(ActionBase::DeclPtrTy)*NP); + memcpy((void*)ProtocolQualifiers, Protos, sizeof(Decl*)*NP); memcpy(ProtocolLocs, ProtoLocs, sizeof(SourceLocation)*NP); NumProtocolQualifiers = NP; ProtocolLAngleLoc = LAngleLoc; diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index d38f403d39..9421cad224 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -111,7 +111,7 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, ((DeclContext *)S->getEntity())->isTransparentContext()) S = S->getParent(); - if (S->isDeclScope(Action::DeclPtrTy::make(D))) + if (S->isDeclScope(D)) return true; if (LangOpt.CPlusPlus) { // C++ 3.3.2p3: @@ -128,7 +128,7 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, // assert(S->getParent() && "No TUScope?"); if (S->getParent()->getFlags() & Scope::ControlScope) - return S->getParent()->isDeclScope(Action::DeclPtrTy::make(D)); + return S->getParent()->isDeclScope(D); } return false; } diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 635236ec4c..34d0c4aa39 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -2713,8 +2713,8 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn, Results.size()); } -void Sema::CodeCompleteInitializer(Scope *S, DeclPtrTy D) { - ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D.getAs<Decl>()); +void Sema::CodeCompleteInitializer(Scope *S, Decl *D) { + ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D); if (!VD) { CodeCompleteOrdinaryName(S, PCC_Expression); return; @@ -2988,7 +2988,7 @@ static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) { Results.AddResult(Result(Pattern)); } -void Sema::CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl, +void Sema::CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl, bool InInterface) { typedef CodeCompleteConsumer::Result Result; ResultBuilder Results(*this); @@ -3310,17 +3310,16 @@ static void AddObjCMethods(ObjCContainerDecl *Container, } -void Sema::CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl, - DeclPtrTy *Methods, +void Sema::CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl, + Decl **Methods, unsigned NumMethods) { typedef CodeCompleteConsumer::Result Result; // Try to find the interface where getters might live. - ObjCInterfaceDecl *Class - = dyn_cast_or_null<ObjCInterfaceDecl>(ClassDecl.getAs<Decl>()); + ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(ClassDecl); if (!Class) { if (ObjCCategoryDecl *Category - = dyn_cast_or_null<ObjCCategoryDecl>(ClassDecl.getAs<Decl>())) + = dyn_cast_or_null<ObjCCategoryDecl>(ClassDecl)) Class = Category->getClassInterface(); if (!Class) @@ -3335,7 +3334,7 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl, // pushed into DeclContexts early enough. Argh! for (unsigned I = 0; I != NumMethods; ++I) { if (ObjCMethodDecl *Method - = dyn_cast_or_null<ObjCMethodDecl>(Methods[I].getAs<Decl>())) + = dyn_cast_or_null<ObjCMethodDecl>(Methods[I])) if (Method->isInstanceMethod() && isAcceptableObjCMethod(Method, MK_ZeroArgSelector, 0, 0)) { Result R = Result(Method, 0); @@ -3351,17 +3350,17 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl, Results.data(),Results.size()); } -void Sema::CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ObjCImplDecl, - DeclPtrTy *Methods, +void Sema::CodeCompleteObjCPropertySetter(Scope *S, Decl *ObjCImplDecl, + Decl **Methods, unsigned NumMethods) { typedef CodeCompleteConsumer::Result Result; // Try to find the interface where setters might live. ObjCInterfaceDecl *Class - = dyn_cast_or_null<ObjCInterfaceDecl>(ObjCImplDecl.getAs<Decl>()); + = dyn_cast_or_null<ObjCInterfaceDecl>(ObjCImplDecl); if (!Class) { if (ObjCCategoryDecl *Category - = dyn_cast_or_null<ObjCCategoryDecl>(ObjCImplDecl.getAs<Decl>())) + = dyn_cast_or_null<ObjCCategoryDecl>(ObjCImplDecl)) Class = Category->getClassInterface(); if (!Class) @@ -3376,7 +3375,7 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ObjCImplDecl, // pushed into DeclContexts early enough. Argh! for (unsigned I = 0; I != NumMethods; ++I) { if (ObjCMethodDecl *Method - = dyn_cast_or_null<ObjCMethodDecl>(Methods[I].getAs<Decl>())) + = dyn_cast_or_null<ObjCMethodDecl>(Methods[I])) if (Method->isInstanceMethod() && isAcceptableObjCMethod(Method, MK_OneArgSelector, 0, 0)) { Result R = Result(Method, 0); @@ -3932,13 +3931,13 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S, Results.data(),Results.size()); } -void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, DeclPtrTy ObjCImpDecl) { +void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) { typedef CodeCompleteConsumer::Result Result; ResultBuilder Results(*this); // Figure out where this @synthesize lives. ObjCContainerDecl *Container - = dyn_cast_or_null<ObjCContainerDecl>(ObjCImpDecl.getAs<Decl>()); + = dyn_cast_or_null<ObjCContainerDecl>(ObjCImpDecl); if (!Container || (!isa<ObjCImplementationDecl>(Container) && !isa<ObjCCategoryImplDecl>(Container))) @@ -3969,13 +3968,13 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, DeclPtrTy ObjCImpDecl) { void Sema::CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName, - DeclPtrTy ObjCImpDecl) { + Decl *ObjCImpDecl) { typedef CodeCompleteConsumer::Result Result; ResultBuilder Results(*this); // Figure out where this @synthesize lives. ObjCContainerDecl *Container - = dyn_cast_or_null<ObjCContainerDecl>(ObjCImpDecl.getAs<Decl>()); + = dyn_cast_or_null<ObjCContainerDecl>(ObjCImpDecl); if (!Container || (!isa<ObjCImplementationDecl>(Container) && !isa<ObjCCategoryImplDecl>(Container))) @@ -4086,7 +4085,7 @@ static void FindImplementableMethods(ASTContext &Context, void Sema::CodeCompleteObjCMethodDecl(Scope *S, bool IsInstanceMethod, TypeTy *ReturnTy, - DeclPtrTy IDecl) { + Decl *IDecl) { // Determine the return type of the method we're declaring, if // provided. QualType ReturnType = GetTypeFromParser(ReturnTy); @@ -4094,7 +4093,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, // Determine where we should start searching for methods, and where we ObjCContainerDecl *SearchDecl = 0, *CurrentDecl = 0; bool IsInImplementation = false; - if (Decl *D = IDecl.getAs<Decl>()) { + if (Decl *D = IDecl) { if (ObjCImplementationDecl *Impl = dyn_cast<ObjCImplementationDecl>(D)) { SearchDecl = Impl->getClassInterface(); CurrentDecl = Impl; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 339cb6632d..72d7e20000 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -38,15 +38,14 @@ using namespace clang; /// getDeclName - Return a pretty name for the specified decl if possible, or /// an empty string if not. This is used for pretty crash reporting. -std::string Sema::getDeclName(DeclPtrTy d) { - Decl *D = d.getAs<Decl>(); +std::string Sema::getDeclName(Decl *D) { if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(D)) return DN->getQualifiedNameAsString(); return ""; } -Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(DeclPtrTy Ptr) { - return DeclGroupPtrTy::make(DeclGroupRef(Ptr.getAs<Decl>())); +Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(Decl *Ptr) { + return DeclGroupPtrTy::make(DeclGroupRef(Ptr)); } /// \brief If the identifier refers to a type name within this scope, @@ -462,8 +461,8 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { IdentifierResolver::iterator I = IdResolver.begin(D->getDeclName()), IEnd = IdResolver.end(); for (; I != IEnd; ++I) { - if (S->isDeclScope(DeclPtrTy::make(*I)) && D->declarationReplaces(*I)) { - S->RemoveDecl(DeclPtrTy::make(*I)); + if (S->isDeclScope(*I) && D->declarationReplaces(*I)) { + S->RemoveDecl(*I); IdResolver.RemoveDecl(*I); // Should only need to replace one decl. @@ -471,7 +470,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { } } - S->AddDecl(DeclPtrTy::make(D)); + S->AddDecl(D); IdResolver.AddDecl(D); } @@ -673,7 +672,7 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end(); I != E; ++I) { - Decl *TmpD = (*I).getAs<Decl>(); + Decl *TmpD = (*I); assert(TmpD && "This decl didn't get pushed??"); assert(isa<NamedDecl>(TmpD) && "Decl isn't NamedDecl?"); @@ -1581,8 +1580,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with /// no declarator (e.g. "struct foo;") is parsed. -Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, - DeclSpec &DS) { +Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, + DeclSpec &DS) { // FIXME: Error on auto/register at file scope // FIXME: Error on inline/virtual/explicit // FIXME: Warn on useless __thread @@ -1598,7 +1597,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, TagD = static_cast<Decl *>(DS.getTypeRep()); if (!TagD) // We probably had an error - return DeclPtrTy(); + return 0; // Note that the above type specs guarantee that the // type rep is a Decl, whereas in many of the others @@ -1619,7 +1618,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // If we're dealing with a class template decl, assume that the // template routines are handling it. if (TagD && isa<ClassTemplateDecl>(TagD)) - return DeclPtrTy(); + return 0; return ActOnFriendTypeDecl(S, DS, MultiTemplateParamsArg(*this, 0, 0)); } @@ -1640,7 +1639,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // about them. // FIXME: Should we support Microsoft's extensions in this area? if (Record->getDeclName() && getLangOptions().Microsoft) - return DeclPtrTy::make(Tag); + return Tag; } if (getLangOptions().CPlusPlus && @@ -1659,14 +1658,14 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, Tag && isa<EnumDecl>(Tag)) { Diag(DS.getSourceRange().getBegin(), diag::ext_typedef_without_a_name) << DS.getSourceRange(); - return DeclPtrTy::make(Tag); + return Tag; } Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators) << DS.getSourceRange(); } - return DeclPtrTy::make(TagD); + return TagD; } /// We are trying to inject an anonymous member into the given scope; @@ -1743,7 +1742,7 @@ static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, // considered to have been defined in the scope in which the // anonymous union is declared. Owner->makeDeclVisibleInContext(*F); - S->AddDecl(Sema::DeclPtrTy::make(*F)); + S->AddDecl(*F); SemaRef.IdResolver.AddDecl(*F); // That includes picking up the appropriate access specifier. @@ -1804,9 +1803,9 @@ StorageClassSpecToFunctionDeclStorageClass(DeclSpec::SCS StorageClassSpec) { /// anonymous structure or union. Anonymous unions are a C++ feature /// (C++ [class.union]) and a GNU C extension; anonymous structures /// are a GNU C and GNU C++ extension. -Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, - AccessSpecifier AS, - RecordDecl *Record) { +Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, + AccessSpecifier AS, + RecordDecl *Record) { DeclContext *Owner = Record->getDeclContext(); // Diagnose whether this anonymous struct/union is an extension. @@ -1973,7 +1972,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, if (Invalid) Anon->setInvalidDecl(); - return DeclPtrTy::make(Anon); + return Anon; } @@ -2172,10 +2171,9 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, return false; } -Sema::DeclPtrTy -Sema::HandleDeclarator(Scope *S, Declarator &D, - MultiTemplateParamsArg TemplateParamLists, - bool IsFunctionDefinition) { +Decl *Sema::HandleDeclarator(Scope *S, Declarator &D, + MultiTemplateParamsArg TemplateParamLists, + bool IsFunctionDefinition) { // TODO: consider using NameInfo for diagnostic. DeclarationNameInfo NameInfo = GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); @@ -2187,7 +2185,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, Diag(D.getDeclSpec().getSourceRange().getBegin(), diag::err_declarator_need_ident) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); - return DeclPtrTy(); + return 0; } // The scope passed in may not be a decl scope. Zip up the scope tree until @@ -2211,14 +2209,14 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, diag::err_template_qualified_declarator_no_match) << (NestedNameSpecifier*)D.getCXXScopeSpec().getScopeRep() << D.getCXXScopeSpec().getRange(); - return DeclPtrTy(); + return 0; } bool IsDependentContext = DC->isDependentContext(); if (!IsDependentContext && RequireCompleteDeclContext(D.getCXXScopeSpec(), DC)) - return DeclPtrTy(); + return 0; if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->hasDefinition()) { Diag(D.getIdentifierLoc(), @@ -2345,7 +2343,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) { if (TemplateParamLists.size()) { Diag(D.getIdentifierLoc(), diag::err_template_typedef); - return DeclPtrTy(); + return 0; } New = ActOnTypedefDeclarator(S, D, DC, R, TInfo, Previous, Redeclaration); @@ -2360,14 +2358,14 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, } if (New == 0) - return DeclPtrTy(); + return 0; // If this has an identifier and is not an invalid redeclaration or // function template specialization, add it to the scope stack. if (New->getDeclName() && !(Redeclaration && New->isInvalidDecl())) PushOnScopeChains(New, S); - return DeclPtrTy::make(New); + return New; } /// TryToFixInvalidVariablyModifiedType - Helper method to turn variable array @@ -2455,11 +2453,11 @@ Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, if (S && IdResolver.ReplaceDecl(PrevDecl, ND)) { // The previous declaration was found on the identifer resolver // chain, so remove it from its scope. - while (S && !S->isDeclScope(DeclPtrTy::make(PrevDecl))) + while (S && !S->isDeclScope(PrevDecl)) S = S->getParent(); if (S) - S->RemoveDecl(DeclPtrTy::make(PrevDecl)); + S->RemoveDecl(PrevDecl); } } @@ -3478,9 +3476,9 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // already checks for that case. if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 && FTI.ArgInfo[0].Param && - FTI.ArgInfo[0].Param.getAs<ParmVarDecl>()->getType()->isVoidType()) { + cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) { // Empty arg list, don't push any params. - ParmVarDecl *Param = FTI.ArgInfo[0].Param.getAs<ParmVarDecl>(); + ParmVarDecl *Param = cast<ParmVarDecl>(FTI.ArgInfo[0].Param); // In C++, the empty parameter-type-list must be spelled "void"; a // typedef of void is not permitted. @@ -3490,7 +3488,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // FIXME: Leaks decl? } else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) { for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) { - ParmVarDecl *Param = FTI.ArgInfo[i].Param.getAs<ParmVarDecl>(); + ParmVarDecl *Param = cast<ParmVarDecl>(FTI.ArgInfo[i].Param); assert(Param->getDeclContext() != NewFD && "Was set before ?"); Param->setDeclContext(NewFD); Params.push_back(Param); @@ -4038,15 +4036,14 @@ bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) { return true; } -void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init) { +void Sema::AddInitializerToDecl(Decl *dcl, ExprArg init) { AddInitializerToDecl(dcl, move(init), /*DirectInit=*/false); } /// AddInitializerToDecl - Adds the initializer Init to the /// declaration dcl. If DirectInit is true, this is C++ direct /// initialization rather than copy initialization. -void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { - Decl *RealDecl = dcl.getAs<Decl>(); +void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) { // If there is no declaration, there was an error parsing it. Just ignore // the initializer. if (RealDecl == 0) @@ -4263,10 +4260,9 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { /// ActOnInitializerError - Given that there was an error parsing an /// initializer for the given declaration, try to return to some form /// of sanity. -void Sema::ActOnInitializerError(DeclPtrTy dcl) { +void Sema::ActOnInitializerError(Decl *D) { // Our main concern here is re-establishing invariants like "a // variable's type is either dependent or complete". - Decl *D = dcl.getAs<Decl>(); if (!D || D->isInvalidDecl()) return; VarDecl *VD = dyn_cast<VarDecl>(D); @@ -4295,10 +4291,8 @@ void Sema::ActOnInitializerError(DeclPtrTy dcl) { // though. } -void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, +void Sema::ActOnUninitializedDecl(Decl *RealDecl, bool TypeContainsUndeducedAuto) { - Decl *RealDecl = dcl.getAs<Decl>(); - // If there is no declaration, there was an error parsing it. Just ignore it. if (RealDecl == 0) return; @@ -4471,7 +4465,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, } Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, - DeclPtrTy *Group, + Decl **Group, unsigned NumDecls) { llvm::SmallVector<Decl*, 8> Decls; @@ -4479,7 +4473,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, Decls.push_back((Decl*)DS.getTypeRep()); for (unsigned i = 0; i != NumDecls; ++i) - if (Decl *D = Group[i].getAs<Decl>()) + if (Decl *D = Group[i]) Decls.push_back(D); return DeclGroupPtrTy::make(DeclGroupRef::Create(Context, @@ -4489,8 +4483,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() /// to introduce parameters into function prototype scope. -Sema::DeclPtrTy -Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { +Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { const DeclSpec &DS = D.getDeclSpec(); // Verify C99 6.7.5.3p2: The only SCS allowed is 'register'. @@ -4539,7 +4532,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. PrevDecl = 0; - } else if (S->isDeclScope(DeclPtrTy::make(PrevDecl))) { + } else if (S->isDeclScope(PrevDecl)) { Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II; Diag(PrevDecl->getLocation(), diag::note_previous_declaration); @@ -4570,7 +4563,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { } // Add the parameter declaration into this scope. - S->AddDecl(DeclPtrTy::make(New)); + S->AddDecl(New); if (II) IdResolver.AddDecl(New); @@ -4579,7 +4572,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { if (New->hasAttr<BlocksAttr>()) { Diag(New->getLocation(), diag::err_block_on_nonlocal); } - return DeclPtrTy::make(New); + return New; } /// \brief Synthesizes a variable for a parameter arising from a @@ -4668,8 +4661,8 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, } } -Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, - Declarator &D) { +Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, + Declarator &D) { assert(getCurFunctionDecl() == 0 && "Function parsing confused"); assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function && "Not a function declarator!"); @@ -4681,9 +4674,9 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Scope *ParentScope = FnBodyScope->getParent(); - DeclPtrTy DP = HandleDeclarator(ParentScope, D, - MultiTemplateParamsArg(*this), - /*IsFunctionDefinition=*/true); + Decl *DP = HandleDeclarator(ParentScope, D, + MultiTemplateParamsArg(*this), + /*IsFunctionDefinition=*/true); return ActOnStartOfFunctionDef(FnBodyScope, DP); } @@ -4731,7 +4724,7 @@ static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD) { return MissingPrototype; } -Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { +Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // Clear the last template instantiation error context. LastTemplateInstantiationErrorContext = ActiveTemplateInstantiation(); @@ -4739,11 +4732,10 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { return D; FunctionDecl *FD = 0; - if (FunctionTemplateDecl *FunTmpl - = dyn_cast<FunctionTemplateDecl>(D.getAs<Decl>())) + if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D)) FD = FunTmpl->getTemplatedDecl(); else - FD = cast<FunctionDecl>(D.getAs<Decl>()); + FD = cast<FunctionDecl>(D); // Enter a new function scope PushFunctionScope(); @@ -4816,7 +4808,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { diag::err_attribute_can_be_applied_only_to_symbol_declaration) << "dllimport"; FD->setInvalidDecl(); - return DeclPtrTy::make(FD); + return FD; } // Visual C++ appears to not think this is an issue, so only issue @@ -4830,7 +4822,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { << FD->getName() << "dllimport"; } } - return DeclPtrTy::make(FD); + return FD; } /// \brief Given the set of return statements within a function body, @@ -4865,13 +4857,12 @@ static void ComputeNRVO(Stmt *Body, ReturnStmt **Returns, unsigned NumReturns) { const_cast<VarDecl*>(NRVOCandidate)->setNRVOVariable(true); } -Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) { +Decl *Sema::ActOnFinishFunctionBody(Decl *D, StmtArg BodyArg) { return ActOnFinishFunctionBody(D, move(BodyArg), false); } -Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, - bool IsInstantiation) { - Decl *dcl = D.getAs<Decl>(); +Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, StmtArg BodyArg, + bool IsInstantiation) { Stmt *Body = BodyArg.takeAs<Stmt>(); FunctionDecl *FD = 0; @@ -4911,7 +4902,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (!MD->isInvalidDecl()) DiagnoseUnusedParameters(MD->param_begin(), MD->param_end()); } else { - return DeclPtrTy(); + return 0; } // Verify and clean out per-function state. @@ -5010,7 +5001,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (getDiagnostics().hasErrorOccurred()) ExprTemporaries.clear(); - return D; + return dcl; } /// ImplicitlyDefineFunction - An undeclared identifier was used in a function @@ -5056,8 +5047,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, DeclContext *PrevDC = CurContext; CurContext = Context.getTranslationUnitDecl(); - FunctionDecl *FD = - dyn_cast<FunctionDecl>(ActOnDeclarator(TUScope, D).getAs<Decl>()); + FunctionDecl *FD = dyn_cast<FunctionDecl>(ActOnDeclarator(TUScope, D)); FD->setImplicit(); CurContext = PrevDC; @@ -5224,7 +5214,7 @@ bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous, /// former case, Name will be non-null. In the later case, Name will be null. /// TagSpec indicates what kind of tag this is. TUK indicates whether this is a /// reference/declaration/definition of a tag. -Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, +Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, @@ -5256,7 +5246,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // This is a declaration or definition of a class template (which may // be a member of another template). if (Invalid) - return DeclPtrTy(); + return 0; OwnedDecl = false; DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc, @@ -5299,26 +5289,26 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, DC = computeDeclContext(SS, false); if (!DC) { IsDependent = true; - return DeclPtrTy(); + return 0; } } else { DC = computeDeclContext(SS, true); if (!DC) { Diag(SS.getRange().getBegin(), diag::err_dependent_nested_name_spec) << SS.getRange(); - return DeclPtrTy(); + return 0; } } if (RequireCompleteDeclContext(SS, DC)) - return DeclPtrTy::make((Decl *)0); + return 0; SearchDC = DC; // Look-up name inside 'foo::'. LookupQualifiedName(Previous, DC); if (Previous.isAmbiguous()) - return DeclPtrTy(); + return 0; if (Previous.empty()) { // Name lookup did not find anything. However, if the @@ -5328,7 +5318,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // this as a dependent elaborated-type-specifier. if (Previous.wasNotFoundInCurrentInstantiation()) { IsDependent = true; - return DeclPtrTy(); + return 0; } // A tag 'foo::bar' must already exist. @@ -5348,7 +5338,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // Note: there used to be some attempt at recovery here. if (Previous.isAmbiguous()) - return DeclPtrTy(); + return 0; if (!getLangOptions().CPlusPlus && TUK != TUK_Reference) { // FIXME: This makes sure that we ignore the contexts associated @@ -5514,7 +5504,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // need to be changed with DeclGroups |