Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 77fa994..873806f 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -141,7 +141,7 @@
bool FreeMemory;
llvm::MallocAllocator MallocAlloc;
llvm::BumpPtrAllocator BumpAlloc;
-public:
+public:
TargetInfo &Target;
IdentifierTable &Idents;
SelectorTable &Selectors;
@@ -189,7 +189,7 @@
bool FreeMemory = true, unsigned size_reserve=0);
~ASTContext();
-
+
void PrintStats() const;
const std::vector<Type*>& getTypes() const { return Types; }
@@ -364,7 +364,7 @@
/// 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 @@
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 @@
bool ExpandStructures,
FieldDecl *Field,
bool OutermostType = false,
- bool EncodingProperty = false) const;
+ bool EncodingProperty = false);
};
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index a2ad290..f954934 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -85,6 +85,9 @@
/// 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 @@
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 @@
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 @@
// 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 @@
// data members, functions, constructors, destructors, etc.
typedef specific_decl_iterator<FieldDecl> field_iterator;
- field_iterator field_begin() const {
- return field_iterator(decls_begin());
+ field_iterator field_begin(ASTContext &Context) const {
+ return field_iterator(decls_begin(Context));
}
- field_iterator field_end() const {
- return field_iterator(decls_end());
+ field_iterator field_end(ASTContext &Context) const {
+ return field_iterator(decls_end(Context));
}
// field_empty - Whether there are any fields (non-static data
// members) in this record.
- bool field_empty() const { return field_begin() == field_end(); }
+ bool field_empty(ASTContext &Context) const {
+ return field_begin(Context) == field_end(Context);
+ }
/// completeDefinition - Notes that the definition of this type is
/// now complete.
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 4675136..3244c63 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -1,4 +1,4 @@
-//===-- DeclBase.h - Base Classes for representing declarations *- C++ -*-===//
+//===-- DeclBase.h - Base Classes for representing declarations -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -178,10 +178,6 @@
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 @@
/// 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 @@
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 @@
/// 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 @@
///
/// 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 @@
/// 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 @@
/// 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 @@
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 @@
#include "clang/AST/DeclNodes.def"
private:
- void buildLookup(DeclContext *DCtx);
- void makeDeclVisibleInContextImpl(NamedDecl *D);
+ void buildLookup(ASTContext &Context, DeclContext *DCtx);
+ void makeDeclVisibleInContextImpl(ASTContext &Context, NamedDecl *D);
void EmitOutRec(llvm::Serializer& S) const;
void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
diff --git a/include/clang/AST/DeclContextInternals.h b/include/clang/AST/DeclContextInternals.h
index 74e83f1..9341a7d 100644
--- a/include/clang/AST/DeclContextInternals.h
+++ b/include/clang/AST/DeclContextInternals.h
@@ -64,7 +64,7 @@
/// 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 @@
/// HandleRedeclaration - If this is a redeclaration of an existing decl,
/// replace the old one with D and return true. Otherwise return false.
- bool HandleRedeclaration(NamedDecl *D) {
+ bool HandleRedeclaration(ASTContext &Context, NamedDecl *D) {
// Most decls only have one entry in their list, special case it.
if (isInline()) {
if (!D->declarationReplaces(Data.get<NamedDecl*>()))
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 9acce0f..62cd01e 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -256,50 +256,54 @@
// 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 @@
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 @@
// Lookup a method. First, we search locally. If a method isn't
// found, we search referenced protocols and class categories.
- ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
- ObjCMethodDecl *lookupClassMethod(Selector Sel);
+ ObjCMethodDecl *lookupInstanceMethod(ASTContext &Context, Selector Sel);
+ ObjCMethodDecl *lookupClassMethod(ASTContext &Context, Selector Sel);
bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; }
diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h
index a3c1e1f..7290459 100644
--- a/include/clang/AST/DeclarationName.h
+++ b/include/clang/AST/DeclarationName.h
@@ -133,11 +133,7 @@
/// 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 @@
// 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 {