summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp34
-rw-r--r--clang/lib/AST/Builtins.cpp2
-rw-r--r--clang/lib/AST/DeclBase.cpp54
-rw-r--r--clang/lib/AST/DeclCXX.cpp4
-rw-r--r--clang/lib/AST/DeclObjC.cpp75
-rw-r--r--clang/lib/AST/ExprConstant.cpp4
-rw-r--r--clang/lib/AST/StmtPrinter.cpp6
7 files changed, 104 insertions, 75 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index aaec98830e5..e976ccf967a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -603,7 +603,7 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo,
}
void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI,
- llvm::SmallVectorImpl<FieldDecl*> &Fields) const {
+ llvm::SmallVectorImpl<FieldDecl*> &Fields) {
const ObjCInterfaceDecl *SuperClass = OI->getSuperClass();
if (SuperClass)
CollectObjCIvars(SuperClass, Fields);
@@ -614,8 +614,8 @@ void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI,
Fields.push_back(cast<FieldDecl>(IVDecl));
}
// look into properties.
- for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(),
- E = OI->prop_end(); I != E; ++I) {
+ for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(*this),
+ E = OI->prop_end(*this); I != E; ++I) {
if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
Fields.push_back(cast<FieldDecl>(IV));
}
@@ -648,7 +648,8 @@ const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) {
/// FIXME! Can do collection of ivars and adding to the record while
/// doing it.
for (unsigned i = 0, e = RecFields.size(); i != e; ++i) {
- RD->addDecl(FieldDecl::Create(*this, RD,
+ RD->addDecl(*this,
+ FieldDecl::Create(*this, RD,
RecFields[i]->getLocation(),
RecFields[i]->getIdentifier(),
RecFields[i]->getType(),
@@ -682,7 +683,7 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
// FIXME. Add actual count of synthesized ivars, instead of count
// of properties which is the upper bound, but is safe.
unsigned FieldCount =
- D->ivar_size() + std::distance(D->prop_begin(), D->prop_end());
+ D->ivar_size() + std::distance(D->prop_begin(*this), D->prop_end(*this));
if (ObjCInterfaceDecl *SD = D->getSuperClass()) {
FieldCount++;
const ASTRecordLayout &SL = getASTObjCInterfaceLayout(SD);
@@ -714,8 +715,8 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
}
// Also synthesized ivars
- for (ObjCInterfaceDecl::prop_iterator I = D->prop_begin(),
- E = D->prop_end(); I != E; ++I) {
+ for (ObjCInterfaceDecl::prop_iterator I = D->prop_begin(*this),
+ E = D->prop_end(*this); I != E; ++I) {
if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl())
NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
}
@@ -743,7 +744,8 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
Entry = NewEntry;
// FIXME: Avoid linear walk through the fields, if possible.
- NewEntry->InitializeLayout(std::distance(D->field_begin(), D->field_end()));
+ NewEntry->InitializeLayout(std::distance(D->field_begin(*this),
+ D->field_end(*this)));
bool IsUnion = D->isUnion();
unsigned StructPacking = 0;
@@ -757,8 +759,8 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
// Layout each field, for now, just sequentially, respecting alignment. In
// the future, this will need to be tweakable by targets.
unsigned FieldIdx = 0;
- for (RecordDecl::field_iterator Field = D->field_begin(),
- FieldEnd = D->field_end();
+ for (RecordDecl::field_iterator Field = D->field_begin(*this),
+ FieldEnd = D->field_end(*this);
Field != FieldEnd; (void)++Field, ++FieldIdx)
NewEntry->LayoutField(*Field, FieldIdx, IsUnion, StructPacking, *this);
@@ -1962,7 +1964,7 @@ QualType ASTContext::getCFConstantStringType() {
SourceLocation(), 0,
FieldTypes[i], /*BitWidth=*/0,
/*Mutable=*/false);
- CFConstantStringTypeDecl->addDecl(Field);
+ CFConstantStringTypeDecl->addDecl(*this, Field);
}
CFConstantStringTypeDecl->completeDefinition(*this);
@@ -1992,7 +1994,7 @@ QualType ASTContext::getObjCFastEnumerationStateType()
SourceLocation(), 0,
FieldTypes[i], /*BitWidth=*/0,
/*Mutable=*/false);
- ObjCFastEnumerationStateTypeDecl->addDecl(Field);
+ ObjCFastEnumerationStateTypeDecl->addDecl(*this, Field);
}
ObjCFastEnumerationStateTypeDecl->completeDefinition(*this);
@@ -2204,7 +2206,7 @@ void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const {
}
void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
- FieldDecl *Field) const {
+ FieldDecl *Field) {
// We follow the behavior of gcc, expanding structures which are
// directly pointed to, and expanding embedded structures. Note that
// these rules are sufficient to prevent recursive encoding of the
@@ -2228,7 +2230,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
bool ExpandStructures,
FieldDecl *FD,
bool OutermostType,
- bool EncodingProperty) const {
+ bool EncodingProperty) {
if (const BuiltinType *BT = T->getAsBuiltinType()) {
if (FD && FD->isBitField()) {
EncodeBitField(this, S, FD);
@@ -2409,8 +2411,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
}
if (ExpandStructures) {
S += '=';
- for (RecordDecl::field_iterator Field = RDecl->field_begin(),
- FieldEnd = RDecl->field_end();
+ for (RecordDecl::field_iterator Field = RDecl->field_begin(*this),
+ FieldEnd = RDecl->field_end(*this);
Field != FieldEnd; ++Field) {
if (FD) {
S += '"';
diff --git a/clang/lib/AST/Builtins.cpp b/clang/lib/AST/Builtins.cpp
index 7eab2679e80..97a40a4dd0b 100644
--- a/clang/lib/AST/Builtins.cpp
+++ b/clang/lib/AST/Builtins.cpp
@@ -201,7 +201,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
case 'P': {
IdentifierInfo *II = &Context.Idents.get("FILE");
DeclContext::lookup_result Lookup
- = Context.getTranslationUnitDecl()->lookup(II);
+ = Context.getTranslationUnitDecl()->lookup(Context, II);
if (Lookup.first != Lookup.second && isa<TypeDecl>(*Lookup.first)) {
Type = Context.getTypeDeclType(cast<TypeDecl>(*Lookup.first));
break;
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index f3cf7814e52..763998e852e 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -369,7 +369,7 @@ DeclContext::~DeclContext() {
}
void DeclContext::DestroyDecls(ASTContext &C) {
- for (decl_iterator D = decls_begin(); D != decls_end(); )
+ for (decl_iterator D = decls_begin(C); D != decls_end(C); )
(*D++)->Destroy(C);
}
@@ -439,7 +439,15 @@ DeclContext *DeclContext::getNextContext() {
}
}
-void DeclContext::addDecl(Decl *D) {
+DeclContext::decl_iterator DeclContext::decls_begin(ASTContext &Context) const {
+ return decl_iterator(FirstDecl);
+}
+
+DeclContext::decl_iterator DeclContext::decls_end(ASTContext &Context) const {
+ return decl_iterator();
+}
+
+void DeclContext::addDecl(ASTContext &Context, Decl *D) {
assert(D->getLexicalDeclContext() == this &&
"Decl inserted into wrong lexical context");
assert(!D->getNextDeclInContext() && D != LastDecl &&
@@ -453,40 +461,41 @@ void DeclContext::addDecl(Decl *D) {
}
if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
- ND->getDeclContext()->makeDeclVisibleInContext(ND);
+ ND->getDeclContext()->makeDeclVisibleInContext(Context, ND);
}
/// buildLookup - Build the lookup data structure with all of the
/// declarations in DCtx (and any other contexts linked to it or
/// transparent contexts nested within it).
-void DeclContext::buildLookup(DeclContext *DCtx) {
+void DeclContext::buildLookup(ASTContext &Context, DeclContext *DCtx) {
for (; DCtx; DCtx = DCtx->getNextContext()) {
- for (decl_iterator D = DCtx->decls_begin(), DEnd = DCtx->decls_end();
+ for (decl_iterator D = DCtx->decls_begin(Context),
+ DEnd = DCtx->decls_end(Context);
D != DEnd; ++D) {
// Insert this declaration into the lookup structure
if (NamedDecl *ND = dyn_cast<NamedDecl>(*D))
- makeDeclVisibleInContextImpl(ND);
+ makeDeclVisibleInContextImpl(Context, ND);
// If this declaration is itself a transparent declaration context,
// add its members (recursively).
if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D))
if (InnerCtx->isTransparentContext())
- buildLookup(InnerCtx->getPrimaryContext());
+ buildLookup(Context, InnerCtx->getPrimaryContext());
}
}
}
DeclContext::lookup_result
-DeclContext::lookup(DeclarationName Name) {
+DeclContext::lookup(ASTContext &Context, DeclarationName Name) {
DeclContext *PrimaryContext = getPrimaryContext();
if (PrimaryContext != this)
- return PrimaryContext->lookup(Name);
+ return PrimaryContext->lookup(Context, Name);
/// If there is no lookup data structure, build one now by walking
/// all of the linked DeclContexts (in declaration order!) and
/// inserting their values.
if (!LookupPtr) {
- buildLookup(this);
+ buildLookup(Context, this);
if (!LookupPtr)
return lookup_result(0, 0);
@@ -496,12 +505,12 @@ DeclContext::lookup(DeclarationName Name) {
StoredDeclsMap::iterator Pos = Map->find(Name);
if (Pos == Map->end())
return lookup_result(0, 0);
- return Pos->second.getLookupResult();
+ return Pos->second.getLookupResult(Context);
}
DeclContext::lookup_const_result
-DeclContext::lookup(DeclarationName Name) const {
- return const_cast<DeclContext*>(this)->lookup(Name);
+DeclContext::lookup(ASTContext &Context, DeclarationName Name) const {
+ return const_cast<DeclContext*>(this)->lookup(Context, Name);
}
DeclContext *DeclContext::getLookupContext() {
@@ -520,7 +529,7 @@ DeclContext *DeclContext::getEnclosingNamespaceContext() {
return Ctx->getPrimaryContext();
}
-void DeclContext::makeDeclVisibleInContext(NamedDecl *D) {
+void DeclContext::makeDeclVisibleInContext(ASTContext &Context, NamedDecl *D) {
// FIXME: This feels like a hack. Should DeclarationName support
// template-ids, or is there a better way to keep specializations
// from being visible?
@@ -529,7 +538,7 @@ void DeclContext::makeDeclVisibleInContext(NamedDecl *D) {
DeclContext *PrimaryContext = getPrimaryContext();
if (PrimaryContext != this) {
- PrimaryContext->makeDeclVisibleInContext(D);
+ PrimaryContext->makeDeclVisibleInContext(Context, D);
return;
}
@@ -537,15 +546,16 @@ void DeclContext::makeDeclVisibleInContext(NamedDecl *D) {
// into it. Otherwise, be lazy and don't build that structure until
// someone asks for it.
if (LookupPtr)
- makeDeclVisibleInContextImpl(D);
+ makeDeclVisibleInContextImpl(Context, D);
// If we are a transparent context, insert into our parent context,
// too. This operation is recursive.
if (isTransparentContext())
- getParent()->makeDeclVisibleInContext(D);
+ getParent()->makeDeclVisibleInContext(Context, D);
}
-void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
+void DeclContext::makeDeclVisibleInContextImpl(ASTContext &Context,
+ NamedDecl *D) {
// Skip unnamed declarations.
if (!D->getDeclName())
return;
@@ -570,7 +580,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
// If it is possible that this is a redeclaration, check to see if there is
// already a decl for which declarationReplaces returns true. If there is
// one, just replace it and return.
- if (DeclNameEntries.HandleRedeclaration(D))
+ if (DeclNameEntries.HandleRedeclaration(Context, D))
return;
// Put this declaration into the appropriate slot.
@@ -579,9 +589,9 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
/// this context.
-DeclContext::udir_iterator_range DeclContext::getUsingDirectives() const {
- lookup_const_result Result = lookup(UsingDirectiveDecl::getName());
+DeclContext::udir_iterator_range
+DeclContext::getUsingDirectives(ASTContext &Context) const {
+ lookup_const_result Result = lookup(Context, UsingDirectiveDecl::getName());
return udir_iterator_range(reinterpret_cast<udir_iterator>(Result.first),
reinterpret_cast<udir_iterator>(Result.second));
}
-
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 0fd83efa20a..ffc35fe1f74 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -70,7 +70,7 @@ bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const {
Context.getCanonicalType(ClassType));
unsigned TypeQuals;
DeclContext::lookup_const_iterator Con, ConEnd;
- for (llvm::tie(Con, ConEnd) = this->lookup(ConstructorName);
+ for (llvm::tie(Con, ConEnd) = this->lookup(Context, ConstructorName);
Con != ConEnd; ++Con) {
if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context, TypeQuals) &&
(TypeQuals & QualType::Const) != 0)
@@ -86,7 +86,7 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context) const {
DeclarationName OpName =Context.DeclarationNames.getCXXOperatorName(OO_Equal);
DeclContext::lookup_const_iterator Op, OpEnd;
- for (llvm::tie(Op, OpEnd) = this->lookup(OpName);
+ for (llvm::tie(Op, OpEnd) = this->lookup(Context, OpName);
Op != OpEnd; ++Op) {
// C++ [class.copy]p9:
// A user-declared copy assignment operator is a non-static non-template
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index cd1b979dcb0..4bc7cd461cb 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -43,7 +43,8 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
//===----------------------------------------------------------------------===//
// Get the local instance method declared in this interface.
-ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const {
+ObjCMethodDecl *
+ObjCContainerDecl::getInstanceMethod(ASTContext &Context, Selector Sel) const {
// Since instance & class methods can have the same name, the loop below
// ensures we get the correct method.
//
@@ -53,7 +54,7 @@ ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const {
// @end
//
lookup_const_iterator Meth, MethEnd;
- for (llvm::tie(Meth, MethEnd) = lookup(Sel);
+ for (llvm::tie(Meth, MethEnd) = lookup(Context, Sel);
Meth != MethEnd; ++Meth) {
ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
if (MD && MD->isInstanceMethod())
@@ -63,7 +64,8 @@ ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const {
}
// Get the local class method declared in this interface.
-ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const {
+ObjCMethodDecl *
+ObjCContainerDecl::getClassMethod(ASTContext &Context, Selector Sel) const {
// Since instance & class methods can have the same name, the loop below
// ensures we get the correct method.
//
@@ -73,7 +75,7 @@ ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const {
// @end
//
lookup_const_iterator Meth, MethEnd;
- for (llvm::tie(Meth, MethEnd) = lookup(Sel);
+ for (llvm::tie(Meth, MethEnd) = lookup(Context, Sel);
Meth != MethEnd; ++Meth) {
ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
if (MD && MD->isClassMethod())
@@ -87,8 +89,10 @@ ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const {
/// FIXME: Convert to DeclContext lookup...
///
ObjCPropertyDecl *
-ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
- for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I)
+ObjCContainerDecl::FindPropertyDeclaration(ASTContext &Context,
+ IdentifierInfo *PropertyId) const {
+ for (prop_iterator I = prop_begin(Context), E = prop_end(Context);
+ I != E; ++I)
if ((*I)->getIdentifier() == PropertyId)
return *I;
@@ -96,7 +100,8 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
if (PID) {
for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
E = PID->protocol_end(); I != E; ++I)
- if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
+ if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context,
+ PropertyId))
return P;
}
@@ -104,22 +109,26 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
// Look through categories.
for (ObjCCategoryDecl *Category = OID->getCategoryList();
Category; Category = Category->getNextClassCategory()) {
- if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(PropertyId))
+ if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(Context,
+ PropertyId))
return P;
}
// Look through protocols.
for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(),
E = OID->protocol_end(); I != E; ++I) {
- if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
+ if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context,
+ PropertyId))
return P;
}
if (OID->getSuperClass())
- return OID->getSuperClass()->FindPropertyDeclaration(PropertyId);
+ return OID->getSuperClass()->FindPropertyDeclaration(Context,
+ PropertyId);
} else if (const ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(this)) {
// Look through protocols.
for (ObjCInterfaceDecl::protocol_iterator I = OCD->protocol_begin(),
E = OCD->protocol_end(); I != E; ++I) {
- if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
+ if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context,
+ PropertyId))
return P;
}
}
@@ -127,7 +136,7 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
}
ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
- IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) {
+ ASTContext &Context, IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) {
ObjCInterfaceDecl* ClassDecl = this;
while (ClassDecl != NULL) {
for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end();
@@ -138,8 +147,8 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
}
}
// look into properties.
- for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
- E = ClassDecl->prop_end(); I != E; ++I) {
+ for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(Context),
+ E = ClassDecl->prop_end(Context); I != E; ++I) {
ObjCPropertyDecl *PDecl = (*I);
if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
if (IV->getIdentifier() == ID) {
@@ -154,12 +163,13 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
/// lookupInstanceMethod - This method returns an instance method by looking in
/// the class, its categories, and its super classes (using a linear search).
-ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
+ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(ASTContext &Context,
+ Selector Sel) {
ObjCInterfaceDecl* ClassDecl = this;
ObjCMethodDecl *MethodDecl = 0;
while (ClassDecl != NULL) {
- if ((MethodDecl = ClassDecl->getInstanceMethod(Sel)))
+ if ((MethodDecl = ClassDecl->getInstanceMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - look through protocols.
@@ -167,13 +177,13 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
ClassDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - now look through categories.
ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
while (CatDecl) {
- if ((MethodDecl = CatDecl->getInstanceMethod(Sel)))
+ if ((MethodDecl = CatDecl->getInstanceMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - look through protocols.
@@ -181,7 +191,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
CatDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel)))
return MethodDecl;
CatDecl = CatDecl->getNextClassCategory();
}
@@ -192,24 +202,25 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
// lookupClassMethod - This method returns a class method by looking in the
// class, its categories, and its super classes (using a linear search).
-ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) {
+ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(ASTContext &Context,
+ Selector Sel) {
ObjCInterfaceDecl* ClassDecl = this;
ObjCMethodDecl *MethodDecl = 0;
while (ClassDecl != NULL) {
- if ((MethodDecl = ClassDecl->getClassMethod(Sel)))
+ if ((MethodDecl = ClassDecl->getClassMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - look through protocols.
for (ObjCInterfaceDecl::protocol_iterator I = ClassDecl->protocol_begin(),
E = ClassDecl->protocol_end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - now look through categories.
ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
while (CatDecl) {
- if ((MethodDecl = CatDecl->getClassMethod(Sel)))
+ if ((MethodDecl = CatDecl->getClassMethod(Context, Sel)))
return MethodDecl;
// Didn't find one yet - look through protocols.
@@ -217,7 +228,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) {
CatDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel)))
return MethodDecl;
CatDecl = CatDecl->getNextClassCategory();
}
@@ -372,7 +383,7 @@ FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context,
const RecordDecl *RecordForDecl = Context.addRecordToClass(this);
assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class");
DeclContext::lookup_const_result Lookup =
- RecordForDecl->lookup(IVar->getDeclName());
+ RecordForDecl->lookup(Context, IVar->getDeclName());
assert((Lookup.first != Lookup.second) && "field decl not found");
return cast<FieldDecl>(*Lookup.first);
}
@@ -434,28 +445,30 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
// lookupInstanceMethod - Lookup a instance method in the protocol and protocols
// it inherited.
-ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(Selector Sel) {
+ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(ASTContext &Context,
+ Selector Sel) {
ObjCMethodDecl *MethodDecl = NULL;
- if ((MethodDecl = getInstanceMethod(Sel)))
+ if ((MethodDecl = getInstanceMethod(Context, Sel)))
return MethodDecl;
for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel)))
return MethodDecl;
return NULL;
}
// lookupInstanceMethod - Lookup a class method in the protocol and protocols
// it inherited.
-ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) {
+ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(ASTContext &Context,
+ Selector Sel) {
ObjCMethodDecl *MethodDecl = NULL;
- if ((MethodDecl = getClassMethod(Sel)))
+ if ((MethodDecl = getClassMethod(Context, Sel)))
return MethodDecl;
for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel)))
return MethodDecl;
return NULL;
}
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 645811319a4..643e066c7b4 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -213,8 +213,8 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
// FIXME: This is linear time.
unsigned i = 0;
- for (RecordDecl::field_iterator Field = RD->field_begin(),
- FieldEnd = RD->field_end();
+ for (RecordDecl::field_iterator Field = RD->field_begin(Info.Ctx),
+ FieldEnd = RD->field_end(Info.Ctx);
Field != FieldEnd; (void)++Field, ++i) {
if (*Field == FD)
break;
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index cd0e8822a8a..b55bddfed09 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -148,7 +148,11 @@ void StmtPrinter::PrintRawDecl(Decl *D) {
if (RecordDecl *RD = dyn_cast<RecordDecl>(TD)) {
OS << "{\n";
IndentLevel += 1;
- for (RecordDecl::field_iterator i = RD->field_begin(); i != RD->field_end(); ++i) {
+ // FIXME: The context passed to field_begin/field_end should
+ // never be NULL!
+ ASTContext *Context = 0;
+ for (RecordDecl::field_iterator i = RD->field_begin(*Context);
+ i != RD->field_end(*Context); ++i) {
PrintFieldDecl(*i);
IndentLevel -= 1;
}
OpenPOWER on IntegriCloud