aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-09 21:40:53 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-09 21:40:53 +0000
commit6ab3524f72a6e64aa04973fa9433b5559abb3525 (patch)
tree2af99c2d010cb635e630a31dc34512563db09f5c
parentd296836d0d5570fe634cfe65580dc57fdd2bc8f1 (diff)
Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h10
-rw-r--r--include/clang/AST/Decl.h27
-rw-r--r--include/clang/AST/DeclBase.h38
-rw-r--r--include/clang/AST/DeclContextInternals.h4
-rw-r--r--include/clang/AST/DeclObjC.h62
-rw-r--r--include/clang/AST/DeclarationName.h7
-rw-r--r--lib/AST/ASTContext.cpp34
-rw-r--r--lib/AST/Builtins.cpp2
-rw-r--r--lib/AST/DeclBase.cpp54
-rw-r--r--lib/AST/DeclCXX.cpp4
-rw-r--r--lib/AST/DeclObjC.cpp75
-rw-r--r--lib/AST/ExprConstant.cpp4
-rw-r--r--lib/AST/StmtPrinter.cpp6
-rw-r--r--lib/Analysis/CFRefCount.cpp4
-rw-r--r--lib/Analysis/CheckObjCInstMethSignature.cpp4
-rw-r--r--lib/Analysis/RegionStore.cpp6
-rw-r--r--lib/CodeGen/CGCall.cpp46
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp9
-rw-r--r--lib/CodeGen/CGExprAgg.cpp12
-rw-r--r--lib/CodeGen/CGExprConstant.cpp8
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp9
-rw-r--r--lib/CodeGen/CGObjCMac.cpp93
-rw-r--r--lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp10
-rw-r--r--lib/Sema/SemaDecl.cpp20
-rw-r--r--lib/Sema/SemaDeclAttr.cpp4
-rw-r--r--lib/Sema/SemaDeclCXX.cpp41
-rw-r--r--lib/Sema/SemaDeclObjC.cpp124
-rw-r--r--lib/Sema/SemaExpr.cpp58
-rw-r--r--lib/Sema/SemaExprCXX.cpp6
-rw-r--r--lib/Sema/SemaExprObjC.cpp20
-rw-r--r--lib/Sema/SemaInherit.cpp2
-rw-r--r--lib/Sema/SemaInit.cpp27
-rw-r--r--lib/Sema/SemaLookup.cpp23
-rw-r--r--lib/Sema/SemaOverload.cpp10
-rw-r--r--lib/Sema/SemaTemplate.cpp2
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp5
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp24
-rw-r--r--tools/clang-cc/ASTConsumers.cpp55
-rw-r--r--tools/clang-cc/ASTConsumers.h2
-rw-r--r--tools/clang-cc/AnalysisConsumer.cpp3
-rw-r--r--tools/clang-cc/RewriteBlocks.cpp40
-rw-r--r--tools/clang-cc/RewriteObjC.cpp92
-rw-r--r--tools/clang-cc/SerializationTest.cpp6
-rw-r--r--tools/clang-cc/clang-cc.cpp6
45 files changed, 630 insertions, 476 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 77fa994e74..873806ffd2 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -141,7 +141,7 @@ class ASTContext {
bool FreeMemory;
llvm::MallocAllocator MallocAlloc;
llvm::BumpPtrAllocator BumpAlloc;
-public:
+public:
TargetInfo &Target;
IdentifierTable &Idents;
SelectorTable &Selectors;
@@ -189,7 +189,7 @@ public:
bool FreeMemory = true, unsigned size_reserve=0);
~ASTContext();
-
+
void PrintStats() const;
const std::vector<Type*>& getTypes() const { return Types; }
@@ -364,7 +364,7 @@ public:
/// given type into \arg S. If \arg NameFields is specified then
/// record field names are also encoded.
void getObjCEncodingForType(QualType t, std::string &S,
- FieldDecl *Field=NULL) const;
+ FieldDecl *Field=NULL);
void getLegacyIntegralTypeEncoding(QualType &t) const;
@@ -492,7 +492,7 @@ public:
const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D);
const RecordDecl *addRecordToClass(const ObjCInterfaceDecl *D);
void CollectObjCIvars(const ObjCInterfaceDecl *OI,
- llvm::SmallVectorImpl<FieldDecl*> &Fields) const;
+ llvm::SmallVectorImpl<FieldDecl*> &Fields);
const FieldDecl *getFieldDecl(const ObjCIvarRefExpr *MRef) {
llvm::DenseMap<const ObjCIvarRefExpr *, const FieldDecl*>::iterator I
= ASTFieldForIvarRef.find(MRef);
@@ -718,7 +718,7 @@ private:
bool ExpandStructures,
FieldDecl *Field,
bool OutermostType = false,
- bool EncodingProperty = false) const;
+ bool EncodingProperty = false);
};
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index a2ad29015e..f954934898 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -85,6 +85,9 @@ public:
/// which may be a special name.
DeclarationName getDeclName() const { return Name; }
+ /// \brief Set the name of this declaration.
+ void setDeclName(DeclarationName N) { Name = N; }
+
/// getNameAsString - Get a human-readable name for the declaration, even if
/// it is one of the special kinds of names (C++ constructor, Objective-C
/// selector, etc). Creating this name requires expensive string
@@ -257,6 +260,9 @@ public:
void setStorageClass(StorageClass SC) { SClass = SC; }
SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
+ void setTypeSpecStartLoc(SourceLocation SL) {
+ TypeSpecStartLoc = SL;
+ }
const Expr *getInit() const { return (const Expr*) Init; }
Expr *getInit() { return (Expr*) Init; }
@@ -872,6 +878,7 @@ protected:
public:
// Low-level accessor
Type *getTypeForDecl() const { return TypeForDecl; }
+ void setTypeForDecl(Type *TD) { TypeForDecl = TD; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
@@ -1041,12 +1048,12 @@ public:
// enumeration.
typedef specific_decl_iterator<EnumConstantDecl> enumerator_iterator;
- enumerator_iterator enumerator_begin() const {
- return enumerator_iterator(this->decls_begin());
+ enumerator_iterator enumerator_begin(ASTContext &Context) const {
+ return enumerator_iterator(this->decls_begin(Context));
}
- enumerator_iterator enumerator_end() const {
- return enumerator_iterator(this->decls_end());
+ enumerator_iterator enumerator_end(ASTContext &Context) const {
+ return enumerator_iterator(this->decls_end(Context));
}
/// getIntegerType - Return the integer type this enum decl corresponds to.
@@ -1146,16 +1153,18 @@ public:
// data members, functions, constructors, destructors, etc.
typedef specific_decl_iterator<FieldDecl> field_iterator;
- field_iterator field_begin() const {
- return field_iterator(decls_begin());
+ field_iterator field_begin(ASTContext &Context) const {
+ return field_iterator(decls_begin(Context));
}
- field_iterator field_end() const {
- return field_iterator(decls_end());
+ field_iterator field_end(ASTContext &Context) const {
+ return field_iterator(decls_end(Context));
}
// field_empty - Whether there are any fields (non-static data
// members) in this record.
- bool field_empty() const { return field_begin() == field_end(); }
+ bool field_empty(ASTContext &Context) const {
+ return field_begin(Context) == field_end(Context);
+ }
/// completeDefinition - Notes that the definition of this type is
/// now complete.
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 4675136d49..3244c63146 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -1,4 +1,4 @@
-//===-- DeclBase.h - Base Classes for representing declarations *- C++ -*-===//
+//===-- DeclBase.h - Base Classes for representing declarations -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -178,10 +178,6 @@ protected:
virtual ~Decl();
- /// setDeclContext - Set both the semantic and lexical DeclContext
- /// to DC.
- void setDeclContext(DeclContext *DC);
-
public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
@@ -229,7 +225,7 @@ public:
/// setInvalidDecl - Indicates the Decl had a semantic error. This
/// allows for graceful error recovery.
- void setInvalidDecl() { InvalidDecl = 1; }
+ void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; }
bool isInvalidDecl() const { return (bool) InvalidDecl; }
/// isImplicit - Indicates whether the declaration was implicitly
@@ -266,6 +262,10 @@ public:
return const_cast<Decl*>(this)->getLexicalDeclContext();
}
+ /// setDeclContext - Set both the semantic and lexical DeclContext
+ /// to DC.
+ void setDeclContext(DeclContext *DC);
+
void setLexicalDeclContext(DeclContext *DC);
// isDefinedOutsideFunctionOrMethod - This predicate returns true if this
@@ -535,8 +535,8 @@ public:
/// decls_begin/decls_end - Iterate over the declarations stored in
/// this context.
- decl_iterator decls_begin() const { return decl_iterator(FirstDecl); }
- decl_iterator decls_end() const { return decl_iterator(); }
+ decl_iterator decls_begin(ASTContext &Context) const;
+ decl_iterator decls_end(ASTContext &Context) const;
/// specific_decl_iterator - Iterates over a subrange of
/// declarations stored in a DeclContext, providing only those that
@@ -692,7 +692,7 @@ public:
///
/// If D is also a NamedDecl, it will be made visible within its
/// semantic context via makeDeclVisibleInContext.
- void addDecl(Decl *D);
+ void addDecl(ASTContext &Context, Decl *D);
/// lookup_iterator - An iterator that provides access to the results
/// of looking up a name within this context.
@@ -711,8 +711,8 @@ public:
/// the declarations with this name, with object, function, member,
/// and enumerator names preceding any tag name. Note that this
/// routine will not look into parent contexts.
- lookup_result lookup(DeclarationName Name);
- lookup_const_result lookup(DeclarationName Name) const;
+ lookup_result lookup(ASTContext &Context, DeclarationName Name);
+ lookup_const_result lookup(ASTContext &Context, DeclarationName Name) const;
/// @brief Makes a declaration visible within this context.
///
@@ -728,7 +728,7 @@ public:
/// visible from this context, as determined by
/// NamedDecl::declarationReplaces, the previous declaration will be
/// replaced with D.
- void makeDeclVisibleInContext(NamedDecl *D);
+ void makeDeclVisibleInContext(ASTContext &Context, NamedDecl *D);
/// udir_iterator - Iterates through the using-directives stored
/// within this context.
@@ -736,14 +736,14 @@ public:
typedef std::pair<udir_iterator, udir_iterator> udir_iterator_range;
- udir_iterator_range getUsingDirectives() const;
+ udir_iterator_range getUsingDirectives(ASTContext &Context) const;
- udir_iterator using_directives_begin() const {
- return getUsingDirectives().first;
+ udir_iterator using_directives_begin(ASTContext &Context) const {
+ return getUsingDirectives(Context).first;
}
- udir_iterator using_directives_end() const {
- return getUsingDirectives().second;
+ udir_iterator using_directives_end(ASTContext &Context) const {
+ return getUsingDirectives(Context).second;
}
// Low-level accessors
@@ -758,8 +758,8 @@ public:
#include "clang/AST/DeclNodes.def"
private:
- void buildLookup(DeclContext *DCtx);
- void makeDeclVisibleInContextImpl(NamedDecl *D);
+ void buildLookup(ASTContext &Context, DeclContext *DCtx);
+ void makeDeclVisibleInContextImpl(ASTContext &Context, NamedDecl *D);
void EmitOutRec(llvm::Serializer& S) const;
void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
diff --git a/include/clang/AST/DeclContextInternals.h b/include/clang/AST/DeclContextInternals.h
index 74e83f17e6..9341a7de37 100644
--- a/include/clang/AST/DeclContextInternals.h
+++ b/include/clang/AST/DeclContextInternals.h
@@ -64,7 +64,7 @@ public:
/// getLookupResult - Return an array of all the decls that this list
/// represents.
- DeclContext::lookup_result getLookupResult() {
+ DeclContext::lookup_result getLookupResult(ASTContext &Context) {
// If we have a single inline unit, return it.
if (isInline()) {
assert(!isNull() && "Empty list isn't allowed");
@@ -81,7 +81,7 @@ public:
/// HandleRedeclaration - If this is a redeclaration of an existing decl,
/// replace the old one with D and return true. Otherwise return false.
- bool HandleRedeclaration(NamedDecl *D) {
+ bool HandleRedeclaration(ASTContext &Context, NamedDecl *D) {
// Most decls only have one entry in their list, special case it.
if (isInline()) {
if (!D->declarationReplaces(Data.get<NamedDecl*>()))
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 9acce0f541..62cd01ee8b 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -256,50 +256,54 @@ public:
// Iterator access to properties.
typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
- prop_iterator prop_begin() const {
- return prop_iterator(decls_begin());
+ prop_iterator prop_begin(ASTContext &Context) const {
+ return prop_iterator(decls_begin(Context));
}
- prop_iterator prop_end() const {
- return prop_iterator(decls_end());
+ prop_iterator prop_end(ASTContext &Context) const {
+ return prop_iterator(decls_end(Context));
}
// Iterator access to instance/class methods.
typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
- method_iterator meth_begin() const {
- return method_iterator(decls_begin());
+ method_iterator meth_begin(ASTContext &Context) const {
+ return method_iterator(decls_begin(Context));
}
- method_iterator meth_end() const {
- return method_iterator(decls_end());
+ method_iterator meth_end(ASTContext &Context) const {
+ return method_iterator(decls_end(Context));
}
typedef filtered_decl_iterator<ObjCMethodDecl,
&ObjCMethodDecl::isInstanceMethod>
instmeth_iterator;
- instmeth_iterator instmeth_begin() const {
- return instmeth_iterator(decls_begin());
+ instmeth_iterator instmeth_begin(ASTContext &Context) const {
+ return instmeth_iterator(decls_begin(Context));
}
- instmeth_iterator instmeth_end() const {
- return instmeth_iterator(decls_end());
+ instmeth_iterator instmeth_end(ASTContext &Context) const {
+ return instmeth_iterator(decls_end(Context));
}
typedef filtered_decl_iterator<ObjCMethodDecl,
&ObjCMethodDecl::isClassMethod>
classmeth_iterator;
- classmeth_iterator classmeth_begin() const {
- return classmeth_iterator(decls_begin());
+ classmeth_iterator classmeth_begin(ASTContext &Context) const {
+ return classmeth_iterator(decls_begin(Context));
}
- classmeth_iterator classmeth_end() const {
- return classmeth_iterator(decls_end());
+ classmeth_iterator classmeth_end(ASTContext &Context) const {
+ return classmeth_iterator(decls_end(Context));
}
// Get the local instance/class method declared in this interface.
- ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
- ObjCMethodDecl *getClassMethod(Selector Sel) const;
- ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
- return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
+ ObjCMethodDecl *getInstanceMethod(ASTContext &Context, Selector Sel) const;
+ ObjCMethodDecl *getClassMethod(ASTContext &Context, Selector Sel) const;
+
+ ObjCMethodDecl *
+ getMethod(ASTContext &Context, Selector Sel, bool isInstance) const {
+ return isInstance ? getInstanceMethod(Context, Sel)
+ : getClassMethod(Context, Sel);
}
- ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
+ ObjCPropertyDecl *FindPropertyDeclaration(ASTContext &Context,
+ IdentifierInfo *PropertyId) const;
// Marks the end of the container.
SourceLocation getAtEndLoc() const { return AtEndLoc; }
@@ -440,17 +444,19 @@ public:
return false;
}
- ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
+ ObjCIvarDecl *lookupInstanceVariable(ASTContext &Context,
+ IdentifierInfo *IVarName,
ObjCInterfaceDecl *&ClassDeclared);
- ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
+ ObjCIvarDecl *lookupInstanceVariable(ASTContext &Context,
+ IdentifierInfo *IVarName) {
ObjCInterfaceDecl *ClassDeclared;
- return lookupInstanceVariable(IVarName, ClassDeclared);
+ return lookupInstanceVariable(Context, IVarName, ClassDeclared);
}
// Lookup a method. First, we search locally. If a method isn't
// found, we search referenced protocols and class categories.
- ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
- ObjCMethodDecl *lookupClassMethod(Selector Sel);
+ ObjCMethodDecl *lookupInstanceMethod(ASTContext &Context, Selector Sel);
+ ObjCMethodDecl *lookupClassMethod(ASTContext &Context, Selector Sel);
// Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'interface
@@ -605,8 +611,8 @@ public:
// Lookup a method. First, we search locally. If a method isn't
// found, we search referenced protocols and class categories.
- ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
- ObjCMethodDecl *lookupClassMethod(Selector Sel);
+ ObjCMethodDecl *lookupInstanceMethod(ASTContext &Context, Selector Sel);
+ ObjCMethodDecl *lookupClassMethod(ASTContext &Context, Selector Sel);
bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; }
diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h
index a3c1e1faa6..729045910b 100644
--- a/include/clang/AST/DeclarationName.h
+++ b/include/clang/AST/DeclarationName.h
@@ -133,11 +133,7 @@ private:
/// Construct a declaration name from a raw pointer.
DeclarationName(uintptr_t Ptr) : Ptr(Ptr) { }
- /// getUsingDirectiveName - Return name for all using-directives.
- static DeclarationName getUsingDirectiveName();
-
friend class DeclarationNameTable;
- friend class UsingDirectiveDecl;
friend class NamedDecl;
/// getFETokenInfoAsVoid - Retrieves the front end-specified pointer
@@ -157,6 +153,9 @@ public:
// Construct a declaration name from an Objective-C selector.
DeclarationName(Selector Sel);
+ /// getUsingDirectiveName - Return name for all using-directives.
+ static DeclarationName getUsingDirectiveName();
+
// operator bool() - Evaluates true when this declaration name is
// non-empty.
operator bool() const {
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index aaec98830e..e976ccf967 100644
--- a/lib/AST/ASTContext.cpp
+++ b/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/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp
index 7eab2679e8..97a40a4dd0 100644
--- a/lib/AST/Builtins.cpp
+++ b/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/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index f3cf7814e5..763998e852 100644
--- a/lib/AST/DeclBase.cpp
+++ b/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);