// Add the built-in ObjC types.
t = cast<TypedefType>(Context.getObjCIdType().getTypePtr());
- IdResolver.AddDecl(t->getDecl(), S);
- TUScope->AddDecl(t->getDecl());
+ PushOnScopeChains(t->getDecl(), TUScope);
t = cast<TypedefType>(Context.getObjCClassType().getTypePtr());
- IdResolver.AddDecl(t->getDecl(), S);
- TUScope->AddDecl(t->getDecl());
+ PushOnScopeChains(t->getDecl(), TUScope);
ObjCInterfaceType *it = cast<ObjCInterfaceType>(Context.getObjCProtoType());
ObjCInterfaceDecl *IDecl = it->getDecl();
- IdResolver.AddDecl(IDecl, S);
- TUScope->AddDecl(IDecl);
+ PushOnScopeChains(IDecl, TUScope);
// Synthesize "typedef struct objc_selector *SEL;"
RecordDecl *SelTag = RecordDecl::Create(Context, Decl::Struct, CurContext,
SourceLocation(),
&Context.Idents.get("objc_selector"),
0);
- IdResolver.AddDecl(SelTag, S);
- TUScope->AddDecl(SelTag);
+ PushOnScopeChains(SelTag, TUScope);
QualType SelT = Context.getPointerType(Context.getTagDeclType(SelTag));
TypedefDecl *SelTypedef = TypedefDecl::Create(Context, CurContext,
SourceLocation(),
&Context.Idents.get("SEL"),
SelT, 0);
- IdResolver.AddDecl(SelTypedef, S);
- TUScope->AddDecl(SelTypedef);
+ PushOnScopeChains(SelTypedef, TUScope);
Context.setObjCSelType(SelTypedef);
}
CurContext = CurContext->getParent();
}
+/// Add this decl to the scope shadowed decl chains.
+void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) {
+ IdResolver.AddDecl(D, S);
+ S->AddDecl(D);
+}
+
void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
if (S->decl_empty()) return;
assert((S->getFlags() & Scope::DeclScope) &&"Scope shouldn't contain decls!");
SourceLocation IdLoc, QualType Type) {
ParmVarDecl *New = ParmVarDecl::Create(Context, CurContext, IdLoc, Id, Type,
VarDecl::None, 0, 0);
- if (Id) {
- IdResolver.AddDecl(New, S);
- S->AddDecl(New);
- }
+ if (Id)
+ PushOnScopeChains(New, S);
return New;
}
}
// If this has an identifier, add it to the scope stack.
- if (II) {
- IdResolver.AddDecl(New, S);
- S->AddDecl(New);
- }
+ if (II)
+ PushOnScopeChains(New, S);
// If any semantic error occurred, mark the decl as invalid.
if (D.getInvalidType() || InvalidDecl)
New->setInvalidDecl();
if (D.getInvalidType())
New->setInvalidDecl();
- if (II) {
- IdResolver.AddDecl(New, S);
- S->AddDecl(New);
- }
+ if (II)
+ PushOnScopeChains(New, S);
HandleDeclAttributes(New, D.getAttributes(), 0);
return New;
for (unsigned p = 0, NumParams = FD->getNumParams(); p < NumParams; ++p) {
ParmVarDecl *Param = FD->getParamDecl(p);
// If this has an identifier, add it to the scope stack.
- if (Param->getIdentifier()) {
- IdResolver.AddDecl(Param, FnBodyScope);
- FnBodyScope->AddDecl(Param);
- }
+ if (Param->getIdentifier())
+ PushOnScopeChains(Param, FnBodyScope);
}
return FD;
S = S->getParent();
// Add it to the decl chain.
- IdResolver.AddDecl(New, S);
- S->AddDecl(New);
+ PushOnScopeChains(New, S);
}
HandleDeclAttributes(New, Attr, 0);
LastEnumConst);
// Register this decl in the current scope stack.
- IdResolver.AddDecl(New, S);
- S->AddDecl(New);
+ PushOnScopeChains(New, S);
return New;
}