diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-01-20 01:17:11 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-01-20 01:17:11 +0000 |
| commit | 6e6ad602e578dd178453d0008fe47ef13f629e24 (patch) | |
| tree | 697316433686f85f3013558cdaee8f88663ff09d /clang/lib/Sema | |
| parent | c59945b4bdfd8887bf9efb1a69171084910acf14 (diff) | |
| download | bcm5719-llvm-6e6ad602e578dd178453d0008fe47ef13f629e24.tar.gz bcm5719-llvm-6e6ad602e578dd178453d0008fe47ef13f629e24.zip | |
Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.
Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.
The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.
llvm-svn: 62562
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/IdentifierResolver.cpp | 13 | ||||
| -rw-r--r-- | clang/lib/Sema/IdentifierResolver.h | 6 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 27 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 95 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 16 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 13 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 13 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 12 |
12 files changed, 102 insertions, 129 deletions
diff --git a/clang/lib/Sema/IdentifierResolver.cpp b/clang/lib/Sema/IdentifierResolver.cpp index 762885e42c3..4e9d085a75b 100644 --- a/clang/lib/Sema/IdentifierResolver.cpp +++ b/clang/lib/Sema/IdentifierResolver.cpp @@ -46,19 +46,10 @@ public: // LookupContext Implementation //===----------------------------------------------------------------------===// -/// getContext - Returns translation unit context for non ScopedDecls and +/// getContext - Returns translation unit context for non Decls and /// for EnumConstantDecls returns the parent context of their EnumDecl. DeclContext *IdentifierResolver::LookupContext::getContext(Decl *D) { - DeclContext *Ctx; - - if (EnumConstantDecl *EnumD = dyn_cast<EnumConstantDecl>(D)) { - Ctx = EnumD->getDeclContext()->getParent(); - } else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) - Ctx = SD->getDeclContext(); - else if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) - Ctx = Ovl->getDeclContext(); - else - return TUCtx(); + DeclContext *Ctx = D->getDeclContext(); if (!Ctx) // FIXME: HACK! We shouldn't end up with a NULL context here. return TUCtx(); diff --git a/clang/lib/Sema/IdentifierResolver.h b/clang/lib/Sema/IdentifierResolver.h index c29fffb36d2..a44323e1b0d 100644 --- a/clang/lib/Sema/IdentifierResolver.h +++ b/clang/lib/Sema/IdentifierResolver.h @@ -29,8 +29,8 @@ namespace clang { class IdentifierResolver { /// LookupContext - A wrapper for DeclContext. DeclContext is only part of - /// ScopedDecls, LookupContext can be used with all decls (assumes - /// translation unit context for non ScopedDecls). + /// Decls, LookupContext can be used with all decls (assumes + /// translation unit context for non Decls). class LookupContext { const DeclContext *Ctx; @@ -42,7 +42,7 @@ class IdentifierResolver { return reinterpret_cast<DeclContext*>(-1); } - /// getContext - Returns translation unit context for non ScopedDecls and + /// getContext - Returns translation unit context for non Decls and /// for EnumConstantDecls returns the parent context of their EnumDecl. static DeclContext *getContext(Decl *D); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index ea42dbff0f0..423b0491245 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -79,7 +79,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { TypedefDecl *SelTypedef = TypedefDecl::Create(Context, CurContext, SourceLocation(), &Context.Idents.get("SEL"), - SelT, 0); + SelT); PushOnScopeChains(SelTypedef, TUScope); Context.setObjCSelType(SelTypedef); @@ -88,7 +88,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { QualType ClassT = Context.getPointerType(Context.getTagDeclType(ClassTag)); TypedefDecl *ClassTypedef = TypedefDecl::Create(Context, CurContext, SourceLocation(), - &Context.Idents.get("Class"), ClassT, 0); + &Context.Idents.get("Class"), ClassT); PushOnScopeChains(ClassTag, TUScope); PushOnScopeChains(ClassTypedef, TUScope); Context.setObjCClassType(ClassTypedef); @@ -108,7 +108,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { TypedefDecl *IdTypedef = TypedefDecl::Create(Context, CurContext, SourceLocation(), &Context.Idents.get("id"), - ObjT, 0); + ObjT); PushOnScopeChains(IdTypedef, TUScope); Context.setObjCIdType(IdTypedef); } @@ -223,7 +223,7 @@ NamedDecl *Sema::getCurFunctionOrMethodDecl() { while (isa<BlockDecl>(DC)) DC = DC->getParent(); if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC)) - return cast<ScopedDecl>(DC); + return cast<NamedDecl>(DC); return 0; } diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 053a323ebbc..80168544dcb 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -40,7 +40,6 @@ namespace clang { class DeclContext; class DeclSpec; class NamedDecl; - class ScopedDecl; class Stmt; class Expr; class InitListExpr; @@ -285,16 +284,16 @@ public: } DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup, bool IsFunctionDefinition); - ScopedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl* LastDeclarator, - Decl* PrevDecl, bool& InvalidDecl); - ScopedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl* LastDeclarator, + NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, + QualType R, Decl* LastDeclarator, + Decl* PrevDecl, bool& InvalidDecl); + NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, + QualType R, Decl* LastDeclarator, Decl* PrevDecl, bool& InvalidDecl); - ScopedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl *LastDeclarator, - Decl* PrevDecl, bool IsFunctionDefinition, - bool& InvalidDecl); + NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, + QualType R, Decl *LastDeclarator, + Decl* PrevDecl, bool IsFunctionDefinition, + bool& InvalidDecl); virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D); virtual void ActOnParamDefaultArgument(DeclTy *param, SourceLocation EqualLoc, @@ -399,7 +398,7 @@ public: /// Subroutines of ActOnDeclarator(). TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T, - ScopedDecl *LastDecl); + Decl *LastDecl); TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old); FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old, bool &Redeclaration); @@ -786,10 +785,10 @@ public: //@} ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id); - ScopedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, - Scope *S); - ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, + NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S); + NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, + Scope *S); // More parsing and symbol table subroutines. diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fe604960f72..ec769a16f0f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -88,8 +88,8 @@ DeclContext *Sema::getContainingDC(DeclContext *DC) { if (isa<ObjCMethodDecl>(DC)) return Context.getTranslationUnitDecl(); - if (ScopedDecl *SD = dyn_cast<ScopedDecl>(DC)) - return SD->getLexicalDeclContext(); + if (Decl *D = dyn_cast<Decl>(DC)) + return D->getLexicalDeclContext(); return DC->getLexicalParent(); } @@ -121,8 +121,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) { // Add scoped declarations into their context, so that they can be // found later. Declarations without a context won't be inserted // into any context. - if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) - CurContext->addDecl(SD); + CurContext->addDecl(D); // C++ [basic.scope]p4: // -- exactly one declaration shall declare a class name or @@ -178,7 +177,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) { = std::find_if(IdResolver.begin(FD->getDeclName(), DC, false/*LookInParentCtx*/), IdResolver.end(), - std::bind1st(std::mem_fun(&ScopedDecl::declarationReplaces), + std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces), FD)); if (Redecl != IdResolver.end()) { // There is already a declaration of a function on our @@ -303,8 +302,8 @@ void Sema::InitBuiltinVaListType() { /// LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope. /// lazily create a decl for it. -ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, - Scope *S) { +NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, + Scope *S) { Builtin::ID BID = (Builtin::ID)bid; if (Context.BuiltinInfo.hasVAListUse(BID)) @@ -314,7 +313,7 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, FunctionDecl *New = FunctionDecl::Create(Context, Context.getTranslationUnitDecl(), SourceLocation(), II, R, - FunctionDecl::Extern, false, 0); + FunctionDecl::Extern, false); // Create Decl objects for each parameter, adding them to the // FunctionDecl. @@ -322,8 +321,7 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, llvm::SmallVector<ParmVarDecl*, 16> Params; for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0, - FT->getArgType(i), VarDecl::None, 0, - 0)); + FT->getArgType(i), VarDecl::None, 0)); New->setParams(Context, &Params[0], Params.size()); } @@ -921,13 +919,12 @@ Sema::DeclTy *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, } // Create a declaration for this anonymous struct/union. - ScopedDecl *Anon = 0; + NamedDecl *Anon = 0; if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), - /*BitWidth=*/0, /*Mutable=*/false, - /*PrevDecl=*/0); + /*BitWidth=*/0, /*Mutable=*/false); Anon->setAccess(AS_public); if (getLangOptions().CPlusPlus) FieldCollector->Add(cast<FieldDecl>(Anon)); @@ -953,8 +950,7 @@ Sema::DeclTy *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Anon = VarDecl::Create(Context, Owner, Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), - SC, /*FIXME:LastDeclarator=*/0, - DS.getSourceRange().getBegin()); + SC, DS.getSourceRange().getBegin()); } Anon->setImplicit(); @@ -1206,7 +1202,7 @@ static bool isNearlyMatchingMemberFunction(ASTContext &Context, Sema::DeclTy * Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, bool IsFunctionDefinition) { - ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl); + NamedDecl *LastDeclarator = dyn_cast_or_null<NamedDecl>((Decl *)lastDecl); DeclarationName Name = GetNameForDeclarator(D); // All of these full declarators require an identifier. If it doesn't have @@ -1227,7 +1223,7 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, DeclContext *DC; Decl *PrevDecl; - ScopedDecl *New; + NamedDecl *New; bool InvalidDecl = false; // See if this is a redefinition of a variable in the same scope. @@ -1320,9 +1316,9 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, return New; } -ScopedDecl* +NamedDecl* Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl* LastDeclarator, + QualType R, Decl* LastDeclarator, Decl* PrevDecl, bool& InvalidDecl) { // Typedef declarators cannot be qualified (C++ [dcl.meaning]p1). if (D.getCXXScopeSpec().isSet()) { @@ -1364,9 +1360,9 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, return NewTD; } -ScopedDecl* +NamedDecl* Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl* LastDeclarator, + QualType R, Decl* LastDeclarator, Decl* PrevDecl, bool& InvalidDecl) { DeclarationName Name = GetNameForDeclarator(D); @@ -1410,7 +1406,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, // This is a static data member for a C++ class. NewVD = CXXClassVarDecl::Create(Context, cast<CXXRecordDecl>(DC), D.getIdentifierLoc(), II, - R, LastDeclarator); + R); } else { bool ThreadSpecified = D.getDeclSpec().isThreadSpecified(); if (S->getFnParent() == 0) { @@ -1422,11 +1418,13 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, } } NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(), - II, R, SC, LastDeclarator, + II, R, SC, // FIXME: Move to DeclGroup... D.getDeclSpec().getSourceRange().getBegin()); NewVD->setThreadSpecified(ThreadSpecified); } + NewVD->setNextDeclarator(LastDeclarator); + // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(NewVD, D); @@ -1471,9 +1469,9 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, return NewVD; } -ScopedDecl* +NamedDecl* Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, - QualType R, ScopedDecl *LastDeclarator, + QualType R, Decl *LastDeclarator, Decl* PrevDecl, bool IsFunctionDefinition, bool& InvalidDecl) { assert(R.getTypePtr()->isFunctionType()); @@ -1534,7 +1532,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // Create a FunctionDecl to satisfy the function definition parsing // code path. NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), - Name, R, SC, isInline, LastDeclarator, + Name, R, SC, isInline, // FIXME: Move to DeclGroup... D.getDeclSpec().getSourceRange().getBegin()); InvalidDecl = true; @@ -1559,15 +1557,15 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // This is a C++ method declaration. NewFD = CXXMethodDecl::Create(Context, cast<CXXRecordDecl>(DC), D.getIdentifierLoc(), Name, R, - (SC == FunctionDecl::Static), isInline, - LastDeclarator); + (SC == FunctionDecl::Static), isInline); } else { NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), - Name, R, SC, isInline, LastDeclarator, + Name, R, SC, isInline, // FIXME: Move to DeclGroup... D.getDeclSpec().getSourceRange().getBegin()); } + NewFD->setNextDeclarator(LastDeclarator); // Set the lexical context. If the declarator has a C++ // scope specifier, the lexical context will be different @@ -1639,7 +1637,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, Params.push_back(ParmVarDecl::Create(Context, DC, SourceLocation(), 0, *ArgType, VarDecl::None, - 0, 0)); + 0)); } NewFD->setParams(Context, &Params[0], Params.size()); @@ -2299,8 +2297,7 @@ void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit) { VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl); if (!VDecl) { - Diag(dyn_cast<ScopedDecl>(RealDecl)->getLocation(), - diag::err_illegal_initializer); + Diag(RealDecl->getLocation(), diag::err_illegal_initializer); RealDecl->setInvalidDecl(); return; } @@ -2442,13 +2439,13 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) { if (GroupDecl == 0) return 0; - ScopedDecl *Group = dyn_cast<ScopedDecl>(GroupDecl); - ScopedDecl *NewGroup = 0; + Decl *Group = dyn_cast<Decl>(GroupDecl); + Decl *NewGroup = 0; if (Group->getNextDeclarator() == 0) NewGroup = Group; else { // reverse the list. while (Group) { - ScopedDecl *Next = Group->getNextDeclarator(); + Decl *Next = Group->getNextDeclarator(); Group->setNextDeclarator(NewGroup); NewGroup = Group; Group = Next; @@ -2456,7 +2453,7 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) { } // Perform semantic analysis that depends on having fully processed both // the declarator and initializer. - for (ScopedDecl *ID = NewGroup; ID; ID = ID->getNextDeclarator()) { + for (Decl *ID = NewGroup; ID; ID = ID->getNextDeclarator()) { VarDecl *IDecl = dyn_cast<VarDecl>(ID); if (!IDecl) continue; @@ -2608,7 +2605,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { ParmVarDecl *New = ParmVarDecl::Create(Context, CurContext, D.getIdentifierLoc(), II, parmDeclType, StorageClass, - 0, 0); + 0); if (D.getInvalidType()) New->setInvalidDecl(); @@ -2756,8 +2753,8 @@ Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtArg BodyArg) { /// ImplicitlyDefineFunction - An undeclared identifier was used in a function /// call, forming a call to an implicitly defined function (per C99 6.5.1p2). -ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, - IdentifierInfo &II, Scope *S) { +NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, + IdentifierInfo &II, Scope *S) { // Extension in C99. Legal in C90, but warn about it. if (getLangOptions().C99) Diag(Loc, diag::ext_implicit_function_decl) << &II; @@ -2794,7 +2791,7 @@ ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, - ScopedDecl *LastDeclarator) { + Decl *LastDeclarator) { assert(D.getIdentifier() && "Wrong callback for declspec without declarator"); assert(!T.isNull() && "GetTypeForDeclarator() returned null type"); @@ -2802,7 +2799,8 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypedefDecl *NewTD = TypedefDecl::Create(Context, CurContext, D.getIdentifierLoc(), D.getIdentifier(), - T, LastDeclarator); + T); + NewTD->setNextDeclarator(LastDeclarator); if (D.getInvalidType()) NewTD->setInvalidDecl(); return NewTD; @@ -2833,7 +2831,7 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK, DeclContext *SearchDC = CurContext; DeclContext *DC = CurContext; DeclContext *LexicalContext = CurContext; - ScopedDecl *PrevDecl = 0; + Decl *PrevDecl = 0; bool Invalid = false; @@ -2860,9 +2858,8 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK, } else { // If this is a named struct, check to see if there was a previous forward // declaration or definition. - // Use ScopedDecl instead of TagDecl, because a NamespaceDecl may come up. - PrevDecl = dyn_cast_or_null<ScopedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S) - .getAsDecl()); + PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S) + .getAsDecl()); if (!getLangOptions().CPlusPlus && TK != TK_Reference) { // FIXME: This makes sure that we ignore the contexts associated @@ -3222,8 +3219,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagD, NewFD = FieldDecl::Create(Context, Record, Loc, II, T, BitWidth, D.getDeclSpec().getStorageClassSpec() == - DeclSpec::SCS_mutable, - /*PrevDecl=*/0); + DeclSpec::SCS_mutable); if (II) { Decl *PrevDecl @@ -3556,8 +3552,7 @@ Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl, EnumConstantDecl *New = EnumConstantDecl::Create(Context, TheEnumDecl, IdLoc, Id, EltTy, - Val, EnumVal, - LastEnumConst); + Val, EnumVal); // Register this decl in the current scope stack. PushOnScopeChains(New, S); @@ -3739,7 +3734,7 @@ Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr) { StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr.release()); - return FileScopeAsmDecl::Create(Context, Loc, AsmString); + return FileScopeAsmDecl::Create(Context, CurContext, Loc, AsmString); } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 95f920063d2..a5825408590 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -421,13 +421,6 @@ void Sema::ActOnBaseSpecifiers(DeclTy *ClassDecl, BaseTy **Bases, /// bitfield width if there is one and 'InitExpr' specifies the initializer if /// any. 'LastInGroup' is non-null for cases where one declspec has multiple /// declarators on it. -/// -/// FIXME: The note below is out-of-date. -/// NOTE: Because of CXXFieldDecl's inability to be chained like ScopedDecls, if -/// an instance field is declared, a new CXXFieldDecl is created but the method -/// does *not* return it; it returns LastInGroup instead. The other C++ members -/// (which are all ScopedDecls) are returned after appending them to -/// LastInGroup. Sema::DeclTy * Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, ExprTy *BW, ExprTy *InitExpr, @@ -876,7 +869,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor, ClassDecl->getLocation(), /*IdentifierInfo=*/0, - ArgType, VarDecl::None, 0, 0); + ArgType, VarDecl::None, 0); CopyConstructor->setParams(Context, &FromParam, 1); ClassDecl->addedConstructor(Context, CopyConstructor); @@ -945,7 +938,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { CXXMethodDecl::Create(Context, ClassDecl, ClassDecl->getLocation(), Name, Context.getFunctionType(RetType, &ArgType, 1, false, 0), - /*isStatic=*/false, /*isInline=*/true, 0); + /*isStatic=*/false, /*isInline=*/true); CopyAssignment->setAccess(AS_public); CopyAssignment->setImplicit(); @@ -953,7 +946,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment, ClassDecl->getLocation(), /*IdentifierInfo=*/0, - ArgType, VarDecl::None, 0, 0); + ArgType, VarDecl::None, 0); CopyAssignment->setParams(Context, &FromParam, 1); // Don't call addedAssignmentOperator. There is no way to distinguish an @@ -2211,7 +2204,7 @@ Sema::DeclTy *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) } VarDecl *ExDecl = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(), - II, ExDeclType, VarDecl::None, 0, Begin); + II, ExDeclType, VarDecl::None, Begin); if (D.getInvalidType() || Invalid) ExDecl->setInvalidDecl(); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index c4fccc7671a..26538876460 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -592,7 +592,7 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation( ObjCImplementationDecl* IMPDecl = ObjCImplementationDecl::Create(Context, CurContext, AtClassImplLoc, - ClassName, IDecl, SDecl); + IDecl, SDecl); // FIXME: PushOnScopeChains? CurContext->addDecl(IMPDecl); @@ -613,7 +613,7 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **ivars, unsigned numIvars, SourceLocation RBrace) { assert(ImpDecl && "missing implementation decl"); - ObjCInterfaceDecl* IDecl = getObjCInterfaceDecl(ImpDecl->getIdentifier()); + ObjCInterfaceDecl* IDecl = ImpDecl->getClassInterface(); if (!IDecl) return; /// Check case of non-existing @interface decl. @@ -1143,7 +1143,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, property->getIdentifier(), property->getType(), VarDecl::None, - 0, 0); + 0); SetterMethod->setMethodParams(&Argument, 1); CD->addDecl(SetterMethod); } else @@ -1258,7 +1258,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl, } if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) { IC->setLocEnd(AtEndLoc); - if (ObjCInterfaceDecl* IDecl = getObjCInterfaceDecl(IC->getIdentifier())) + if (ObjCInterfaceDecl* IDecl = IC->getClassInterface()) ImplMethodsVsClassMethods(IC, IDecl); } else if (ObjCCategoryImplDecl* CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) { @@ -1361,12 +1361,12 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( Param = ParmVarDecl::Create(Context, ObjCMethod, SourceLocation(/*FIXME*/), ArgNames[i], argType, - VarDecl::None, 0, 0); + VarDecl::None, 0); else Param = ParmVarWithOriginalTypeDecl::Create(Context, ObjCMethod, SourceLocation(/*FIXME*/), ArgNames[i], argType, originalArgType, - VarDecl::None, 0, 0); + VarDecl::None, 0); Param->setObjCDeclQualifier( CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier())); @@ -1544,7 +1544,7 @@ Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, FD.D.getIdentifier(), T, VarDecl::None, - 0, 0); + 0); SetterDecl->setMethodParams(&Argument, 1); PIDecl->setSetterMethodDecl(SetterDecl); } @@ -1634,7 +1634,7 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, ObjCImplementationDecl *IC = 0; ObjCCategoryImplDecl* CatImplClass = 0; if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) { - IDecl = getObjCInterfaceDecl(IC->getIdentifier()); + IDecl = IC->getClassInterface(); // We always synthesize an interface for an implementation // without an interface decl. So, IDecl is always non-zero. assert(IDecl && diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f6623b01dd4..5b6b00ceb16 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -383,11 +383,11 @@ DeclRefExpr *Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Lo /// getObjectForAnonymousRecordDecl - Retrieve the (unnamed) field or /// variable corresponding to the anonymous union or struct whose type /// is Record. -static ScopedDecl *getObjectForAnonymousRecordDecl(RecordDecl *Record) { +static Decl *getObjectForAnonymousRecordDecl(RecordDecl *Record) { assert(Record->isAnonymousStructOrUnion() && "Record must be an anonymous struct or union!"); - // FIXME: Once ScopedDecls are directly linked together, this will + // FIXME: Once Decls are directly linked together, this will // be an O(1) operation rather than a slow walk through DeclContext's // vector (which itself will be eliminated). DeclGroups might make // this even better. @@ -400,7 +400,7 @@ static ScopedDecl *getObjectForAnonymousRecordDecl(RecordDecl *Record) { // follows its type in the list of declarations. ++D; assert(D != DEnd && "Missing object for anonymous record"); - assert(!cast<ScopedDecl>(*D)->getDeclName() && "Decl should be unnamed"); + assert(!cast<NamedDecl>(*D)->getDeclName() && "Decl should be unnamed"); return *D; } } @@ -429,7 +429,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, DeclContext *Ctx = Field->getDeclContext(); do { RecordDecl *Record = cast<RecordDecl>(Ctx); - ScopedDecl *AnonObject = getObjectForAnonymousRecordDecl(Record); + Decl *AnonObject = getObjectForAnonymousRecordDecl(Record); if (FieldDecl *AnonField = dyn_cast<FieldDecl>(AnonObject)) AnonFields.push_back(AnonField); else { @@ -576,13 +576,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // well. IdentifierInfo *II = Name.getAsIdentifierInfo(); if (II && getCurMethodDecl()) { - ScopedDecl *SD = dyn_cast_or_null<ScopedDecl>(D); // There are two cases to handle here. 1) scoped lookup could have failed, // in which case we should look for an ivar. 2) scoped lookup could have // found a decl, but that decl is outside the current method (i.e. a global // variable). In these two cases, we do a lookup for an ivar with this // name, if the lookup suceeds, we replace it our current decl. - if (SD == 0 || SD->isDefinedOutsideFunctionOrMethod()) { + if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) { ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface(); if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II)) { // FIXME: This should use a new expr for a direct reference, don't turn @@ -597,7 +596,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, } } // Needed to implement property "super.method" notation. - if (SD == 0 && II->isStr("super")) { + if (D == 0 && II->isStr("super")) { QualType T = Context.getPointerType(Context.getObjCInterfaceType( getCurMethodDecl()->getClassInterface())); return Owned(new ObjCSuperExpr(Loc, T)); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 8958221ef55..1266d32d3f8 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -540,11 +540,11 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, QualType FnType = Context.getFunctionType(Return, &Argument, 1, false, 0); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, - FnType, FunctionDecl::None, false, 0, + FnType, FunctionDecl::None, false, SourceLocation()); Alloc->setImplicit(); ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(), - 0, Argument, VarDecl::None, 0, 0); + 0, Argument, VarDecl::None, 0); Alloc->setParams(Context, &Param, 1); // FIXME: Also add this declaration to the IdentifierResolver, but diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 5f8f3f5f6ad..7353bc37e4b 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -53,8 +53,7 @@ MaybeConstructOverloadSet(ASTContext &Context, // FIXME: We leak this overload set. Eventually, we want to // stop building the declarations for these overload sets, so // there will be nothing to leak. - Ovl = OverloadedFunctionDecl::Create(Context, - cast<ScopedDecl>(*I)->getDeclContext(), + Ovl = OverloadedFunctionDecl::Create(Context, (*I)->getDeclContext(), (*I)->getDeclName()); Ovl->addOverload(cast<FunctionDecl>(*I)); } @@ -491,7 +490,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name, // A static member, a nested type or an enumerator defined in // a base class T can unambiguously be found even if an object // has more than one base class subobject of type T. - ScopedDecl *FirstDecl = *Path->Decls.first; + Decl *FirstDecl = *Path->Decls.first; if (isa<VarDecl>(FirstDecl) || isa<TypeDecl>(FirstDecl) || isa<EnumConstantDecl>(FirstDecl)) @@ -610,10 +609,10 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name, Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types) << Name << LookupRange; - std::set<ScopedDecl *> DeclsPrinted; + std::set<Decl *> DeclsPrinted; for (BasePaths::paths_iterator Path = Paths->begin(), PathEnd = Paths->end(); Path != PathEnd; ++Path) { - ScopedDecl *D = *Path->Decls.first; + Decl *D = *Path->Decls.first; if (DeclsPrinted.insert(D).second) Diag(D->getLocation(), diag::note_ambiguous_member_found); } diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 61c22d43bef..9441ea5f166 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -2193,20 +2193,17 @@ void Sema::AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S, // operator names can only be ordinary identifiers. // Ignore member functions. - if (ScopedDecl *SD = dyn_cast<ScopedDecl>(*I)) { - if (SD->getDeclContext()->isRecord()) - continue; - } + if ((*I)->getDeclContext()->isRecord()) + continue; // We found something with this name. We're done. break; } - if (I != IEnd && isa<ScopedDecl>(*I)) { - ScopedDecl *FirstDecl = cast<ScopedDecl>(*I); + if (I != IEnd) { + Decl *FirstDecl = *I; for (; I != IEnd; ++I) { - ScopedDecl *SD = cast<ScopedDecl>(*I); - if (FirstDecl->getDeclContext() != SD->getDeclContext()) + if (FirstDecl->getDeclContext() != (*I)->getDeclContext()) break; if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 8b72514239e..9e15c21f5ac 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -43,14 +43,14 @@ Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclTy *decl, if (decl == 0) return StmtError(); - ScopedDecl *SD = cast<ScopedDecl>(static_cast<Decl *>(decl)); + Decl *D = static_cast<Decl *>(decl); // This is a temporary hack until we are always passing around // DeclGroupRefs. llvm::SmallVector<Decl*, 10> decls; - while (SD) { - ScopedDecl* d = SD; - SD = SD->getNextDeclarator(); + while (D) { + Decl* d = D; + D = D->getNextDeclarator(); d->setNextDeclarator(0); decls.push_back(d); } @@ -86,7 +86,7 @@ Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R, /*empty*/; if (i != NumElts) { - ScopedDecl *D = *cast<DeclStmt>(Elts[i])->decl_begin(); + Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin(); Diag(D->getLocation(), diag::ext_mixed_decls_code); } } @@ -633,7 +633,7 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, return StmtError(Diag((*DS->decl_begin())->getLocation(), diag::err_toomany_element_decls)); - ScopedDecl *D = DS->getSolitaryDecl(); + Decl *D = DS->getSolitaryDecl(); FirstType = cast<ValueDecl>(D)->getType(); // C99 6.8.5p3: The declaration part of a 'for' statement shall only // declare identifiers for objects having storage class 'auto' or |

