Propagate the ASTContext to various AST traversal and lookup functions.
authorDouglas Gregor <dgregor@apple.com>
Thu, 9 Apr 2009 21:40:53 +0000 (21:40 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 9 Apr 2009 21:40:53 +0000 (21:40 +0000)
No functionality change (really).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8

45 files changed:
include/clang/AST/ASTContext.h
include/clang/AST/Decl.h
include/clang/AST/DeclBase.h
include/clang/AST/DeclContextInternals.h
include/clang/AST/DeclObjC.h
include/clang/AST/DeclarationName.h
lib/AST/ASTContext.cpp
lib/AST/Builtins.cpp
lib/AST/DeclBase.cpp
lib/AST/DeclCXX.cpp
lib/AST/DeclObjC.cpp
lib/AST/ExprConstant.cpp
lib/AST/StmtPrinter.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/CheckObjCInstMethSignature.cpp
lib/Analysis/RegionStore.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenTypes.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaExprObjC.cpp
lib/Sema/SemaInherit.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
tools/clang-cc/ASTConsumers.cpp
tools/clang-cc/ASTConsumers.h
tools/clang-cc/AnalysisConsumer.cpp
tools/clang-cc/RewriteBlocks.cpp
tools/clang-cc/RewriteObjC.cpp
tools/clang-cc/SerializationTest.cpp
tools/clang-cc/clang-cc.cpp

index 77fa994e740813d1f2d9519da50f4060a4a22a05..873806ffd2d0add5d63141032429c4fd2b0f8b66 100644 (file)
@@ -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);
                                   
 };
 
index a2ad29015e0b6d2efdee2f6fe5806d57a63d0586..f954934898e385fdfebbb9c6d458c271e8e63746 100644 (file)
@@ -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.
index 4675136d49607ca57da3a0400a81c789057a754f..3244c63146610f8b13e7e843ec58dc1729683ee5 100644 (file)
@@ -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);
index 74e83f17e65e43b8d5c7b158a8c1ee6d2a964b91..9341a7de3703ef8f63f91e9f8db33bdbbe6acc03 100644 (file)
@@ -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*>()))
index 9acce0f5411acb64ec1bb302b459cd6877f3a1b6..62cd01ee8b5a8d48e494e203686b24916fc57c67 100644 (file)
@@ -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; }
index a3c1e1faa602df1c989c2d1b7ca997f09ef0f6db..729045910b54538d7f699d2501c0571324a3ae0a 100644 (file)
@@ -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 { 
index aaec98830e5d4a3a32d2e244ee6c883f207086b3..e976ccf967ae15d7af51a4c9040b06163a6b99ab 100644 (file)
@@ -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 += '"';
index 7eab2679e800e92aa7d6091d0090e59dea0161e1..97a40a4dd0b1489614df39752da825aac0f1c99d 100644 (file)
@@ -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;
index f3cf7814e52f78e2da617288c7258849ff44dd44..763998e852ed88361886ad0924b0994bf8e6cd5c 100644 (file)
@@ -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));
 }
-
index 0fd83efa20a77411ba9671ad8395a9f386909447..ffc35fe1f74be09624758fc60e8ba250d27993f5 100644 (file)
@@ -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
index cd1b979dcb0c2e3319d80c55df2b0b8292e8b63b..4bc7cd461cbce06ab79345b45f9491c69703a391 100644 (file)
@@ -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;
 }
index 645811319a4652de71082ad3793e95fdcdbd2743..643e066c7b46cbaad2435088efc80fcc7ee17180 100644 (file)
@@ -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;
index cd0e8822a8ab00bdeb1bf89e41d987e2c439e2d9..b55bddfed09d74b90abe70ef3dad7de1aaeedbac 100644 (file)
@@ -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;
       }
index 267fc0be1a204cfd38c8a006ad50275ca680edc5..0a68ee49de2239ab8b3cdeefd2aba16cc457633e 100644 (file)
@@ -1779,8 +1779,8 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
               MemRegionManager &MRMgr = state.getManager().getRegionManager();
               
               // Iterate through the fields and construct new symbols.
-              for (RecordDecl::field_iterator FI=RD->field_begin(),
-                   FE=RD->field_end(); FI!=FE; ++FI) {
+              for (RecordDecl::field_iterator FI=RD->field_begin(Ctx),
+                   FE=RD->field_end(Ctx); FI!=FE; ++FI) {
                 
                 // For now just handle scalar fields.
                 FieldDecl *FD = *FI;
index a59ed884d49500c5df7d24fb2e7420b89f041375..97e77cc50dae6972307bd5ac44bf2f1f0f36d417 100644 (file)
@@ -97,8 +97,8 @@ void clang::CheckObjCInstMethSignature(ObjCImplementationDecl* ID,
   ASTContext& Ctx = BR.getContext();
   
   while (C && NumMethods) {
-    for (ObjCInterfaceDecl::instmeth_iterator I=C->instmeth_begin(),
-         E=C->instmeth_end(); I!=E; ++I) {
+    for (ObjCInterfaceDecl::instmeth_iterator I=C->instmeth_begin(Ctx),
+         E=C->instmeth_end(Ctx); I!=E; ++I) {
 
       ObjCMethodDecl* M = *I;
       Selector S = M->getSelector();
index a1267928063889b43c2bf43e60cfb2151e71ad32..5e60363573ce62721c07b2fa2034939fb6c96db8 100644 (file)
@@ -814,7 +814,8 @@ SVal RegionStoreManager::RetrieveStruct(const GRState* St,const TypedRegion* R){
 
   llvm::ImmutableList<SVal> StructVal = getBasicVals().getEmptySValList();
 
-  std::vector<FieldDecl *> Fields(RD->field_begin(), RD->field_end());
+  std::vector<FieldDecl *> Fields(RD->field_begin(getContext()), 
+                                  RD->field_end(getContext()));
 
   for (std::vector<FieldDecl *>::reverse_iterator Field = Fields.rbegin(),
                                                FieldEnd = Fields.rend();
@@ -1166,7 +1167,8 @@ RegionStoreManager::BindStruct(const GRState* St, const TypedRegion* R, SVal V){
 
   nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
   nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
-  RecordDecl::field_iterator FI = RD->field_begin(), FE = RD->field_end();
+  RecordDecl::field_iterator FI = RD->field_begin(getContext()), 
+                             FE = RD->field_end(getContext());
 
   for (; FI != FE; ++FI, ++VI) {
 
index 2edf3bd104a163d3de386914941cb38b28dc3fa1..f3021dce43c7fd816e51c1990db4117cff8b7ebe 100644 (file)
@@ -160,17 +160,17 @@ void ABIArgInfo::dump() const {
 /// isEmptyRecord - Return true iff a structure has no non-empty
 /// members. Note that a structure with a flexible array member is not
 /// considered empty.
-static bool isEmptyRecord(QualType T) {
+static bool isEmptyRecord(ASTContext &Context, QualType T) {
   const RecordType *RT = T->getAsRecordType();
   if (!RT)
     return 0;
   const RecordDecl *RD = RT->getDecl();
   if (RD->hasFlexibleArrayMember())
     return false;
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(Context), 
+         e = RD->field_end(Context); i != e; ++i) {
     const FieldDecl *FD = *i;
-    if (!isEmptyRecord(FD->getType()))
+    if (!isEmptyRecord(Context, FD->getType()))
       return false;
   }
   return true;
@@ -194,8 +194,8 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
     return 0;
 
   const Type *Found = 0;
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(Context), 
+         e = RD->field_end(Context); i != e; ++i) {
     const FieldDecl *FD = *i;
     QualType FT = FD->getType();
 
@@ -204,7 +204,7 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
       if (AT->getSize().getZExtValue() == 1)
         FT = AT->getElementType();
 
-    if (isEmptyRecord(FT)) {
+    if (isEmptyRecord(Context, FT)) {
       // Ignore
     } else if (Found) {
       return 0;
@@ -230,8 +230,8 @@ static bool is32Or64BitBasicType(QualType Ty, ASTContext &Context) {
 
 static bool areAllFields32Or64BitBasicType(const RecordDecl *RD,
                                            ASTContext &Context) {
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(Context), 
+         e = RD->field_end(Context); i != e; ++i) {
     const FieldDecl *FD = *i;
 
     if (!is32Or64BitBasicType(FD->getType(), Context))
@@ -273,6 +273,7 @@ class DefaultABIInfo : public ABIInfo {
 
 /// X86_32ABIInfo - The X86-32 ABI information.
 class X86_32ABIInfo : public ABIInfo {
+  ASTContext &Context;
   bool IsDarwin;
 
   static bool isRegisterSize(unsigned Size) {
@@ -298,7 +299,8 @@ public:
   virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                  CodeGenFunction &CGF) const;
 
-  X86_32ABIInfo(bool d) : ABIInfo(), IsDarwin(d) {}
+  X86_32ABIInfo(ASTContext &Context, bool d) 
+    : ABIInfo(), Context(Context), IsDarwin(d) {}
 };
 }
 
@@ -336,8 +338,8 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
 
   // Structure types are passed in register if all fields would be
   // passed in a register.
-  for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(), 
-         e = RT->getDecl()->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(Context), 
+         e = RT->getDecl()->field_end(Context); i != e; ++i) {
     const FieldDecl *FD = *i;
     
     // FIXME: Reject bitfields wholesale for now; this is incorrect.
@@ -345,7 +347,7 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
       return false;
 
     // Empty structures are ignored.
-    if (isEmptyRecord(FD->getType()))
+    if (isEmptyRecord(Context, FD->getType()))
       continue;
 
     // Check fields recursively.
@@ -756,8 +758,8 @@ void X86_64ABIInfo::classify(QualType Ty,
     // Reset Lo class, this will be recomputed.
     Current = NoClass;
     unsigned idx = 0;
-    for (RecordDecl::field_iterator i = RD->field_begin(), 
-           e = RD->field_end(); i != e; ++i, ++idx) {
+    for (RecordDecl::field_iterator i = RD->field_begin(Context), 
+           e = RD->field_end(Context); i != e; ++i, ++idx) {
       uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
       bool BitField = i->isBitField();
 
@@ -1391,7 +1393,7 @@ const ABIInfo &CodeGenTypes::getABIInfo() const {
     bool IsDarwin = strstr(getContext().Target.getTargetTriple(), "darwin");
     switch (getContext().Target.getPointerWidth(0)) {
     case 32:
-      return *(TheABIInfo = new X86_32ABIInfo(IsDarwin));
+      return *(TheABIInfo = new X86_32ABIInfo(Context, IsDarwin));
     case 64:
       return *(TheABIInfo = new X86_64ABIInfo());
     }
@@ -1424,8 +1426,8 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty,
   assert(!RD->hasFlexibleArrayMember() && 
          "Cannot expand structure with flexible array.");
   
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(Context), 
+         e = RD->field_end(Context); i != e; ++i) {
     const FieldDecl *FD = *i;
     assert(!FD->isBitField() && 
            "Cannot expand structure with bit-field members.");
@@ -1449,8 +1451,8 @@ CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV,
   assert(LV.isSimple() && 
          "Unexpected non-simple lvalue during struct expansion.");  
   llvm::Value *Addr = LV.getAddress();
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(getContext()), 
+         e = RD->field_end(getContext()); i != e; ++i) {
     FieldDecl *FD = *i;    
     QualType FT = FD->getType();
 
@@ -1476,8 +1478,8 @@ CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
   RecordDecl *RD = RT->getDecl();
   assert(RV.isAggregate() && "Unexpected rvalue during struct expansion");
   llvm::Value *Addr = RV.getAggregateAddr();
-  for (RecordDecl::field_iterator i = RD->field_begin(), 
-         e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator i = RD->field_begin(getContext()), 
+         e = RD->field_end(getContext()); i != e; ++i) {
     FieldDecl *FD = *i;    
     QualType FT = FD->getType();
     
index 0d13299574b3337cb4619fd543f9b32fc1645785..f2fc90c6cfb398b740bfe934d00e66d6c0f5adb0 100644 (file)
@@ -269,8 +269,8 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
   const ASTRecordLayout &RL = M->getContext().getASTRecordLayout(Decl);
 
   unsigned FieldNo = 0;
-  for (RecordDecl::field_iterator I = Decl->field_begin(),
-                                  E = Decl->field_end(); 
+  for (RecordDecl::field_iterator I = Decl->field_begin(M->getContext()),
+                                  E = Decl->field_end(M->getContext()); 
        I != E; ++I, ++FieldNo) {
     FieldDecl *Field = *I;
     llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -450,8 +450,9 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty,
   llvm::SmallVector<llvm::DIDescriptor, 32> Enumerators;
 
   // Create DIEnumerator elements for each enumerator.
-  for (EnumDecl::enumerator_iterator Enum = Decl->enumerator_begin(),
-                                  EnumEnd = Decl->enumerator_end();
+  for (EnumDecl::enumerator_iterator 
+         Enum = Decl->enumerator_begin(M->getContext()),
+         EnumEnd = Decl->enumerator_end(M->getContext());
        Enum != EnumEnd; ++Enum) {
     Enumerators.push_back(DebugFactory.CreateEnumerator(Enum->getNameAsString(),
                                             Enum->getInitVal().getZExtValue()));
index 095e2240cf626b4fd4caa77e2b5df3552436b7f5..3b1580cc136a6516d7f7a0f5e09d45d44b433035 100644 (file)
@@ -133,7 +133,9 @@ void AggExprEmitter::VisitCStyleCastExpr(CStyleCastExpr *E) {
   // GCC union extension
   if (E->getType()->isUnionType()) {
     RecordDecl *SD = E->getType()->getAsRecordType()->getDecl();
-    LValue FieldLoc = CGF.EmitLValueForField(DestPtr, *SD->field_begin(), true, 0);
+    LValue FieldLoc = CGF.EmitLValueForField(DestPtr, 
+                                             *SD->field_begin(CGF.getContext()),
+                                             true, 0);
     EmitInitializationToLValue(E->getSubExpr(), FieldLoc);
     return;
   }
@@ -398,8 +400,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
 #ifndef NDEBUG
       // Make sure that it's really an empty and not a failure of
       // semantic analysis.
-      for (RecordDecl::field_iterator Field = SD->field_begin(),
-                                   FieldEnd = SD->field_end();
+      for (RecordDecl::field_iterator Field = SD->field_begin(CGF.getContext()),
+                                   FieldEnd = SD->field_end(CGF.getContext());
            Field != FieldEnd; ++Field)
         assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed");
 #endif
@@ -423,8 +425,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
   
   // Here we iterate over the fields; this makes it simpler to both
   // default-initialize fields and skip over unnamed fields.
-  for (RecordDecl::field_iterator Field = SD->field_begin(),
-                               FieldEnd = SD->field_end();
+  for (RecordDecl::field_iterator Field = SD->field_begin(CGF.getContext()),
+                               FieldEnd = SD->field_end(CGF.getContext());
        Field != FieldEnd; ++Field) {
     // We're done once we hit the flexible array member
     if (Field->getType()->isIncompleteArrayType())
index 35b3a3750a391bea276bc4b5fa014695cbe48834..c5f22023d37e1aa0f4b0c485332a2670bb8ab083 100644 (file)
@@ -196,8 +196,8 @@ public:
     unsigned EltNo = 0;  // Element no in ILE
     int FieldNo = 0; // Field no in RecordDecl
     bool RewriteType = false;
-    for (RecordDecl::field_iterator Field = RD->field_begin(),
-                                 FieldEnd = RD->field_end();
+    for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()),
+                                 FieldEnd = RD->field_end(CGM.getContext());
          EltNo < ILE->getNumInits() && Field != FieldEnd; ++Field) {
       FieldNo++;
       if (!Field->getIdentifier())
@@ -267,8 +267,8 @@ public:
       // Make sure that it's really an empty and not a failure of
       // semantic analysis.
       RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
-      for (RecordDecl::field_iterator Field = RD->field_begin(),
-                                   FieldEnd = RD->field_end();
+      for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()),
+                                   FieldEnd = RD->field_end(CGM.getContext());
            Field != FieldEnd; ++Field)
         assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed");
 #endif
index fc77c805f4266ecb3d79910a46def01199b54a07..cd94290000d734b5e6bddb5ad007edf122671285 100644 (file)
@@ -618,8 +618,8 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
     Protocols.push_back((*PI)->getNameAsString());
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames;
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
-  for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(),
-       E = PD->instmeth_end(); iter != E; iter++) {
+  for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(Context),
+       E = PD->instmeth_end(Context); iter != E; iter++) {
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl(*iter, TypeStr);
     InstanceMethodNames.push_back(
@@ -629,8 +629,9 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
   // Collect information about class methods:
   llvm::SmallVector<llvm::Constant*, 16> ClassMethodNames;
   llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes;
-  for (ObjCProtocolDecl::classmeth_iterator iter = PD->classmeth_begin(),
-      endIter = PD->classmeth_end() ; iter != endIter ; iter++) {
+  for (ObjCProtocolDecl::classmeth_iterator 
+         iter = PD->classmeth_begin(Context),
+         endIter = PD->classmeth_end(Context) ; iter != endIter ; iter++) {
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
     ClassMethodNames.push_back(
index 116d8b010fe20baa52d5082fa828f1a35b520d3b..a06959f1de778044d785e2826b67bf01f93b770c 100644 (file)
@@ -1100,8 +1100,9 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
   // Construct method lists.
   std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
   std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods;
-  for (ObjCProtocolDecl::instmeth_iterator i = PD->instmeth_begin(),
-         e = PD->instmeth_end(); i != e; ++i) {
+  for (ObjCProtocolDecl::instmeth_iterator 
+         i = PD->instmeth_begin(CGM.getContext()),
+         e = PD->instmeth_end(CGM.getContext()); i != e; ++i) {
     ObjCMethodDecl *MD = *i;
     llvm::Constant *C = GetMethodDescriptionConstant(MD);
     if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
@@ -1111,8 +1112,9 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
     }      
   }
 
-  for (ObjCProtocolDecl::classmeth_iterator i = PD->classmeth_begin(),
-         e = PD->classmeth_end(); i != e; ++i) {
+  for (ObjCProtocolDecl::classmeth_iterator 
+         i = PD->classmeth_begin(CGM.getContext()),
+         e = PD->classmeth_end(CGM.getContext()); i != e; ++i) {
     ObjCMethodDecl *MD = *i;
     llvm::Constant *C = GetMethodDescriptionConstant(MD);
     if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
@@ -1286,8 +1288,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(const std::string &Name,
                                       const ObjCContainerDecl *OCD,
                                       const ObjCCommonTypesHelper &ObjCTypes) {
   std::vector<llvm::Constant*> Properties, Prop(2);
-  for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(), 
-       E = OCD->prop_end(); I != E; ++I) {
+  for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(CGM.getContext()), 
+       E = OCD->prop_end(CGM.getContext()); I != E; ++I) {
     const ObjCPropertyDecl *PD = *I;
     Prop[0] = GetPropertyName(PD->getIdentifier());
     Prop[1] = GetPropertyTypeString(PD, Container);
@@ -1691,19 +1693,20 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) {
 
 /// countInheritedIvars - count number of ivars in class and its super class(s)
 ///
-static int countInheritedIvars(const ObjCInterfaceDecl *OI) {
+static int countInheritedIvars(const ObjCInterfaceDecl *OI, 
+                               ASTContext &Context) {
   int count = 0;
   if (!OI)
     return 0;
   const ObjCInterfaceDecl *SuperClass = OI->getSuperClass();
   if (SuperClass)
-    count += countInheritedIvars(SuperClass);
+    count += countInheritedIvars(SuperClass, Context);
   for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(),
        E = OI->ivar_end(); I != E; ++I)
     ++count;
   // 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(Context),
+       E = OI->prop_end(Context); I != E; ++I) {
     if ((*I)->getPropertyIvarDecl())
       ++count;
   }
@@ -1719,7 +1722,8 @@ static int countInheritedIvars(const ObjCInterfaceDecl *OI) {
 ///
 static const ObjCInterfaceDecl *getInterfaceDeclForIvar(
                                   const ObjCInterfaceDecl *OI,
-                                  const ObjCIvarDecl *IVD) {
+                                  const ObjCIvarDecl *IVD,
+                                  ASTContext &Context) {
   if (!OI)
     return 0;
   assert(isa<ObjCInterfaceDecl>(OI) && "OI is not an interface");
@@ -1728,14 +1732,14 @@ static const ObjCInterfaceDecl *getInterfaceDeclForIvar(
     if ((*I)->getIdentifier() == IVD->getIdentifier())
       return OI;
   // 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(Context),
+       E = OI->prop_end(Context); I != E; ++I) {
     ObjCPropertyDecl *PDecl = (*I);
     if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
       if (IV->getIdentifier() == IVD->getIdentifier())
         return OI;
   }
-  return getInterfaceDeclForIvar(OI->getSuperClass(), IVD);
+  return getInterfaceDeclForIvar(OI->getSuperClass(), IVD, Context);
 }
 
 /*
@@ -1768,7 +1772,8 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
   
   RecordDecl::field_iterator ifield, pfield;
   const RecordDecl *RD = GetFirstIvarInRecord(OID, ifield, pfield);
-  for (RecordDecl::field_iterator e = RD->field_end(); ifield != e; ++ifield) {
+  for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext());
+       ifield != e; ++ifield) {
     FieldDecl *Field = *ifield;
     uint64_t  Offset = GetIvarBaseOffset(Layout, Field);
     if (Field->getIdentifier())
@@ -2611,7 +2616,8 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
       const RecordType *RT = FQT->getAsRecordType();
       const RecordDecl *RD = RT->getDecl();
       // FIXME - Find a more efficiant way of passing records down.
-      TmpRecFields.append(RD->field_begin(), RD->field_end());
+      TmpRecFields.append(RD->field_begin(CGM.getContext()),
+                          RD->field_end(CGM.getContext()));
       // FIXME - Is Layout correct?
       BuildAggrIvarLayout(OI, Layout, RD, TmpRecFields,
                           BytePos + GetFieldBaseOffset(OI, Layout, Field),
@@ -2643,7 +2649,8 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
         const RecordType *RT = FQT->getAsRecordType();
         const RecordDecl *RD = RT->getDecl();
         // FIXME - Find a more efficiant way of passing records down.
-        TmpRecFields.append(RD->field_begin(), RD->field_end());
+        TmpRecFields.append(RD->field_begin(CGM.getContext()),
+                            RD->field_end(CGM.getContext()));
         
         BuildAggrIvarLayout(OI, Layout, RD,
                             TmpRecFields,
@@ -3075,10 +3082,11 @@ const RecordDecl *CGObjCCommonMac::GetFirstIvarInRecord(
                                           const ObjCInterfaceDecl *OID,
                                           RecordDecl::field_iterator &FIV,
                                           RecordDecl::field_iterator &PIV) {
-  int countSuperClassIvars = countInheritedIvars(OID->getSuperClass());
+  int countSuperClassIvars = countInheritedIvars(OID->getSuperClass(),
+                                                 CGM.getContext());
   const RecordDecl *RD = CGM.getContext().addRecordToClass(OID);
-  RecordDecl::field_iterator ifield = RD->field_begin();
-  RecordDecl::field_iterator pfield = RD->field_end();
+  RecordDecl::field_iterator ifield = RD->field_begin(CGM.getContext());
+  RecordDecl::field_iterator pfield = RD->field_end(CGM.getContext());
   while (countSuperClassIvars-- > 0) {
     pfield = ifield;
     ++ifield;
@@ -3194,10 +3202,10 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
   RecordDecl *RD = RecordDecl::Create(Ctx, TagDecl::TK_struct, 0,
                                       SourceLocation(),
                                       &Ctx.Idents.get("_objc_super"));  
-  RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0, 
-                                Ctx.getObjCIdType(), 0, false));
-  RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
-                                Ctx.getObjCClassType(), 0, false));
+  RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0, 
+                                     Ctx.getObjCIdType(), 0, false));
+  RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
+                                     Ctx.getObjCClassType(), 0, false));
   RD->completeDefinition(Ctx);
   
   SuperCTy = Ctx.getTagDeclType(RD);
@@ -3819,10 +3827,10 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
   RecordDecl *RD = RecordDecl::Create(Ctx, TagDecl::TK_struct, 0,
                                       SourceLocation(),
                                       &Ctx.Idents.get("_message_ref_t"));
-  RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
-                                Ctx.VoidPtrTy, 0, false));
-  RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
-                                Ctx.getObjCSelType(), 0, false));
+  RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
+                                     Ctx.VoidPtrTy, 0, false));
+  RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0,
+                                     Ctx.getObjCSelType(), 0, false));
   RD->completeDefinition(Ctx);
   
   MessageRefCTy = Ctx.getTagDeclType(RD);
@@ -4273,17 +4281,17 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
     RecordDecl::field_iterator firstField, lastField;
     const RecordDecl *RD = GetFirstIvarInRecord(OID, firstField, lastField);
     
-    for (RecordDecl::field_iterator e = RD->field_end(),
+    for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext()),
          ifield = firstField; ifield != e; ++ifield)
       lastField = ifield;
     
-    if (lastField != RD->field_end()) {
+    if (lastField != RD->field_end(CGM.getContext())) {
       FieldDecl *Field = *lastField;
       const llvm::Type *FieldTy =
         CGM.getTypes().ConvertTypeForMem(Field->getType());
       unsigned Size = CGM.getTargetData().getTypePaddedSize(FieldTy);
       InstanceSize = GetIvarBaseOffset(Layout, Field) + Size;
-      if (firstField == RD->field_end())
+      if (firstField == RD->field_end(CGM.getContext()))
         InstanceStart = InstanceSize;
       else {
         Field = *firstField;
@@ -4495,8 +4503,8 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(
                               const ObjCInterfaceDecl *ID,
                               const ObjCIvarDecl *Ivar) {
   Name += "\01_OBJC_IVAR_$_" + 
-          getInterfaceDeclForIvar(ID, Ivar)->getNameAsString() + '.'
-          + Ivar->getNameAsString();
+    getInterfaceDeclForIvar(ID, Ivar, CGM.getContext())->getNameAsString() + 
+    '.' + Ivar->getNameAsString();
   llvm::GlobalVariable *IvarOffsetGV = 
     CGM.getModule().getGlobalVariable(Name);
   if (!IvarOffsetGV)
@@ -4585,13 +4593,14 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
   for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
        E = OID->ivar_end(); I != E; ++I) 
      OIvars.push_back(*I);
-  for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(),
-       E = OID->prop_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(CGM.getContext()),
+       E = OID->prop_end(CGM.getContext()); I != E; ++I)
     if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
       OIvars.push_back(IV);
     
   unsigned iv = 0;
-  for (RecordDecl::field_iterator e = RD->field_end(); i != e; ++i) {
+  for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext()); 
+       i != e; ++i) {
     FieldDecl *Field = *i;
     uint64_t offset = GetIvarBaseOffset(Layout, Field);
     Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), OIvars[iv++], offset);
@@ -4693,8 +4702,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
   // Construct method lists.
   std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
   std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods;
-  for (ObjCProtocolDecl::instmeth_iterator i = PD->instmeth_begin(),
-       e = PD->instmeth_end(); i != e; ++i) {
+  for (ObjCProtocolDecl::instmeth_iterator 
+         i = PD->instmeth_begin(CGM.getContext()),
+         e = PD->instmeth_end(CGM.getContext()); 
+       i != e; ++i) {
     ObjCMethodDecl *MD = *i;
     llvm::Constant *C = GetMethodDescriptionConstant(MD);
     if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
@@ -4704,8 +4715,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
     }      
   }
   
-  for (ObjCProtocolDecl::classmeth_iterator i = PD->classmeth_begin(),
-       e = PD->classmeth_end(); i != e; ++i) {
+  for (ObjCProtocolDecl::classmeth_iterator 
+         i = PD->classmeth_begin(CGM.getContext()),
+         e = PD->classmeth_end(CGM.getContext());
+       i != e; ++i) {
     ObjCMethodDecl *MD = *i;
     llvm::Constant *C = GetMethodDescriptionConstant(MD);
     if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
index 2c1ab1f8b59b82d0adad24312cd414c05da2986d..eb190c79e1cb8c91169cb8181b413294b2bc4dac 100644 (file)
@@ -1102,7 +1102,7 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
     cast<llvm::StructType>(getTypes().ConvertType(CFTy));
 
   std::vector<llvm::Constant*> Fields;
-  RecordDecl::field_iterator Field = CFRD->field_begin();
+  RecordDecl::field_iterator Field = CFRD->field_begin(getContext());
 
   // Class pointer.
   FieldDecl *CurField = *Field++;
@@ -1297,7 +1297,8 @@ void CodeGenModule::EmitObjCPropertyImplementations(const
 
 /// EmitNamespace - Emit all declarations in a namespace.
 void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) {
-  for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->decls_end();
+  for (RecordDecl::decl_iterator I = ND->decls_begin(getContext()),
+         E = ND->decls_end(getContext());
        I != E; ++I)
     EmitTopLevelDecl(*I);
 }
@@ -1309,7 +1310,8 @@ void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) {
     return;
   }
 
-  for (RecordDecl::decl_iterator I = LSD->decls_begin(), E = LSD->decls_end();
+  for (RecordDecl::decl_iterator I = LSD->decls_begin(getContext()),
+         E = LSD->decls_end(getContext());
        I != E; ++I)
     EmitTopLevelDecl(*I);
 }
index e13a4bc65d265ccf1a99e1b3d344b418548c74cc..984e49e12098afd3bb7ded23f590a42dcf1527b0 100644 (file)
@@ -482,7 +482,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
   } else if (TD->isUnion()) {
     // Just use the largest element of the union, breaking ties with the
     // highest aligned member.
-    if (!RD->field_empty()) {
+    if (!RD->field_empty(getContext())) {
       RecordOrganizer RO(*this, *RD);
       
       RO.layoutUnionFields(Context.getASTRecordLayout(RD));
@@ -563,8 +563,8 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) {
   std::vector<const llvm::Type*> LLVMFields;
 
   unsigned curField = 0;
-  for (RecordDecl::field_iterator Field = RD.field_begin(),
-                               FieldEnd = RD.field_end();
+  for (RecordDecl::field_iterator Field = RD.field_begin(CGT.getContext()),
+                               FieldEnd = RD.field_end(CGT.getContext());
        Field != FieldEnd; ++Field) {
     uint64_t offset = RL.getFieldOffset(curField);
     const llvm::Type *Ty = CGT.ConvertTypeForMemRecursive(Field->getType());
@@ -614,8 +614,8 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) {
 /// all fields are added.
 void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) {
   unsigned curField = 0;
-  for (RecordDecl::field_iterator Field = RD.field_begin(),
-                               FieldEnd = RD.field_end();
+  for (RecordDecl::field_iterator Field = RD.field_begin(CGT.getContext()),
+                               FieldEnd = RD.field_end(CGT.getContext());
        Field != FieldEnd; ++Field) {
     // The offset should usually be zero, but bitfields could be strange
     uint64_t offset = RL.getFieldOffset(curField);
index a3ddb33eb332b15cd9e2ff9343f56c96d97ad0eb..474c1e490e43c3648e8d603d279abb1b51ce9393 100644 (file)
@@ -211,7 +211,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.
-  CurContext->addDecl(D);
+  CurContext->addDecl(Context, D);
 
   // C++ [basic.scope]p4:
   //   -- exactly one declaration shall declare a class name or
@@ -1004,8 +1004,8 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
 bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
                                                RecordDecl *AnonRecord) {
   bool Invalid = false;
-  for (RecordDecl::field_iterator F = AnonRecord->field_begin(),
-                               FEnd = AnonRecord->field_end();
+  for (RecordDecl::field_iterator F = AnonRecord->field_begin(Context),
+                               FEnd = AnonRecord->field_end(Context);
        F != FEnd; ++F) {
     if ((*F)->getDeclName()) {
       NamedDecl *PrevDecl = LookupQualifiedName(Owner, (*F)->getDeclName(),
@@ -1028,7 +1028,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
         //   definition, the members of the anonymous union are
         //   considered to have been defined in the scope in which the
         //   anonymous union is declared.
-        Owner->makeDeclVisibleInContext(*F);
+        Owner->makeDeclVisibleInContext(Context, *F);
         S->AddDecl(DeclPtrTy::make(*F));
         IdResolver.AddDecl(*F);
       }
@@ -1094,8 +1094,8 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
     //   The member-specification of an anonymous union shall only
     //   define non-static data members. [Note: nested types and
     //   functions cannot be declared within an anonymous union. ]
-    for (DeclContext::decl_iterator Mem = Record->decls_begin(),
-                                 MemEnd = Record->decls_end();
+    for (DeclContext::decl_iterator Mem = Record->decls_begin(Context),
+                                 MemEnd = Record->decls_end(Context);
          Mem != MemEnd; ++Mem) {
       if (FieldDecl *FD = dyn_cast<FieldDecl>(*Mem)) {
         // C++ [class.union]p3:
@@ -1183,7 +1183,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
   // Add the anonymous struct/union object to the current
   // context. We'll be referencing this object when we refer to one of
   // its members.
-  Owner->addDecl(Anon);
+  Owner->addDecl(Context, Anon);
 
   // Inject the members of the anonymous struct/union into the owning
   // context and into the identifier resolver chain for name lookup
@@ -3473,7 +3473,7 @@ CreateNewDecl:
     S = getNonFieldDeclScope(S);
     PushOnScopeChains(New, S);
   } else {
-    CurContext->addDecl(New);
+    CurContext->addDecl(Context, New);
   }
 
   return DeclPtrTy::make(New);
@@ -3607,7 +3607,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
   } else if (II) {
     PushOnScopeChains(NewFD, S);
   } else
-    Record->addDecl(NewFD);
+    Record->addDecl(Context, NewFD);
 
   return NewFD;
 }
@@ -3921,7 +3921,7 @@ void Sema::ActOnFields(Scope* S,
           ObjCIvarDecl* Ivar = (*IVI);
           IdentifierInfo *II = Ivar->getIdentifier();
           ObjCIvarDecl* prevIvar =
-            ID->getSuperClass()->lookupInstanceVariable(II);
+            ID->getSuperClass()->lookupInstanceVariable(Context, II);
           if (prevIvar) {
             Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
             Diag(prevIvar->getLocation(), diag::note_previous_declaration);
index 7f5909b037f5db48accdae8ac6f4ec0afb4ed1e0..f3f04f077426dd25041fcf1ed44355940be401a6 100644 (file)
@@ -1178,8 +1178,8 @@ static void HandleTransparentUnionAttr(Decl *d, const AttributeList &Attr,
 
   // FIXME: This isn't supposed to be restricted to pointers, but otherwise
   // we might silently generate incorrect code; see following code
-  for (RecordDecl::field_iterator Field = RD->field_begin(),
-                               FieldEnd = RD->field_end();
+  for (RecordDecl::field_iterator Field = RD->field_begin(S.Context),
+                               FieldEnd = RD->field_end(S.Context);
        Field != FieldEnd; ++Field) {
     if (!Field->getType()->isPointerType()) {
       S.Diag(Attr.getLoc(), diag::warn_transparent_union_nonpointer);
index feb127bcf46874a0b9d2993161cd22a6216ae68c..feff707e1568743d0681af7ca9ad002d89f1c49d 100644 (file)
@@ -633,7 +633,8 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
   //   using a qualified name. ]
   // Look for a member, first.
   FieldDecl *Member = 0;
-  DeclContext::lookup_result Result = ClassDecl->lookup(MemberOrBase);
+  DeclContext::lookup_result Result 
+    = ClassDecl->lookup(Context, MemberOrBase);
   if (Result.first != Result.second)
     Member = dyn_cast<FieldDecl>(*Result.first);
 
@@ -772,7 +773,8 @@ namespace {
         continue;
       
       DeclContext::lookup_const_iterator I, E;
-      for (llvm::tie(I, E) = RD->lookup(VMD->getDeclName()); I != E; ++I) {
+      for (llvm::tie(I, E) = RD->lookup(Context, VMD->getDeclName()); 
+           I != E; ++I) {
         if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*I)) {
           if (Context.getCanonicalType(MD->getType()) == 
               Context.getCanonicalType(VMD->getType())) {
@@ -785,7 +787,8 @@ namespace {
     }
     
     // Finally, add pure virtual methods from this class.
-    for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end(); 
+    for (RecordDecl::decl_iterator i = RD->decls_begin(Context), 
+                                   e = RD->decls_end(Context); 
          i != e; ++i) {
       if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) {
         if (MD->isPure())
@@ -863,8 +866,8 @@ namespace {
     bool VisitDeclContext(const DeclContext *DC) {
       bool Invalid = false;
 
-      for (CXXRecordDecl::decl_iterator I = DC->decls_begin(),
-           E = DC->decls_end(); I != E; ++I)
+      for (CXXRecordDecl::decl_iterator I = DC->decls_begin(SemaRef.Context),
+           E = DC->decls_end(SemaRef.Context); I != E; ++I)
         Invalid |= Visit(*I);
 
       return Invalid;
@@ -968,7 +971,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
                                  /*isImplicitlyDeclared=*/true);
     DefaultCon->setAccess(AS_public);
     DefaultCon->setImplicit();
-    ClassDecl->addDecl(DefaultCon);
+    ClassDecl->addDecl(Context, DefaultCon);
 
     // Notify the class that we've added a constructor.
     ClassDecl->addedConstructor(Context, DefaultCon);
@@ -1003,8 +1006,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
     //        class type M (or array thereof), each such class type
     //        has a copy constructor whose first parameter is of type
     //        const M& or const volatile M&.
-    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
-         HasConstCopyConstructor && Field != ClassDecl->field_end(); ++Field) {
+    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
+         HasConstCopyConstructor && Field != ClassDecl->field_end(Context);
+         ++Field) {
       QualType FieldType = (*Field)->getType();
       if (const ArrayType *Array = Context.getAsArrayType(FieldType))
         FieldType = Array->getElementType();
@@ -1049,7 +1053,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
     CopyConstructor->setParams(Context, &FromParam, 1);
 
     ClassDecl->addedConstructor(Context, CopyConstructor);
-    ClassDecl->addDecl(CopyConstructor);
+    ClassDecl->addDecl(Context, CopyConstructor);
   }
 
   if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
@@ -1083,8 +1087,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
     //          type M (or array thereof), each such class type has a copy
     //          assignment operator whose parameter is of type const M&,
     //          const volatile M& or M.
-    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
-         HasConstCopyAssignment && Field != ClassDecl->field_end(); ++Field) {
+    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
+         HasConstCopyAssignment && Field != ClassDecl->field_end(Context);
+         ++Field) {
       QualType FieldType = (*Field)->getType();
       if (const ArrayType *Array = Context.getAsArrayType(FieldType))
         FieldType = Array->getElementType();
@@ -1127,7 +1132,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
 
     // Don't call addedAssignmentOperator. There is no way to distinguish an
     // implicit from an explicit assignment operator.
-    ClassDecl->addDecl(CopyAssignment);
+    ClassDecl->addDecl(Context, CopyAssignment);
   }
 
   if (!ClassDecl->hasUserDeclaredDestructor()) {
@@ -1146,7 +1151,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
                                   /*isImplicitlyDeclared=*/true);
     Destructor->setAccess(AS_public);
     Destructor->setImplicit();
-    ClassDecl->addDecl(Destructor);
+    ClassDecl->addDecl(Context, Destructor);
   }
 }
 
@@ -1668,7 +1673,7 @@ void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
   // or translation unit scope. We add UsingDirectiveDecls, into
   // it's lookup structure.
   if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity()))
-    Ctx->addDecl(UDir);
+    Ctx->addDecl(Context, UDir);
   else
     // Otherwise it is block-sope. using-directives will affect lookup
     // only to the end of scope.
@@ -1724,7 +1729,7 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
     NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc, Alias, 
                                IdentLoc, R);
   
-  CurContext->addDecl(AliasDecl);
+  CurContext->addDecl(Context, AliasDecl);
   return DeclPtrTy::make(AliasDecl);
 }
 
@@ -1861,7 +1866,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
     = Context.DeclarationNames.getCXXConstructorName(
                        Context.getCanonicalType(ClassType.getUnqualifiedType()));
   DeclContext::lookup_const_iterator Con, ConEnd;
-  for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(ConstructorName);
+  for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(Context, ConstructorName);
        Con != ConEnd; ++Con) {
     CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
     if ((Kind == IK_Direct) ||
@@ -2467,7 +2472,7 @@ Sema::DeclPtrTy Sema::ActOnStartLinkageSpecification(Scope *S,
   LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
                                                LangLoc, Language, 
                                                LBraceLoc.isValid());
-  CurContext->addDecl(D);
+  CurContext->addDecl(Context, D);
   PushDeclContext(S, D);
   return DeclPtrTy::make(D);
 }
@@ -2586,7 +2591,7 @@ Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
   Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc, 
                                         AssertExpr, AssertMessage);
   
-  CurContext->addDecl(Decl);
+  CurContext->addDecl(Context, Decl);
   return DeclPtrTy::make(Decl);
 }
 
index e1583d75b40d34727ffc14b9a62b48c507588638..edbb018a223f9f329041f67a79eac26d0ff91e17 100644 (file)
@@ -98,7 +98,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
   
     ObjCInterfaceDecls[ClassName] = IDecl;
     // FIXME: PushOnScopeChains
-    CurContext->addDecl(IDecl);
+    CurContext->addDecl(Context, IDecl);
     // Remember that this needs to be removed when the scope is popped.
     TUScope->AddDecl(DeclPtrTy::make(IDecl));
   }
@@ -206,7 +206,7 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
   ObjCAliasDecls[AliasName] = AliasDecl;
 
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(AliasDecl);
+  CurContext->addDecl(Context, AliasDecl);
   if (!CheckObjCDeclScope(AliasDecl))
     TUScope->AddDecl(DeclPtrTy::make(AliasDecl));
 
@@ -265,7 +265,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
     PDecl = ObjCProtocolDecl::Create(Context, CurContext, 
                                      AtProtoInterfaceLoc,ProtocolName);
     // FIXME: PushOnScopeChains?
-    CurContext->addDecl(PDecl);
+    CurContext->addDecl(Context, PDecl);
     PDecl->setForwardDecl(false);
     ObjCProtocols[ProtocolName] = PDecl;
   }
@@ -367,12 +367,12 @@ void Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
   if (!SDecl)
     return;
   // FIXME: O(N^2)
-  for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(),
-       E = SDecl->prop_end(); S != E; ++S) {
+  for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(Context),
+       E = SDecl->prop_end(Context); S != E; ++S) {
     ObjCPropertyDecl *SuperPDecl = (*S);
     // Does property in super class has declaration in current class?
-    for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(),
-         E = IDecl->prop_end(); I != E; ++I) {
+    for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(Context),
+         E = IDecl->prop_end(Context); I != E; ++I) {
       ObjCPropertyDecl *PDecl = (*I);
       if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
           DiagnosePropertyMismatch(PDecl, SuperPDecl, 
@@ -392,12 +392,12 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
     // Category
     ObjCCategoryDecl *CatDecl = static_cast<ObjCCategoryDecl*>(CDecl);
     assert (CatDecl && "MergeOneProtocolPropertiesIntoClass");
-    for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
-         E = PDecl->prop_end(); P != E; ++P) {
+    for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(Context),
+         E = PDecl->prop_end(Context); P != E; ++P) {
       ObjCPropertyDecl *Pr = (*P);
       ObjCCategoryDecl::prop_iterator CP, CE;
       // Is this property already in  category's list of properties?
-      for (CP = CatDecl->prop_begin(), CE = CatDecl->prop_end(); 
+      for (CP = CatDecl->prop_begin(Context), CE = CatDecl->prop_end(Context); 
            CP != CE; ++CP)
         if ((*CP)->getIdentifier() == Pr->getIdentifier())
           break;
@@ -407,12 +407,12 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
     }
     return;
   }
-  for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
-       E = PDecl->prop_end(); P != E; ++P) {
+  for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(Context),
+       E = PDecl->prop_end(Context); P != E; ++P) {
     ObjCPropertyDecl *Pr = (*P);
     ObjCInterfaceDecl::prop_iterator CP, CE;
     // Is this property already in  class's list of properties?
-    for (CP = IDecl->prop_begin(), CE = IDecl->prop_end(); 
+    for (CP = IDecl->prop_begin(Context), CE = IDecl->prop_end(Context); 
          CP != CE; ++CP)
       if ((*CP)->getIdentifier() == Pr->getIdentifier())
         break;
@@ -483,16 +483,16 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
     return;  // Possibly due to previous error
 
   llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
-  for (ObjCInterfaceDecl::method_iterator i = ID->meth_begin(),
-       e =  ID->meth_end(); i != e; ++i) {
+  for (ObjCInterfaceDecl::method_iterator i = ID->meth_begin(Context),
+       e =  ID->meth_end(Context); i != e; ++i) {
     ObjCMethodDecl *MD = *i;
     MethodMap[MD->getSelector()] = MD;
   }
 
   if (MethodMap.empty())
     return;
-  for (ObjCCategoryDecl::method_iterator i = CAT->meth_begin(),
-       e =  CAT->meth_end(); i != e; ++i) {
+  for (ObjCCategoryDecl::method_iterator i = CAT->meth_begin(Context),
+       e =  CAT->meth_end(Context); i != e; ++i) {
     ObjCMethodDecl *Method = *i;
     const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
     if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
@@ -518,7 +518,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
       PDecl = ObjCProtocolDecl::Create(Context, CurContext, 
                                        IdentList[i].second, Ident);
       // FIXME: PushOnScopeChains?
-      CurContext->addDecl(PDecl);
+      CurContext->addDecl(Context, PDecl);
     }
     if (attrList)
       ProcessDeclAttributeList(PDecl, attrList);
@@ -528,7 +528,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
   ObjCForwardProtocolDecl *PDecl = 
     ObjCForwardProtocolDecl::Create(Context, CurContext, AtProtocolLoc,
                                     &Protocols[0], Protocols.size());
-  CurContext->addDecl(PDecl);
+  CurContext->addDecl(Context, PDecl);
   CheckObjCDeclScope(PDecl);
   return DeclPtrTy::make(PDecl);
 }
@@ -544,7 +544,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
   ObjCCategoryDecl *CDecl = 
     ObjCCategoryDecl::Create(Context, CurContext, AtInterfaceLoc, CategoryName);
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(CDecl);
+  CurContext->addDecl(Context, CDecl);
 
   ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
   /// Check that class of this category is already completely declared.
@@ -598,7 +598,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
     Diag(ClassLoc, diag::err_undef_interface) << ClassName;
 
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(CDecl);
+  CurContext->addDecl(Context, CDecl);
 
   /// TODO: Check that CatName, category name, is not used in another
   // implementation.
@@ -663,7 +663,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
     IDecl->setLocEnd(ClassLoc);
     
     // FIXME: PushOnScopeChains?
-    CurContext->addDecl(IDecl);
+    CurContext->addDecl(Context, IDecl);
     // Remember that this needs to be removed when the scope is popped.
     TUScope->AddDecl(DeclPtrTy::make(IDecl));
   }
@@ -673,7 +673,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
                                    IDecl, SDecl);
   
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(IMPDecl);
+  CurContext->addDecl(Context, IMPDecl);
 
   if (CheckObjCDeclScope(IMPDecl))
     return DeclPtrTy::make(IMPDecl);
@@ -797,7 +797,7 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl,
     return false;
   // Even if property is ready only, if interface has a user defined setter, 
   // it is not considered read only.
-  if (IDecl->getInstanceMethod(PDecl->getSetterName()))
+  if (IDecl->getInstanceMethod(Context, PDecl->getSetterName()))
     return false;
   
   // Main class has the property as 'readonly'. Must search
@@ -807,10 +807,10 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl,
        Category; Category = Category->getNextClassCategory()) {
     // Even if property is ready only, if a category has a user defined setter, 
     // it is not considered read only. 
-    if (Category->getInstanceMethod(PDecl->getSetterName()))
+    if (Category->getInstanceMethod(Context, PDecl->getSetterName()))
       return false;
     ObjCPropertyDecl *P = 
-    Category->FindPropertyDeclaration(PDecl->getIdentifier());
+      Category->FindPropertyDeclaration(Context, PDecl->getIdentifier());
     if (P && !P->isReadOnly())
       return false;
   }
@@ -863,28 +863,31 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
   // and otherwise would terminate in a warning.
 
   // check unimplemented instance methods.
-  for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), 
-       E = PDecl->instmeth_end(); I != E; ++I) {
+  for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(Context), 
+       E = PDecl->instmeth_end(Context); I != E; ++I) {
     ObjCMethodDecl *method = *I;
     if (method->getImplementationControl() != ObjCMethodDecl::Optional && 
         !method->isSynthesized() && !InsMap.count(method->getSelector()) &&
-        (!Super || !Super->lookupInstanceMethod(method->getSelector()))) {
+        (!Super || 
+         !Super->lookupInstanceMethod(Context, method->getSelector()))) {
         // Ugly, but necessary. Method declared in protcol might have
         // have been synthesized due to a property declared in the class which
         // uses the protocol.
         ObjCMethodDecl *MethodInClass = 
-          IDecl->lookupInstanceMethod(method->getSelector());
+          IDecl->lookupInstanceMethod(Context, method->getSelector());
         if (!MethodInClass || !MethodInClass->isSynthesized())
           WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
       }
   }
   // check unimplemented class methods
-  for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), 
-       E = PDecl->classmeth_end(); I != E; ++I) {
+  for (ObjCProtocolDecl::classmeth_iterator 
+         I = PDecl->classmeth_begin(Context),
+         E = PDecl->classmeth_end(Context);
+       I != E; ++I) {
     ObjCMethodDecl *method = *I;
     if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
         !ClsMap.count(method->getSelector()) &&
-        (!Super || !Super->lookupClassMethod(method->getSelector())))
+        (!Super || !Super->lookupClassMethod(Context, method->getSelector())))
       WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
   }
   // Check on this protocols's referenced protocols, recursively.
@@ -900,11 +903,11 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
   // Check and see if instance methods in class interface have been
   // implemented in the implementation class.
   for (ObjCImplementationDecl::instmeth_iterator I = IMPDecl->instmeth_begin(),
-       E = IMPDecl->instmeth_end(); I != E; ++I)
+         E = IMPDecl->instmeth_end(); I != E; ++I)
     InsMap.insert((*I)->getSelector());
   
-  for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(),
-       E = CDecl->instmeth_end(); I != E; ++I) {
+  for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(Context),
+       E = CDecl->instmeth_end(Context); I != E; ++I) {
     if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector())) {
       WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
       continue;
@@ -913,7 +916,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
     ObjCMethodDecl *ImpMethodDecl = 
       IMPDecl->getInstanceMethod((*I)->getSelector());
     ObjCMethodDecl *IntfMethodDecl = 
-      CDecl->getInstanceMethod((*I)->getSelector());
+      CDecl->getInstanceMethod(Context, (*I)->getSelector());
     assert(IntfMethodDecl && 
            "IntfMethodDecl is null in ImplMethodsVsClassMethods");
     // ImpMethodDecl may be null as in a @dynamic property.
@@ -928,15 +931,17 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
        E = IMPDecl->classmeth_end(); I != E; ++I)
     ClsMap.insert((*I)->getSelector());
   
-  for (ObjCInterfaceDecl::classmeth_iterator I = CDecl->classmeth_begin(),
-       E = CDecl->classmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::classmeth_iterator 
+         I = CDecl->classmeth_begin(Context),
+         E = CDecl->classmeth_end(Context);
+       I != E; ++I)
     if (!ClsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
     else {
       ObjCMethodDecl *ImpMethodDecl = 
         IMPDecl->getClassMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
-        CDecl->getClassMethod((*I)->getSelector());
+        CDecl->getClassMethod(Context, (*I)->getSelector());
       WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
   
@@ -1002,7 +1007,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
       ObjCInterfaceDecls[IdentList[i]] = IDecl;
 
       // FIXME: PushOnScopeChains?
-      CurContext->addDecl(IDecl);
+      CurContext->addDecl(Context, IDecl);
       // Remember that this needs to be removed when the scope is popped.
       TUScope->AddDecl(DeclPtrTy::make(IDecl));
     }
@@ -1013,7 +1018,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
   ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc,
                                                &Interfaces[0],
                                                Interfaces.size());
-  CurContext->addDecl(CDecl);
+  CurContext->addDecl(Context, CDecl);
   CheckObjCDeclScope(CDecl);
   return DeclPtrTy::make(CDecl);
 }
@@ -1138,8 +1143,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
                                ObjCContainerDecl *CD) {
   ObjCMethodDecl *GetterMethod, *SetterMethod;
   
-  GetterMethod = CD->getInstanceMethod(property->getGetterName());  
-  SetterMethod = CD->getInstanceMethod(property->getSetterName());
+  GetterMethod = CD->getInstanceMethod(Context, property->getGetterName());  
+  SetterMethod = CD->getInstanceMethod(Context, property->getSetterName());
   
   if (GetterMethod &&
       GetterMethod->getResultType() != property->getType()) {
@@ -1182,7 +1187,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
                               ObjCPropertyDecl::Optional) ? 
                              ObjCMethodDecl::Optional : 
                              ObjCMethodDecl::Required);
-    CD->addDecl(GetterMethod);
+    CD->addDecl(Context, GetterMethod);
   } else
     // A user declared getter will be synthesize when @synthesize of
     // the property with the same name is seen in the @implementation
@@ -1213,7 +1218,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
                                                   VarDecl::None,
                                                   0);
       SetterMethod->setMethodParams(&Argument, 1, Context);
-      CD->addDecl(SetterMethod);
+      CD->addDecl(Context, SetterMethod);
     } else
       // A user declared setter will be synthesize when @synthesize of
       // the property with the same name is seen in the @implementation
@@ -1279,7 +1284,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
             << Method->getDeclName();
           Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
       } else {
-        DC->addDecl(Method);
+        DC->addDecl(Context, Method);
         InsMap[Method->getSelector()] = Method;
         /// The following allows us to typecheck messages to "id".
         AddInstanceMethodToGlobalPool(Method);
@@ -1296,7 +1301,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
           << Method->getDeclName();
         Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
       } else {
-        DC->addDecl(Method);
+        DC->addDecl(Context, Method);
         ClsMap[Method->getSelector()] = Method;
         /// The following allows us to typecheck messages to "Class".
         AddFactoryMethodToGlobalPool(Method);
@@ -1322,8 +1327,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
     // ProcessPropertyDecl is responsible for diagnosing conflicts with any
     // user-defined setter/getter. It also synthesizes setter/getter methods
     // and adds them to the DeclContext and global method pools.
-    for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(),
-                                          E = CDecl->prop_end(); I != E; ++I)
+    for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(Context),
+                                          E = CDecl->prop_end(Context);
+         I != E; ++I)
       ProcessPropertyDecl(*I, CDecl);
     CDecl->setAtEndLoc(AtEndLoc);
   }
@@ -1612,8 +1618,10 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
         // Find the property in continuation class's primary class only.
         ObjCPropertyDecl *PIDecl = 0;
         IdentifierInfo *PropertyId = FD.D.getIdentifier();
-        for (ObjCInterfaceDecl::prop_iterator I = CCPrimary->prop_begin(), 
-             E = CCPrimary->prop_end(); I != E; ++I)
+        for (ObjCInterfaceDecl::prop_iterator 
+               I = CCPrimary->prop_begin(Context),
+               E = CCPrimary->prop_end(Context);
+             I != E; ++I)
           if ((*I)->getIdentifier() == PropertyId) {
             PIDecl = *I;
             break;
@@ -1671,7 +1679,7 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
   assert(DC && "ClassDecl is not a DeclContext");
   ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, AtLoc, 
                                                      FD.D.getIdentifier(), T);
-  DC->addDecl(PDecl);
+  DC->addDecl(Context, PDecl);
   
   ProcessDeclAttributes(PDecl, FD.D);
 
@@ -1747,7 +1755,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
            "ActOnPropertyImplDecl - @implementation without @interface");
     
     // Look for this property declaration in the @implementation's @interface
-    property = IDecl->FindPropertyDeclaration(PropertyId);
+    property = IDecl->FindPropertyDeclaration(Context, PropertyId);
     if (!property) {
       Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName();
       return DeclPtrTy();
@@ -1771,7 +1779,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
     if (!Category)
       return DeclPtrTy();
     // Look for this property declaration in @implementation's category
-    property = Category->FindPropertyDeclaration(PropertyId);
+    property = Category->FindPropertyDeclaration(Context, PropertyId);
     if (!property) {
       Diag(PropertyLoc, diag::error_bad_category_property_decl)
         << Category->getDeclName();
@@ -1789,7 +1797,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
       PropertyIvar = PropertyId;
     QualType PropType = Context.getCanonicalType(property->getType());
     // Check that this is a previously declared 'ivar' in 'IDecl' interface
-    Ivar = IDecl->lookupInstanceVariable(PropertyIvar);
+    Ivar = IDecl->lookupInstanceVariable(Context, PropertyIvar);
     if (!Ivar) {
       if (getLangOptions().ObjCNonFragileABI) {
         Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc, 
@@ -1851,7 +1859,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
                                   ObjCPropertyImplDecl::Synthesize 
                                   : ObjCPropertyImplDecl::Dynamic),
                                  Ivar);
-  CurContext->addDecl(PIDecl);
+  CurContext->addDecl(Context, PIDecl);
   if (IC) {
     if (Synthesize)
       if (ObjCPropertyImplDecl *PPIDecl = 
@@ -1943,7 +1951,7 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
     if (getLangOptions().CPlusPlus)
       PushOnScopeChains(cast<FieldDecl>(FD), S);
     else if (RecordDecl *Record = dyn_cast<RecordDecl>(TagD.getAs<Decl>()))
-      Record->addDecl(FD);
+      Record->addDecl(Context, FD);
   }
 }
 
index cb7a90fffc627a9bcbef9715153d2fe59f49e8e3..dda8654b49bde2e5648d3e2ca74c63218db277a2 100644 (file)
@@ -58,7 +58,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
         if (ObjCImplementationDecl *Impl
               = dyn_cast<ObjCImplementationDecl>(MD->getParent())) {
           
-          MD = Impl->getClassInterface()->getMethod(MD->getSelector(),
+          MD = Impl->getClassInterface()->getMethod(Context, 
+                                                    MD->getSelector(),
                                                     MD->isInstanceMethod());
           isSilenced |= MD && MD->getAttr<DeprecatedAttr>();
         }
@@ -449,7 +450,8 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
 /// getObjectForAnonymousRecordDecl - Retrieve the (unnamed) field or
 /// variable corresponding to the anonymous union or struct whose type
 /// is Record.
-static Decl *getObjectForAnonymousRecordDecl(RecordDecl *Record) {
+static Decl *getObjectForAnonymousRecordDecl(ASTContext &Context,
+                                             RecordDecl *Record) {
   assert(Record->isAnonymousStructOrUnion() && 
          "Record must be an anonymous struct or union!");
   
@@ -458,8 +460,8 @@ static Decl *getObjectForAnonymousRecordDecl(RecordDecl *Record) {
   // vector (which itself will be eliminated). DeclGroups might make
   // this even better.
   DeclContext *Ctx = Record->getDeclContext();
-  for (DeclContext::decl_iterator D = Ctx->decls_begin(), 
-                               DEnd = Ctx->decls_end();
+  for (DeclContext::decl_iterator D = Ctx->decls_begin(Context), 
+                               DEnd = Ctx->decls_end(Context);
        D != DEnd; ++D) {
     if (*D == Record) {
       // The object for the anonymous struct/union directly
@@ -495,7 +497,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
   DeclContext *Ctx = Field->getDeclContext();
   do {
     RecordDecl *Record = cast<RecordDecl>(Ctx);
-    Decl *AnonObject = getObjectForAnonymousRecordDecl(Record);
+    Decl *AnonObject = getObjectForAnonymousRecordDecl(Context, Record);
     if (FieldDecl *AnonField = dyn_cast<FieldDecl>(AnonObject))
       AnonFields.push_back(AnonField);
     else {
@@ -643,7 +645,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
     if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) {
       ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
       ObjCInterfaceDecl *ClassDeclared;
-      if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
+      if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(Context, II, 
+                                                           ClassDeclared)) {
         // Check if referencing a field with __attribute__((deprecated)).
         if (DiagnoseUseOfDecl(IV, Loc))
           return ExprError();
@@ -675,7 +678,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
       // We should warn if a local variable hides an ivar.
       ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
       ObjCInterfaceDecl *ClassDeclared;
-      if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
+      if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(Context, II, 
+                                                           ClassDeclared)) {
         if (IV->getAccessControl() != ObjCIvarDecl::Private ||
             IFace == ClassDeclared)
           Diag(Loc, diag::warn_ivar_use_hidden)<<IV->getDeclName();
@@ -1695,16 +1699,18 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
 
 static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl,
                                                 IdentifierInfo &Member,
-                                                const Selector &Sel) {
+                                                const Selector &Sel,
+                                                ASTContext &Context) {
   
-  if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(&Member))
+  if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(Context, &Member))
     return PD;
-  if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Sel))
+  if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Context, Sel))
     return OMD;
   
   for (ObjCProtocolDecl::protocol_iterator I = PDecl->protocol_begin(),
        E = PDecl->protocol_end(); I != E; ++I) {
-    if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel))
+    if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel, 
+                                                     Context))
       return D;
   }
   return 0;
@@ -1712,17 +1718,18 @@ static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl,
 
 static Decl *FindGetterNameDecl(const ObjCQualifiedIdType *QIdTy,
                                 IdentifierInfo &Member,
-                                const Selector &Sel) {
+                                const Selector &Sel,
+                                ASTContext &Context) {
   // Check protocols on qualified interfaces.
   Decl *GDecl = 0;
   for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(),
        E = QIdTy->qual_end(); I != E; ++I) {
-    if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) {
+    if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(Context, &Member)) {
       GDecl = PD;
       break;
     }
     // Also must look for a getter name which uses property syntax.
-    if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Sel)) {
+    if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Context, Sel)) {
       GDecl = OMD;
       break;
     }
@@ -1731,7 +1738,7 @@ static Decl *FindGetterNameDecl(const ObjCQualifiedIdType *QIdTy,
     for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(),
          E = QIdTy->qual_end(); I != E; ++I) {
       // Search in the protocol-qualifier list of current protocol.
-      GDecl = FindGetterNameDeclFromProtocolList(*I, Member, Sel);
+      GDecl = FindGetterNameDeclFromProtocolList(*I, Member, Sel, Context);
       if (GDecl)
         return GDecl;
     }
@@ -1875,7 +1882,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
   // (*Obj).ivar.
   if (const ObjCInterfaceType *IFTy = BaseType->getAsObjCInterfaceType()) {
     ObjCInterfaceDecl *ClassDeclared;
-    if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member, 
+    if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(Context,
+                                                                   &Member, 
                                                              ClassDeclared)) {
       // If the decl being referenced had an error, return an error for this
       // sub-expr without emitting another error, in order to avoid cascading
@@ -1937,7 +1945,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
     ObjCInterfaceDecl *IFace = IFTy->getDecl();
 
     // Search for a declared property first.
-    if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(&Member)) {
+    if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Context, 
+                                                              &Member)) {
       // Check whether we can reference this property.
       if (DiagnoseUseOfDecl(PD, MemberLoc))
         return ExprError();
@@ -1949,7 +1958,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
     // Check protocols on qualified interfaces.
     for (ObjCInterfaceType::qual_iterator I = IFTy->qual_begin(),
          E = IFTy->qual_end(); I != E; ++I)
-      if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) {
+      if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(Context,
+                                                               &Member)) {
         // Check whether we can reference this property.
         if (DiagnoseUseOfDecl(PD, MemberLoc))
           return ExprError();
@@ -1965,7 +1975,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
     // shared with the code in ActOnInstanceMessage.
 
     Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
-    ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel);
+    ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Context, Sel);
 
     // If this reference is in an @implementation, check for 'private' methods.
     if (!Getter)
@@ -1988,7 +1998,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
     Selector SetterSel = 
       SelectorTable::constructSetterName(PP.getIdentifierTable(), 
                                          PP.getSelectorTable(), &Member);
-    ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
+    ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(Context, SetterSel);
     if (!Setter) {
       // If this reference is in an @implementation, also check for 'private'
       // methods.
@@ -2027,7 +2037,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
   if (OpKind == tok::period && (QIdTy = BaseType->getAsObjCQualifiedIdType())) {
     // Check protocols on qualified interfaces.
     Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
-    if (Decl *PMDecl = FindGetterNameDecl(QIdTy, Member, Sel)) {
+    if (Decl *PMDecl = FindGetterNameDecl(QIdTy, Member, Sel, Context)) {
       if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(PMDecl)) {
         // Check the use of this declaration
         if (DiagnoseUseOfDecl(PD, MemberLoc))
@@ -2059,7 +2069,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
       ObjCInterfaceDecl *IFace = MD->getClassInterface();
       ObjCMethodDecl *Getter;
       // FIXME: need to also look locally in the implementation.
-      if ((Getter = IFace->lookupClassMethod(Sel))) {
+      if ((Getter = IFace->lookupClassMethod(Context, Sel))) {
         // Check the use of this method.
         if (DiagnoseUseOfDecl(Getter, MemberLoc))
           return ExprError();
@@ -2069,7 +2079,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
       Selector SetterSel = 
         SelectorTable::constructSetterName(PP.getIdentifierTable(), 
                                            PP.getSelectorTable(), &Member);
-      ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
+      ObjCMethodDecl *Setter = IFace->lookupClassMethod(Context, SetterSel);
       if (!Setter) {
         // If this reference is in an @implementation, also check for 'private'
         // methods.
@@ -2481,7 +2491,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) {
       // GCC cast to union extension
       RecordDecl *RD = castType->getAsRecordType()->getDecl();
       RecordDecl::field_iterator Field, FieldEnd;
-      for (Field = RD->field_begin(), FieldEnd = RD->field_end();
+      for (Field = RD->field_begin(Context), FieldEnd = RD->field_end(Context);
            Field != FieldEnd; ++Field) {
         if (Context.getCanonicalType(Field->getType()).getUnqualifiedType() ==
             Context.getCanonicalType(castExpr->getType()).getUnqualifiedType()) {
index 361434a0dd95845c2cbafb24eac0b6d823357614..4a5bfd59ae5f82ff191d312d1543799f06f496a3 100644 (file)
@@ -454,7 +454,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
                                   bool AllowMissing, FunctionDecl *&Operator)
 {
   DeclContext::lookup_iterator Alloc, AllocEnd;
-  llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Name);
+  llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Context, Name);
   if (Alloc == AllocEnd) {
     if (AllowMissing)
       return false;
@@ -561,7 +561,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
   // Check if this function is already declared.
   {
     DeclContext::lookup_iterator Alloc, AllocEnd;
-    for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Name);
+    for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Context, Name);
          Alloc != AllocEnd; ++Alloc) {
       // FIXME: Do we need to check for default arguments here?
       FunctionDecl *Func = cast<FunctionDecl>(*Alloc);
@@ -584,7 +584,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
   // FIXME: Also add this declaration to the IdentifierResolver, but
   // make sure it is at the end of the chain to coincide with the
   // global scope.
-  ((DeclContext *)TUScope->getEntity())->addDecl(Alloc);
+  ((DeclContext *)TUScope->getEntity())->addDecl(Context, Alloc);
 }
 
 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
index 54ed709d0f45b0461e3194e5e73409cfbe25d2c3..54a18ac832a2a46b4ea98ebe3ec34bd57d95c21f 100644 (file)
@@ -238,7 +238,7 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel,
     // But only in the root. This matches gcc's behaviour and what the
     // runtime expects.
     if (!Method && !ClassDecl->getSuperClass()) {
-      Method = ClassDecl->lookupInstanceMethod(Sel);
+      Method = ClassDecl->lookupInstanceMethod(Context, Sel);
       // Look through local category implementations associated 
       // with the root class.
       if (!Method) 
@@ -282,7 +282,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr(
   // Search for a declared property first.
   
   Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName);
-  ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel);
+  ObjCMethodDecl *Getter = IFace->lookupClassMethod(Context, Sel);
 
   // If this reference is in an @implementation, check for 'private' methods.
   if (!Getter)
@@ -304,7 +304,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr(
     SelectorTable::constructSetterName(PP.getIdentifierTable(), 
                                        PP.getSelectorTable(), &propertyName);
     
-  ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
+  ObjCMethodDecl *Setter = IFace->lookupClassMethod(Context, SetterSel);
   if (!Setter) {
     // If this reference is in an @implementation, also check for 'private'
     // methods.
@@ -422,7 +422,7 @@ Sema::ExprResult Sema::ActOnClassMessage(
   assert(ClassDecl && "missing interface declaration");
   ObjCMethodDecl *Method = 0;
   QualType returnType;
-  Method = ClassDecl->lookupClassMethod(Sel);
+  Method = ClassDecl->lookupClassMethod(Context, Sel);
   
   // If we have an implementation in scope, check "private" methods.
   if (!Method)
@@ -473,7 +473,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
       // If we have an interface in scope, check 'super' methods.
       if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
         if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass()) {
-          Method = SuperDecl->lookupInstanceMethod(Sel);
+          Method = SuperDecl->lookupInstanceMethod(Context, Sel);
           
           if (!Method) 
             // If we have implementations in scope, check "private" methods.
@@ -512,7 +512,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
     if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
       if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) {
         // First check the public methods in the class interface.
-        Method = ClassDecl->lookupClassMethod(Sel);
+        Method = ClassDecl->lookupClassMethod(Context, Sel);
         
         if (!Method)
           Method = LookupPrivateClassMethod(Sel, ClassDecl);
@@ -546,10 +546,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
     // Search protocols for instance methods.
     for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
       ObjCProtocolDecl *PDecl = QIT->getProtocols(i);
-      if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel)))
+      if (PDecl && (Method = PDecl->lookupInstanceMethod(Context, Sel)))
         break;
       // Since we aren't supporting "Class<foo>", look for a class method.
-      if (PDecl && (Method = PDecl->lookupClassMethod(Sel)))
+      if (PDecl && (Method = PDecl->lookupClassMethod(Context, Sel)))
         break;
     }
   } else if (const ObjCInterfaceType *OCIType = 
@@ -560,13 +560,13 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
     // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be
     // faster than the following method (which can do *many* linear searches). 
     // The idea is to add class info to InstanceMethodPool.
-    Method = ClassDecl->lookupInstanceMethod(Sel);
+    Method = ClassDecl->lookupInstanceMethod(Context, Sel);
     
     if (!Method) {
       // Search protocol qualifiers.
       for (ObjCQualifiedInterfaceType::qual_iterator QI = OCIType->qual_begin(),
            E = OCIType->qual_end(); QI != E; ++QI) {
-        if ((Method = (*QI)->lookupInstanceMethod(Sel)))
+        if ((Method = (*QI)->lookupInstanceMethod(Context, Sel)))
           break;
       }
     }
index c01430c9ee589a54561623bd0309e93ea05b9ab8..8239f54d68a7b03d0940f7f5ab99112992224bb2 100644 (file)
@@ -179,7 +179,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class,
       FoundPathToThisBase 
         = (Context.getCanonicalType(BaseSpec->getType()) == Criteria.Base);
     } else {
-      Paths.ScratchPath.Decls = BaseRecord->lookup(Criteria.Name);
+      Paths.ScratchPath.Decls = BaseRecord->lookup(Context, Criteria.Name);
       while (Paths.ScratchPath.Decls.first != Paths.ScratchPath.Decls.second) {
         if (isAcceptableLookupResult(*Paths.ScratchPath.Decls.first,
                                      Criteria.NameKind, Criteria.IDNS)) {
index f8890c389b56d667a11815e224b554e0529c6580..7da1f6bb23f2caa7cc6917ad50b82847269a06ef 100644 (file)
@@ -324,8 +324,9 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
   
   if (const RecordType *RType = ILE->getType()->getAsRecordType()) {
     unsigned Init = 0, NumInits = ILE->getNumInits();
-    for (RecordDecl::field_iterator Field = RType->getDecl()->field_begin(),
-                                 FieldEnd = RType->getDecl()->field_end();
+    for (RecordDecl::field_iterator 
+           Field = RType->getDecl()->field_begin(SemaRef.Context),
+           FieldEnd = RType->getDecl()->field_end(SemaRef.Context);
          Field != FieldEnd; ++Field) {
       if (Field->isUnnamedBitfield())
         continue;
@@ -431,8 +432,9 @@ int InitListChecker::numArrayElements(QualType DeclType) {
 int InitListChecker::numStructUnionElements(QualType DeclType) {
   RecordDecl *structDecl = DeclType->getAsRecordType()->getDecl();
   int InitializableMembers = 0;
-  for (RecordDecl::field_iterator Field = structDecl->field_begin(),
-                               FieldEnd = structDecl->field_end();
+  for (RecordDecl::field_iterator 
+         Field = structDecl->field_begin(SemaRef.Context),
+         FieldEnd = structDecl->field_end(SemaRef.Context);
        Field != FieldEnd; ++Field) {
     if ((*Field)->getIdentifier() || !(*Field)->isBitField())
       ++InitializableMembers;
@@ -559,7 +561,7 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList,
   } else if (DeclType->isAggregateType()) {
     if (DeclType->isRecordType()) {
       RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
-      CheckStructUnionTypes(IList, DeclType, RD->field_begin(), 
+      CheckStructUnionTypes(IList, DeclType, RD->field_begin(SemaRef.Context), 
                             SubobjectIsDesignatorContext, Index,
                             StructuredList, StructuredIndex,
                             TopLevelObject);
@@ -927,7 +929,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
   if (DeclType->isUnionType() && IList->getNumInits() == 0) {
     // Value-initialize the first named member of the union.
     RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
-    for (RecordDecl::field_iterator FieldEnd = RD->field_end();
+    for (RecordDecl::field_iterator FieldEnd = RD->field_end(SemaRef.Context);
          Field != FieldEnd; ++Field) {
       if (Field->getDeclName()) {
         StructuredList->setInitializedFieldInUnion(*Field);
@@ -942,7 +944,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
   // because an error should get printed out elsewhere. It might be
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
-  RecordDecl::field_iterator FieldEnd = RD->field_end();
+  RecordDecl::field_iterator FieldEnd = RD->field_end(SemaRef.Context);
   bool InitializedSomething = false;
   while (Index < IList->getNumInits()) {
     Expr *Init = IList->getInit(Index);
@@ -1136,8 +1138,9 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
     // need to compute the field's index.
     IdentifierInfo *FieldName = D->getFieldName();
     unsigned FieldIndex = 0;
-    RecordDecl::field_iterator Field = RT->getDecl()->field_begin(),
-                            FieldEnd = RT->getDecl()->field_end();
+    RecordDecl::field_iterator 
+      Field = RT->getDecl()->field_begin(SemaRef.Context),
+      FieldEnd = RT->getDecl()->field_end(SemaRef.Context);
     for (; Field != FieldEnd; ++Field) {
       if (Field->isUnnamedBitfield())
         continue;
@@ -1151,7 +1154,8 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
     if (Field == FieldEnd) {
       // We did not find the field we're looking for. Produce a
       // suitable diagnostic and return a failure.
-      DeclContext::lookup_result Lookup = RT->getDecl()->lookup(FieldName);
+      DeclContext::lookup_result Lookup 
+        = RT->getDecl()->lookup(SemaRef.Context, FieldName);
       if (Lookup.first == Lookup.second) {
         // Name lookup didn't find anything.
         SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
@@ -1478,7 +1482,8 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
     if (RDecl->isUnion())
       NumElements = 1;
     else
-      NumElements = std::distance(RDecl->field_begin(), RDecl->field_end());
+      NumElements = std::distance(RDecl->field_begin(SemaRef.Context), 
+                                  RDecl->field_end(SemaRef.Context));
   }
 
   if (NumElements < NumInits)
index d85123c85369db2adec485f2fda06c29bd633ce6..0b11d9cf68c9835042094221fd25420c141c7e76 100644 (file)
@@ -57,23 +57,25 @@ struct UsingDirAncestorCompare {
 /// AddNamespaceUsingDirectives - Adds all UsingDirectiveDecl's to heap UDirs
 /// (ordered by common ancestors), found in namespace NS,
 /// including all found (recursively) in their nominated namespaces.
-void AddNamespaceUsingDirectives(DeclContext *NS,
+void AddNamespaceUsingDirectives(ASTContext &Context, 
+                                 DeclContext *NS,
                                  UsingDirectivesTy &UDirs,
                                  NamespaceSet &Visited) {
   DeclContext::udir_iterator I, End;
 
-  for (llvm::tie(I, End) = NS->getUsingDirectives(); I !=End; ++I) {
+  for (llvm::tie(I, End) = NS->getUsingDirectives(Context); I !=End; ++I) {
     UDirs.push_back(*I);
     std::push_heap(UDirs.begin(), UDirs.end(), UsingDirAncestorCompare());
     NamespaceDecl *Nominated = (*I)->getNominatedNamespace();
     if (Visited.insert(Nominated).second)
-      AddNamespaceUsingDirectives(Nominated, UDirs, /*ref*/ Visited);
+      AddNamespaceUsingDirectives(Context, Nominated, UDirs, /*ref*/ Visited);
   }
 }
 
 /// AddScopeUsingDirectives - Adds all UsingDirectiveDecl's found in Scope S,
 /// including all found in the namespaces they nominate.
-static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) {
+static void AddScopeUsingDirectives(ASTContext &Context, Scope *S, 
+                                    UsingDirectivesTy &UDirs) {
   NamespaceSet VisitedNS;
 
   if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity())) {
@@ -81,7 +83,7 @@ static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) {
     if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(Ctx))
       VisitedNS.insert(NS);
 
-    AddNamespaceUsingDirectives(Ctx, UDirs, /*ref*/ VisitedNS);
+    AddNamespaceUsingDirectives(Context, Ctx, UDirs, /*ref*/ VisitedNS);
 
   } else {
     Scope::udir_iterator I = S->using_directives_begin(),
@@ -95,7 +97,8 @@ static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) {
       NamespaceDecl *Nominated = UD->getNominatedNamespace();
       if (!VisitedNS.count(Nominated)) {
         VisitedNS.insert(Nominated);
-        AddNamespaceUsingDirectives(Nominated, UDirs, /*ref*/ VisitedNS);
+        AddNamespaceUsingDirectives(Context, Nominated, UDirs, 
+                                    /*ref*/ VisitedNS);
       }
     }
   }
@@ -569,7 +572,7 @@ CppNamespaceLookup(ASTContext &Context, DeclContext *NS,
 
   // Perform qualified name lookup into the LookupCtx.
   DeclContext::lookup_iterator I, E;
-  for (llvm::tie(I, E) = NS->lookup(Name); I != E; ++I)
+  for (llvm::tie(I, E) = NS->lookup(Context, Name); I != E; ++I)
     if (Sema::isAcceptableLookupResult(*I, NameKind, IDNS)) {
       Results.push_back(Sema::LookupResult::CreateLookupResult(Context, I, E));
       break;
@@ -682,7 +685,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
   UsingDirectivesTy UDirs;
   for (Scope *SC = Initial; SC; SC = SC->getParent())
     if (SC->getFlags() & Scope::DeclScope)
-      AddScopeUsingDirectives(SC, UDirs);
+      AddScopeUsingDirectives(Context, SC, UDirs);
 
   // Sort heapified UsingDirectiveDecls.
   std::sort_heap(UDirs.begin(), UDirs.end());
@@ -967,7 +970,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
 
   // Perform qualified name lookup into the LookupCtx.
   DeclContext::lookup_iterator I, E;
-  for (llvm::tie(I, E) = LookupCtx->lookup(Name); I != E; ++I)
+  for (llvm::tie(I, E) = LookupCtx->lookup(Context, Name); I != E; ++I)
     if (isAcceptableLookupResult(*I, NameKind, IDNS))
       return LookupResult::CreateLookupResult(Context, I, E);
 
@@ -1544,7 +1547,7 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
     //        namespaces even if they are not visible during an ordinary
     //        lookup (11.4).
     DeclContext::lookup_iterator I, E;
-    for (llvm::tie(I, E) = (*NS)->lookup(Name); I != E; ++I) {
+    for (llvm::tie(I, E) = (*NS)->lookup(Context, Name); I != E; ++I) {
       FunctionDecl *Func = dyn_cast<FunctionDecl>(*I);
       if (!Func)
         break;
index 3afd454f1ba0a7bf1536a46c00074e7a23ff26e5..0a12a71bb74f0590dfaa088c7885b31f1165f00e 100644 (file)
@@ -1334,7 +1334,8 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
         = Context.DeclarationNames.getCXXConstructorName(
                           Context.getCanonicalType(ToType).getUnqualifiedType());
       DeclContext::lookup_iterator Con, ConEnd;
-      for (llvm::tie(Con, ConEnd) = ToRecordDecl->lookup(ConstructorName);
+      for (llvm::tie(Con, ConEnd) 
+             = ToRecordDecl->lookup(Context, ConstructorName);
            Con != ConEnd; ++Con) {
         CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
         if (Constructor->isConvertingConstructor())
@@ -2395,7 +2396,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
   // FIXME: Lookup in base classes, too!
   if (const RecordType *T1Rec = T1->getAsRecordType()) {
     DeclContext::lookup_const_iterator Oper, OperEnd;
-    for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(OpName);
+    for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(Context, OpName);
          Oper != OperEnd; ++Oper)
       AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Args[0], 
                          Args+1, NumArgs - 1, CandidateSet,
@@ -4033,7 +4034,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
   OverloadCandidateSet CandidateSet;
   DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Call);
   DeclContext::lookup_const_iterator Oper, OperEnd;
-  for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(OpName);
+  for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(Context, OpName);
        Oper != OperEnd; ++Oper)
     AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Object, Args, NumArgs, 
                        CandidateSet, /*SuppressUserConversions=*/false);
@@ -4234,7 +4235,8 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
   const RecordType *BaseRecord = Base->getType()->getAsRecordType();
   
   DeclContext::lookup_const_iterator Oper, OperEnd;
-  for (llvm::tie(Oper, OperEnd) = BaseRecord->getDecl()->lookup(OpName);
+  for (llvm::tie(Oper, OperEnd) 
+         = BaseRecord->getDecl()->lookup(Context, OpName);
        Oper != OperEnd; ++Oper)
     AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Base, 0, 0, CandidateSet,
                        /*SuppressUserConversions=*/false);
index d30726c766aa708a10e28f526810bd7eff0a1590..6e6021ae948f2ea073d3a4fd3811b80058c15c2b 100644 (file)
@@ -2097,7 +2097,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
   // Add the specialization into its lexical context, so that it can
   // be seen when iterating through the list of declarations in that
   // context. However, specializations are not found by name lookup.
-  CurContext->addDecl(Specialization);
+  CurContext->addDecl(Context, Specialization);
   return DeclPtrTy::make(Specialization);
 }
 
index a041d06bf20ce016c9da9a83aea1858a5be5729f..1a67fd124849997b2131f4b679a107868730dd84 100644 (file)
@@ -728,8 +728,9 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
     Invalid = true;
 
   llvm::SmallVector<DeclPtrTy, 32> Fields;
-  for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
-       MemberEnd = Pattern->decls_end(); Member != MemberEnd; ++Member) {
+  for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context),
+         MemberEnd = Pattern->decls_end(Context); 
+       Member != MemberEnd; ++Member) {
     Decl *NewMember = InstantiateDecl(*Member, Instantiation,
                                       TemplateArgs, NumTemplateArgs);
     if (NewMember) {
index e7210b3431ba235f92ed2549470bf89b6cb63dcd..4639511023c6450e9b37274caea933f10306f166 100644 (file)
@@ -99,7 +99,7 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
   if (Invalid)
     Typedef->setInvalidDecl();
 
-  Owner->addDecl(Typedef);
+  Owner->addDecl(SemaRef.Context, Typedef);
   return Typedef;
 }
 
@@ -127,7 +127,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
   if (SemaRef.CheckVariableDeclaration(Var, 0, Redeclaration))
     Var->setInvalidDecl();
 
-  Owner->addDecl(Var);
+  Owner->addDecl(SemaRef.Context, Var);
 
   if (D->getInit()) {
     OwningExprResult Init 
@@ -187,7 +187,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
     if (Invalid)
       Field->setInvalidDecl();
     
-    Owner->addDecl(Field);
+    Owner->addDecl(SemaRef.Context, Field);
   }
 
   return Field;
@@ -214,14 +214,14 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
                                     D->getLocation(), D->getIdentifier(),
                                     /*PrevDecl=*/0);
   Enum->setAccess(D->getAccess());
-  Owner->addDecl(Enum);
+  Owner->addDecl(SemaRef.Context, Enum);
   Enum->startDefinition();
 
   llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators;
 
   EnumConstantDecl *LastEnumConst = 0;
-  for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(),
-         ECEnd = D->enumerator_end();
+  for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(SemaRef.Context),
+         ECEnd = D->enumerator_end(SemaRef.Context);
        EC != ECEnd; ++EC) {
     // The specified value for the enumerator.
     OwningExprResult Value = SemaRef.Owned((Expr *)0);
@@ -248,7 +248,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
     }
 
     if (EnumConst) {
-      Enum->addDecl(EnumConst);
+      Enum->addDecl(SemaRef.Context, EnumConst);
       Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst));
       LastEnumConst = EnumConst;
     }
@@ -281,7 +281,7 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
   else
     Record->setDescribedClassTemplate(D->getDescribedClassTemplate());
 
-  Owner->addDecl(Record);
+  Owner->addDecl(SemaRef.Context, Record);
   return Record;
 }
 
@@ -327,7 +327,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
     Method->setInvalidDecl();
 
   if (!Method->isInvalidDecl() || !PrevDecl)
-    Owner->addDecl(Method);
+    Owner->addDecl(SemaRef.Context, Method);
   return Method;
 }
 
@@ -371,7 +371,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
     Constructor->setInvalidDecl();
 
   if (!Constructor->isInvalidDecl())
-    Owner->addDecl(Constructor);
+    Owner->addDecl(SemaRef.Context, Constructor);
   return Constructor;
 }
 
@@ -399,7 +399,7 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
   if (SemaRef.CheckFunctionDeclaration(Destructor, PrevDecl, Redeclaration,
                                        /*FIXME:*/OverloadableAttrRequired))
     Destructor->setInvalidDecl();
-  Owner->addDecl(Destructor);
+  Owner->addDecl(SemaRef.Context, Destructor);
   return Destructor;
 }
 
@@ -429,7 +429,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
   if (SemaRef.CheckFunctionDeclaration(Conversion, PrevDecl, Redeclaration,
                                        /*FIXME:*/OverloadableAttrRequired))
     Conversion->setInvalidDecl();
-  Owner->addDecl(Conversion);
+  Owner->addDecl(SemaRef.Context, Conversion);
   return Conversion;  
 }
 
index 1b5cdd36bef7aea8d9d68b3b9c9b5c094127312b..74683e3031739f5a60cc283cd4d08bd171c7985a 100644 (file)
@@ -125,8 +125,10 @@ void DeclPrinter:: PrintDecl(Decl *D) {
     Out << ";\n";
   } else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
     Out << "enum " << ED->getNameAsString() << " {\n";
-    for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(),
-                                    EEnd = ED->enumerator_end();
+    // FIXME: Shouldn't pass a NULL context
+    ASTContext *Context = 0;
+    for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(*Context),
+                                    EEnd = ED->enumerator_end(*Context);
          E != EEnd; ++E)
       Out << "  " << (*E)->getNameAsString() << ",\n";
     Out << "};\n";
@@ -139,8 +141,10 @@ void DeclPrinter:: PrintDecl(Decl *D) {
 
     Out << " {\n";
     ChangeIndent(1);
-    for (DeclContext::decl_iterator i = TD->decls_begin();
-         i != TD->decls_end();
+    // FIXME: Shouldn't pass a NULL context
+    ASTContext *Context = 0;
+    for (DeclContext::decl_iterator i = TD->decls_begin(*Context);
+         i != TD->decls_end(*Context);
          ++i)
       PrintDecl(*i);    
     ChangeIndent(-1);
@@ -198,8 +202,10 @@ void DeclPrinter::Print(NamedDecl *ND) {
 void DeclPrinter::Print(NamespaceDecl *NS) {
   Out << "namespace " << NS->getNameAsString() << " {\n";
   ChangeIndent(1);
-  for (DeclContext::decl_iterator i = NS->decls_begin();
-       i != NS->decls_end();
+  // FIXME: Shouldn't pass a NULL context
+  ASTContext *Context = 0;
+  for (DeclContext::decl_iterator i = NS->decls_begin(*Context);
+       i != NS->decls_end(*Context);
        ++i)
     PrintDecl(*i);    
   ChangeIndent(-1);
@@ -278,8 +284,10 @@ void DeclPrinter::PrintLinkageSpec(LinkageSpecDecl *LS) {
     ChangeIndent(1);
   }
 
-  for (LinkageSpecDecl::decl_iterator D = LS->decls_begin(), 
-                                   DEnd = LS->decls_end();
+  // FIXME: Should not use a NULL DeclContext!
+  ASTContext *Context = 0;
+  for (LinkageSpecDecl::decl_iterator D = LS->decls_begin(*Context), 
+                                   DEnd = LS->decls_end(*Context);
        D != DEnd; ++D)
     PrintDecl(*D);
 
@@ -389,16 +397,18 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
     Out << "}\n";
   }
   
-  for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(),
-       E = OID->prop_end(); I != E; ++I)
+  // FIXME: Should not use a NULL DeclContext!
+  ASTContext *Context = 0;
+  for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(*Context),
+       E = OID->prop_end(*Context); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   bool eol_needed = false;
-  for (ObjCInterfaceDecl::classmeth_iterator I = OID->classmeth_begin(),
-       E = OID->classmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::classmeth_iterator I = OID->classmeth_begin(*Context),
+       E = OID->classmeth_end(*Context); I != E; ++I)
     eol_needed = true, PrintObjCMethodDecl(*I);
   
-  for (ObjCInterfaceDecl::instmeth_iterator I = OID->instmeth_begin(),
-       E = OID->instmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::instmeth_iterator I = OID->instmeth_begin(*Context),
+       E = OID->instmeth_end(*Context); I != E; ++I)
     eol_needed = true, PrintObjCMethodDecl(*I);
   
   Out << (eol_needed ? "\n@end\n" : "@end\n");
@@ -408,8 +418,10 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
 void DeclPrinter::PrintObjCProtocolDecl(ObjCProtocolDecl *PID) {
   Out << "@protocol " << PID->getNameAsString() << '\n';
   
-  for (ObjCProtocolDecl::prop_iterator I = PID->prop_begin(),
-       E = PID->prop_end(); I != E; ++I)
+  // FIXME: Should not use a NULL DeclContext!
+  ASTContext *Context = 0;
+  for (ObjCProtocolDecl::prop_iterator I = PID->prop_begin(*Context),
+       E = PID->prop_end(*Context); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   Out << "@end\n";
   // FIXME: implement the rest...
@@ -427,12 +439,14 @@ void DeclPrinter::PrintObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
 }
 
 void DeclPrinter::PrintObjCCategoryDecl(ObjCCategoryDecl *PID) {
+  // FIXME: Should not use a NULL DeclContext!
+  ASTContext *Context = 0;
   Out << "@interface " 
       << PID->getClassInterface()->getNameAsString()
       << '(' << PID->getNameAsString() << ");\n";
   // Output property declarations.
-  for (ObjCCategoryDecl::prop_iterator I = PID->prop_begin(),
-       E = PID->prop_end(); I != E; ++I)
+  for (ObjCCategoryDecl::prop_iterator I = PID->prop_begin(*Context),
+       E = PID->prop_end(*Context); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   Out << "@end\n";
   
@@ -867,7 +881,10 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
   Out << "\n";
 
   // Print decls in the DeclContext.
-  for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end();
+  // FIXME: Should not use a NULL DeclContext!
+  ASTContext *Context = 0;
+  for (DeclContext::decl_iterator I = DC->decls_begin(*Context), 
+         E = DC->decls_end(*Context);
        I != E; ++I) {
     for (unsigned i = 0; i < Indentation; ++i)
       Out << "  ";
index fd8416da0ea25f0577dde347814c5fa4bf66221d..970dfecada05f9ef0bf38fa6486739099616bf9e 100644 (file)
@@ -67,7 +67,7 @@ ASTConsumer *CreateSerializationTest(Diagnostic &Diags,
 ASTConsumer *CreateASTSerializer(const std::string& InFile,
                                  const std::string& EmitDir,
                                  Diagnostic &Diags);
-
+  
 ASTConsumer *CreateBlockRewriter(const std::string& InFile,
                                  const std::string& OutFile,
                                  Diagnostic &Diags,
index bc385934047607e71632d0df1b4d3404a59e7163..c39b1bcf3ff700623a6bdfd07325429ef8a54500 100644 (file)
@@ -459,7 +459,8 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
   if (!ObjCImplementationActions.empty()) {
     TranslationUnitDecl *TUD = C.getTranslationUnitDecl();
     
-    for (DeclContext::decl_iterator I = TUD->decls_begin(),E = TUD->decls_end();
+    for (DeclContext::decl_iterator I = TUD->decls_begin(C),
+                                    E = TUD->decls_end(C);
          I != E; ++I)
       if (ObjCImplementationDecl* ID = dyn_cast<ObjCImplementationDecl>(*I))
         HandleCode(ID, 0, ObjCImplementationActions);
index f302913661872ff7b031713d9a9f906bc31b04e8..3610da63c5be0f25eae604136353286b3ee8adb1 100644 (file)
@@ -310,29 +310,41 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
 }
 
 void RewriteBlocks::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
-  for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), 
-       E = ClassDecl->instmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::instmeth_iterator 
+         I = ClassDecl->instmeth_begin(*Context), 
+         E = ClassDecl->instmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDecl(*I);
-  for (ObjCInterfaceDecl::classmeth_iterator I = ClassDecl->classmeth_begin(), 
-       E = ClassDecl->classmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::classmeth_iterator 
+         I = ClassDecl->classmeth_begin(*Context), 
+         E = ClassDecl->classmeth_end(*Context);
+       I != E; ++I)
     RewriteMethodDecl(*I);
 }
 
 void RewriteBlocks::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
-  for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), 
-       E = CatDecl->instmeth_end(); I != E; ++I)
+  for (ObjCCategoryDecl::instmeth_iterator 
+         I = CatDecl->instmeth_begin(*Context), 
+         E = CatDecl->instmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDecl(*I);
-  for (ObjCCategoryDecl::classmeth_iterator I = CatDecl->classmeth_begin(), 
-       E = CatDecl->classmeth_end(); I != E; ++I)
+  for (ObjCCategoryDecl::classmeth_iterator 
+         I = CatDecl->classmeth_begin(*Context), 
+         E = CatDecl->classmeth_end(*Context);
+       I != E; ++I)
     RewriteMethodDecl(*I);
 }
 
 void RewriteBlocks::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
-  for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), 
-       E = PDecl->instmeth_end(); I != E; ++I)
+  for (ObjCProtocolDecl::instmeth_iterator 
+         I = PDecl->instmeth_begin(*Context), 
+         E = PDecl->instmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDecl(*I);
-  for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), 
-       E = PDecl->classmeth_end(); I != E; ++I)
+  for (ObjCProtocolDecl::classmeth_iterator 
+         I = PDecl->classmeth_begin(*Context), 
+         E = PDecl->classmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDecl(*I);
 }
 
@@ -1138,8 +1150,8 @@ void RewriteBlocks::HandleDeclInMainFile(Decl *D) {
   }
   if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
     if (RD->isDefinition()) {
-      for (RecordDecl::field_iterator i = RD->field_begin(), 
-             e = RD->field_end(); i != e; ++i) {
+      for (RecordDecl::field_iterator i = RD->field_begin(*Context), 
+             e = RD->field_end(*Context); i != e; ++i) {
         FieldDecl *FD = *i;
         if (isBlockPointerType(FD->getType()))
           RewriteBlockPointerDecl(FD);
index 5fcecc603078b42d3570d7478626902ef8d25a99..44c0eb3d985e09cc159d7e91a347fcdedff7b621 100644 (file)
@@ -584,8 +584,8 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) {
     RewriteForwardProtocolDecl(FP);
   } else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
     // Recurse into linkage specifications
-    for (DeclContext::decl_iterator DI = LSD->decls_begin(),
-                                 DIEnd = LSD->decls_end();
+    for (DeclContext::decl_iterator DI = LSD->decls_begin(*Context),
+                                 DIEnd = LSD->decls_end(*Context);
          DI != DIEnd; ++DI)
       HandleTopLevelSingleDecl(*DI);
   }
@@ -791,11 +791,15 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
   // FIXME: handle category headers that are declared across multiple lines.
   ReplaceText(LocStart, 0, "// ", 3);
   
-  for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), 
-       E = CatDecl->instmeth_end(); I != E; ++I)
+  for (ObjCCategoryDecl::instmeth_iterator 
+         I = CatDecl->instmeth_begin(*Context), 
+         E = CatDecl->instmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
-  for (ObjCCategoryDecl::classmeth_iterator I = CatDecl->classmeth_begin(), 
-       E = CatDecl->classmeth_end(); I != E; ++I)
+  for (ObjCCategoryDecl::classmeth_iterator 
+         I = CatDecl->classmeth_begin(*Context), 
+         E = CatDecl->classmeth_end(*Context);
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
 
   // Lastly, comment out the @end.
@@ -810,11 +814,15 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
   // FIXME: handle protocol headers that are declared across multiple lines.
   ReplaceText(LocStart, 0, "// ", 3);
   
-  for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), 
-       E = PDecl->instmeth_end(); I != E; ++I)
+  for (ObjCProtocolDecl::instmeth_iterator 
+         I = PDecl->instmeth_begin(*Context), 
+         E = PDecl->instmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
-  for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), 
-       E = PDecl->classmeth_end(); I != E; ++I)
+  for (ObjCProtocolDecl::classmeth_iterator
+         I = PDecl->classmeth_begin(*Context), 
+         E = PDecl->classmeth_end(*Context);
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
 
   // Lastly, comment out the @end.
@@ -1038,14 +1046,18 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
   }
   SynthesizeObjCInternalStruct(ClassDecl, ResultStr);
     
-  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)
     RewriteProperty(*I);
-  for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), 
-       E = ClassDecl->instmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::instmeth_iterator 
+         I = ClassDecl->instmeth_begin(*Context), 
+         E = ClassDecl->instmeth_end(*Context);
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
-  for (ObjCInterfaceDecl::classmeth_iterator I = ClassDecl->classmeth_begin(), 
-       E = ClassDecl->classmeth_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::classmeth_iterator 
+         I = ClassDecl->classmeth_begin(*Context), 
+         E = ClassDecl->classmeth_end(*Context); 
+       I != E; ++I)
     RewriteMethodDeclaration(*I);
 
   // Lastly, comment out the @end.
@@ -1136,7 +1148,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
         dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
       // lookup which class implements the instance variable.
       ObjCInterfaceDecl *clsDeclared = 0;
-      iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(), clsDeclared);
+      iFaceDecl->getDecl()->lookupInstanceVariable(*Context, 
+                                                   D->getIdentifier(), 
+                                                   clsDeclared);
       assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
       
       // Synthesize an explicit cast to gain access to the ivar.
@@ -1180,7 +1194,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
       ObjCInterfaceType *iFaceDecl = dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
       // lookup which class implements the instance variable.
       ObjCInterfaceDecl *clsDeclared = 0;
-      iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(), clsDeclared);
+      iFaceDecl->getDecl()->lookupInstanceVariable(*Context, 
+                                                   D->getIdentifier(), 
+                                                   clsDeclared);
       assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
       
       // Synthesize an explicit cast to gain access to the ivar.
@@ -2187,7 +2203,8 @@ QualType RewriteObjC::getSuperStructType() {
 
     // Create fields
     for (unsigned i = 0; i < 2; ++i) {
-      SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl, 
+      SuperStructDecl->addDecl(*Context,
+                               FieldDecl::Create(*Context, SuperStructDecl, 
                                                  SourceLocation(), 0, 
                                                  FieldTypes[i], /*BitWidth=*/0,
                                                  /*Mutable=*/false));
@@ -2216,7 +2233,8 @@ QualType RewriteObjC::getConstantStringStructType() {
 
     // Create fields
     for (unsigned i = 0; i < 4; ++i) {
-      ConstantStringDecl->addDecl(FieldDecl::Create(*Context, 
+      ConstantStringDecl->addDecl(*Context,
+                                  FieldDecl::Create(*Context, 
                                                     ConstantStringDecl, 
                                                     SourceLocation(), 0,
                                                     FieldTypes[i], 
@@ -2867,9 +2885,9 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
     if (ObjCSynthesizedProtocols.count(PDecl))
       continue;
            
-    if (PDecl->instmeth_begin() != PDecl->instmeth_end()) {
-      unsigned NumMethods = std::distance(PDecl->instmeth_begin(),
-                                          PDecl->instmeth_end());
+    if (PDecl->instmeth_begin(*Context) != PDecl->instmeth_end(*Context)) {
+      unsigned NumMethods = std::distance(PDecl->instmeth_begin(*Context),
+                                          PDecl->instmeth_end(*Context));
       /* struct _objc_protocol_method_list {
        int protocol_method_count;
        struct protocol_methods protocols[];
@@ -2885,9 +2903,11 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
         "{\n\t" + utostr(NumMethods) + "\n";
       
       // Output instance methods declared in this protocol.
-      for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), 
-           E = PDecl->instmeth_end(); I != E; ++I) {
-        if (I == PDecl->instmeth_begin())
+      for (ObjCProtocolDecl::instmeth_iterator 
+             I = PDecl->instmeth_begin(*Context), 
+             E = PDecl->instmeth_end(*Context); 
+           I != E; ++I) {
+        if (I == PDecl->instmeth_begin(*Context))
           Result += "\t  ,{{(SEL)\"";
         else
           Result += "\t  ,{(SEL)\"";
@@ -2902,8 +2922,8 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
     }
     
     // Output class methods declared in this protocol.
-    unsigned NumMethods = std::distance(PDecl->classmeth_begin(),
-                                        PDecl->classmeth_end());
+    unsigned NumMethods = std::distance(PDecl->classmeth_begin(*Context),
+                                        PDecl->classmeth_end(*Context));
     if (NumMethods > 0) {
       /* struct _objc_protocol_method_list {
        int protocol_method_count;
@@ -2922,9 +2942,11 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
       Result += "\n";
       
       // Output instance methods declared in this protocol.
-      for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), 
-           E = PDecl->classmeth_end(); I != E; ++I) {
-        if (I == PDecl->classmeth_begin())
+      for (ObjCProtocolDecl::classmeth_iterator 
+             I = PDecl->classmeth_begin(*Context), 
+             E = PDecl->classmeth_end(*Context);
+           I != E; ++I) {
+        if (I == PDecl->classmeth_begin(*Context))
           Result += "\t  ,{{(SEL)\"";
         else
           Result += "\t  ,{(SEL)\"";
@@ -2967,14 +2989,14 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
       "{\n\t0, \"";
     Result += PDecl->getNameAsString();
     Result += "\", 0, ";
-    if (PDecl->instmeth_begin() != PDecl->instmeth_end()) {
+    if (PDecl->instmeth_begin(*Context) != PDecl->instmeth_end(*Context)) {
       Result += "(struct _objc_protocol_method_list *)&_OBJC_PROTOCOL_INSTANCE_METHODS_";
       Result += PDecl->getNameAsString();
       Result += ", ";
     }
     else
       Result += "0, ";
-    if (PDecl->classmeth_begin() != PDecl->classmeth_end()) {
+    if (PDecl->classmeth_begin(*Context) != PDecl->classmeth_end(*Context)) {
       Result += "(struct _objc_protocol_method_list *)&_OBJC_PROTOCOL_CLASS_METHODS_";
       Result += PDecl->getNameAsString();
       Result += "\n";
@@ -4507,8 +4529,8 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
   }
   if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
     if (RD->isDefinition()) {
-      for (RecordDecl::field_iterator i = RD->field_begin(), 
-             e = RD->field_end(); i != e; ++i) {
+      for (RecordDecl::field_iterator i = RD->field_begin(*Context), 
+             e = RD->field_end(*Context); i != e; ++i) {
         FieldDecl *FD = *i;
         if (isTopLevelBlockPointerType(FD->getType()))
           RewriteBlockPointerDecl(FD);
index b4fd8d7a7580afd8d4f757708bc71808f4630e32..708328db77dbceb63d111ca0e48370c360931fe8 100644 (file)
@@ -72,7 +72,8 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename,
     llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
     
     TranslationUnitDecl *TUD = Ctx.getTranslationUnitDecl();
-    for (DeclContext::decl_iterator I = TUD->decls_begin(), E =TUD->decls_end();
+    for (DeclContext::decl_iterator I = TUD->decls_begin(Ctx), 
+                                    E = TUD->decls_end(Ctx);
          I != E; ++I)
       FilePrinter->HandleTopLevelDecl(DeclGroupRef(*I));
   }
@@ -123,7 +124,8 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
     llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
     
     TranslationUnitDecl *TUD = NewCtx->getTranslationUnitDecl();
-    for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end();
+    for (DeclContext::decl_iterator I = TUD->decls_begin(*NewCtx), 
+                                    E = TUD->decls_end(*NewCtx);
          I != E; ++I)
       FilePrinter->HandleTopLevelDecl(DeclGroupRef(*I));
   }
index 3c06ea736caf9a5cc5dd4433e9e25971468385d4..b10323ab7352bbabb63b57f2b06832cfbe558d27 100644 (file)
@@ -1597,7 +1597,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
     ClearSourceMgr = true;
     break;
   }      
-    
+
   case PrintPreprocessedInput: {      // -E mode.
     llvm::TimeRegion Timer(ClangFrontendTimer);
     DoPrintPreprocessedInput(PP, OutputFile);
@@ -1683,7 +1683,6 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
                                       PP.getSelectorTable(),
                                       /* FreeMemory = */ !DisableFree));
     
-    
     ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats);
     
     if (FixItRewrite)
@@ -1763,7 +1762,8 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
 
   // FIXME: We need to inform Consumer about completed TagDecls as well.
   TranslationUnitDecl *TUD = Ctx->getTranslationUnitDecl();
-  for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end();
+  for (DeclContext::decl_iterator I = TUD->decls_begin(*Ctx), 
+                                  E = TUD->decls_end(*Ctx);
        I != E; ++I)
     Consumer->HandleTopLevelDecl(DeclGroupRef(*I));
 }