FieldDecl *FieldDecls[2];
for (unsigned i = 0; i < 2; ++i)
- FieldDecls[i] = FieldDecl::Create(*Context, SuperStructDecl,
- SourceLocation(), 0,
+ FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0,
FieldTypes[i]);
SuperStructDecl->defineBody(FieldDecls, 4);
FieldDecl *FieldDecls[4];
for (unsigned i = 0; i < 4; ++i)
- FieldDecls[i] = FieldDecl::Create(*Context, ConstantStringDecl,
- SourceLocation(), 0,
+ FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0,
FieldTypes[i]);
ConstantStringDecl->defineBody(FieldDecls, 4);
///
ScopedDecl *Next;
- ContextDecl *CtxDecl;
+ DeclContext *CtxDecl;
protected:
- ScopedDecl(Kind DK, ContextDecl *CD, SourceLocation L,
+ ScopedDecl(Kind DK, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, ScopedDecl *PrevDecl)
: NamedDecl(DK, L, Id), NextDeclarator(PrevDecl), Next(0), CtxDecl(CD) {}
public:
- ContextDecl *getContextDecl() const { return CtxDecl; }
+ DeclContext *getDeclContext() const { return CtxDecl; }
ScopedDecl *getNext() const { return Next; }
void setNext(ScopedDecl *N) { Next = N; }
// roughly global variables and functions, but also handles enums (which could
// be defined inside or outside a function etc).
bool isDefinedOutsideFunctionOrMethod() const {
- if (getContextDecl())
- return !getContextDecl()->isFunctionOrMethod();
+ if (getDeclContext())
+ return !getDeclContext()->isFunctionOrMethod();
else
return true;
}
QualType DeclType;
protected:
- ValueDecl(Kind DK, ContextDecl *CD, SourceLocation L,
+ ValueDecl(Kind DK, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, ScopedDecl *PrevDecl)
: ScopedDecl(DK, CD, L, Id, PrevDecl), DeclType(T) {}
public:
friend class StmtIteratorBase;
protected:
- VarDecl(Kind DK, ContextDecl *CD, SourceLocation L, IdentifierInfo *Id, QualType T,
+ VarDecl(Kind DK, DeclContext *CD, SourceLocation L, IdentifierInfo *Id, QualType T,
StorageClass SC, ScopedDecl *PrevDecl)
: ValueDecl(DK, CD, L, Id, T, PrevDecl), Init(0) { SClass = SC; }
public:
/// void foo() { int x; static int y; extern int z; }
///
class BlockVarDecl : public VarDecl {
- BlockVarDecl(ContextDecl *CD, SourceLocation L,
+ BlockVarDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, StorageClass S,
ScopedDecl *PrevDecl)
: VarDecl(BlockVar, CD, L, Id, T, S, PrevDecl) {}
public:
- static BlockVarDecl *Create(ASTContext &C, ContextDecl *CD, SourceLocation L,
+ static BlockVarDecl *Create(ASTContext &C, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, StorageClass S,
ScopedDecl *PrevDecl);
// Implement isa/cast/dyncast/etc.
/// definitions (C99 6.9.2p2) using our type system (without storing a
/// pointer to the decl's scope, which is transient).
class FileVarDecl : public VarDecl {
- FileVarDecl(ContextDecl *CD, SourceLocation L,
+ FileVarDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, StorageClass S,
ScopedDecl *PrevDecl)
: VarDecl(FileVar, CD, L, Id, T, S, PrevDecl) {}
public:
- static FileVarDecl *Create(ASTContext &C, ContextDecl *CD,
+ static FileVarDecl *Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S, ScopedDecl *PrevDecl);
/// in, inout, etc.
unsigned objcDeclQualifier : 6;
- ParmVarDecl(ContextDecl *CD, SourceLocation L,
+ ParmVarDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, StorageClass S,
ScopedDecl *PrevDecl)
: VarDecl(ParmVar, CD, L, Id, T, S, PrevDecl),
objcDeclQualifier(OBJC_TQ_None) {}
public:
- static ParmVarDecl *Create(ASTContext &C, ContextDecl *CD,
+ static ParmVarDecl *Create(ASTContext &C, DeclContext *CD,
SourceLocation L,IdentifierInfo *Id,
QualType T, StorageClass S, ScopedDecl *PrevDecl);
/// FunctionDecl - An instance of this class is created to represent a function
/// declaration or definition.
-class FunctionDecl : public ValueDecl, public ContextDecl {
+class FunctionDecl : public ValueDecl, public DeclContext {
public:
enum StorageClass {
None, Extern, Static, PrivateExtern
bool IsInline : 1;
bool IsImplicit : 1;
- FunctionDecl(ContextDecl *CD, SourceLocation L,
+ FunctionDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T,
StorageClass S, bool isInline, ScopedDecl *PrevDecl)
: ValueDecl(Function, CD, L, Id, T, PrevDecl),
- ContextDecl(Function),
+ DeclContext(Function),
ParamInfo(0), Body(0), DeclChain(0), SClass(S),
IsInline(isInline), IsImplicit(0) {}
virtual ~FunctionDecl();
public:
- static FunctionDecl *Create(ASTContext &C, ContextDecl *CD, SourceLocation L,
+ static FunctionDecl *Create(ASTContext &C, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T,
StorageClass S = None, bool isInline = false,
ScopedDecl *PrevDecl = 0);
class FieldDecl : public NamedDecl {
QualType DeclType;
Expr *BitWidth;
- ContextDecl *CtxDecl;
protected:
- FieldDecl(Kind DK, ContextDecl *CD,
- SourceLocation L, IdentifierInfo *Id, QualType T,
+ FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
Expr *BW = NULL)
- : NamedDecl(DK, L, Id), DeclType(T), BitWidth(BW), CtxDecl(CD) {}
- FieldDecl(RecordDecl *CD, SourceLocation L,
- IdentifierInfo *Id, QualType T, Expr *BW)
+ : NamedDecl(DK, L, Id), DeclType(T), BitWidth(BW) {}
+ FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T, Expr *BW)
: NamedDecl(Field, L, Id), DeclType(T), BitWidth(BW) {}
public:
- static FieldDecl *Create(ASTContext &C, RecordDecl *CD,
- SourceLocation L, IdentifierInfo *Id,
+ static FieldDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id,
QualType T, Expr *BW = NULL);
QualType getType() const { return DeclType; }
bool isBitField() const { return BitWidth != NULL; }
Expr *getBitWidth() const { return BitWidth; }
- ContextDecl *getContextDecl() const { return CtxDecl; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= FieldFirst && D->getKind() <= FieldLast;
Expr *Init; // an integer constant expression
llvm::APSInt Val; // The value.
protected:
- EnumConstantDecl(ContextDecl *CD, SourceLocation L,
+ EnumConstantDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, Expr *E,
const llvm::APSInt &V, ScopedDecl *PrevDecl)
: ValueDecl(EnumConstant, CD, L, Id, T, PrevDecl), Init(E), Val(V) {}
Type *TypeForDecl;
friend class ASTContext;
protected:
- TypeDecl(Kind DK, ContextDecl *CD, SourceLocation L,
+ TypeDecl(Kind DK, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, ScopedDecl *PrevDecl)
: ScopedDecl(DK, CD, L, Id, PrevDecl), TypeForDecl(0) {}
public:
class TypedefDecl : public TypeDecl {
/// UnderlyingType - This is the type the typedef is set to.
QualType UnderlyingType;
- TypedefDecl(ContextDecl *CD, SourceLocation L,
+ TypedefDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, QualType T, ScopedDecl *PD)
: TypeDecl(Typedef, CD, L, Id, PD), UnderlyingType(T) {}
~TypedefDecl() {}
public:
- static TypedefDecl *Create(ASTContext &C, ContextDecl *CD,
+ static TypedefDecl *Create(ASTContext &C, DeclContext *CD,
SourceLocation L,IdentifierInfo *Id,
QualType T, ScopedDecl *PD);
/// TagDecl - Represents the declaration of a struct/union/class/enum.
-class TagDecl : public TypeDecl, public ContextDecl {
+class TagDecl : public TypeDecl {
/// IsDefinition - True if this is a definition ("struct foo {};"), false if
/// it is a declaration ("struct foo;").
bool IsDefinition : 1;
protected:
- TagDecl(Kind DK, ContextDecl *CD, SourceLocation L,
+ TagDecl(Kind DK, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, ScopedDecl *PrevDecl)
- : TypeDecl(DK, CD, L, Id, PrevDecl), ContextDecl(DK) {
+ : TypeDecl(DK, CD, L, Id, PrevDecl) {
IsDefinition = false;
}
public:
/// EnumDecl - Represents an enum. As an extension, we allow forward-declared
/// enums.
-class EnumDecl : public TagDecl {
+class EnumDecl : public TagDecl, public DeclContext {
/// ElementList - this is a linked list of EnumConstantDecl's which are linked
/// together through their getNextDeclarator pointers.
EnumConstantDecl *ElementList;
/// have a different type than this does.
QualType IntegerType;
- EnumDecl(ContextDecl *CD, SourceLocation L,
+ EnumDecl(DeclContext *CD, SourceLocation L,
IdentifierInfo *Id, ScopedDecl *PrevDecl)
- : TagDecl(Enum, CD, L, Id, PrevDecl) {
+ : TagDecl(Enum, CD, L, Id, PrevDecl), DeclContext(Enum) {
ElementList = 0;
IntegerType = QualType();
}
public:
- static EnumDecl *Create(ASTContext &C, ContextDecl *CD,
+ static EnumDecl *Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
FieldDecl **Members; // Null if not defined.
int NumMembers; // -1 if not defined.
- RecordDecl(Kind DK, ContextDecl *CD, SourceLocation L, IdentifierInfo *Id,
+ RecordDecl(Kind DK, DeclContext *CD, SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl) : TagDecl(DK, CD, L, Id, PrevDecl) {
HasFlexibleArrayMember = false;
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
}
public:
- static RecordDecl *Create(ASTContext &C, Kind DK, ContextDecl *CD,
+ static RecordDecl *Create(ASTContext &C, Kind DK, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
//
//===----------------------------------------------------------------------===//
//
-// This file defines the Decl and ContextDecl interfaces.
+// This file defines the Decl and DeclContext interfaces.
//
//===----------------------------------------------------------------------===//
namespace clang {
class FunctionDecl;
class ObjCMethodDecl;
-class TagDecl;
+class EnumDecl;
class ObjCInterfaceDecl;
/// Decl - This represents one declaration (or definition), e.g. a variable,
void ReadInRec(llvm::Deserializer& D);
};
-/// ContextDecl - This is used only as base class of specific decl types that
+/// DeclContext - This is used only as base class of specific decl types that
/// can act as declaration contexts. These decls are:
///
/// FunctionDecl
/// ObjCMethodDecl
-/// TagDecl
+/// EnumDecl
/// ObjCInterfaceDecl
///
-class ContextDecl {
+class DeclContext {
/// DeclKind - This indicates which class this is.
Decl::Kind DeclKind : 8;
// Used in the CastTo template to get the DeclKind
- // from a Decl or a ContextDecl. ContextDecl doesn't have a getKind() method
+ // from a Decl or a DeclContext. DeclContext doesn't have a getKind() method
// to avoid 'ambiguous access' compiler errors.
template<typename T> struct KindTrait {
static Decl::Kind getKind(const T *D) { return D->getKind(); }
return static_cast<ObjCMethodDecl*>(const_cast<From*>(D));
case Decl::ObjCInterface:
return static_cast<ObjCInterfaceDecl*>(const_cast<From*>(D));
+ case Decl::Enum:
+ return static_cast<EnumDecl*>(const_cast<From*>(D));
default:
- // check for TagDecl
- if (DK >= Decl::TagFirst && DK <= Decl::TagLast)
- return static_cast<TagDecl*>(const_cast<From*>(D));
-
- assert(false && "a decl that inherits ContextDecl isn't handled");
+ assert(false && "a decl that inherits DeclContext isn't handled");
return 0;
}
}
protected:
- ContextDecl(Decl::Kind K) : DeclKind(K) {}
+ DeclContext(Decl::Kind K) : DeclKind(K) {}
public:
- /// getParent - Returns the containing ContextDecl if this is a ScopedDecl,
+ /// getParent - Returns the containing DeclContext if this is a ScopedDecl,
/// else returns NULL.
- ContextDecl *getParent() const;
+ DeclContext *getParent() const;
bool isFunctionOrMethod() const {
switch (DeclKind) {
}
}
- /// ToDecl and FromDecl make Decl <-> ContextDecl castings.
+ /// ToDecl and FromDecl make Decl <-> DeclContext castings.
/// They are intended to be used by the simplify_type and cast_convert_val
/// templates.
- static Decl *ToDecl (const ContextDecl *D);
- static ContextDecl *FromDecl (const Decl *D);
+ static Decl *ToDecl (const DeclContext *D);
+ static DeclContext *FromDecl (const Decl *D);
static bool classof(const Decl *D) {
switch (D->getKind()) {
case Decl::Function:
case Decl::ObjCMethod:
case Decl::ObjCInterface:
+ case Decl::Enum:
return true;
default:
- // check for TagDecl
- return D->getKind() >= Decl::TagFirst &&
- D->getKind() <= Decl::TagLast;
+ return false;
}
}
- static bool classof(const ContextDecl *D) { return true; }
+ static bool classof(const DeclContext *D) { return true; }
static bool classof(const FunctionDecl *D) { return true; }
static bool classof(const ObjCMethodDecl *D) { return true; }
- static bool classof(const TagDecl *D) { return true; }
+ static bool classof(const EnumDecl *D) { return true; }
static bool classof(const ObjCInterfaceDecl *D) { return true; }
};
-template<> struct ContextDecl::KindTrait<ContextDecl> {
- static Decl::Kind getKind(const ContextDecl *D) { return D->DeclKind; }
+template<> struct DeclContext::KindTrait<DeclContext> {
+ static Decl::Kind getKind(const DeclContext *D) { return D->DeclKind; }
};
} // end clang.
namespace llvm {
-/// Implement simplify_type for ContextDecl, so that we can dyn_cast from
-/// ContextDecl to a specific Decl class.
- template<> struct simplify_type<const ::clang::ContextDecl*> {
+/// Implement simplify_type for DeclContext, so that we can dyn_cast from
+/// DeclContext to a specific Decl class.
+ template<> struct simplify_type<const ::clang::DeclContext*> {
typedef ::clang::Decl* SimpleType;
- static SimpleType getSimplifiedValue(const ::clang::ContextDecl *Val) {
- return ::clang::ContextDecl::ToDecl(Val);
+ static SimpleType getSimplifiedValue(const ::clang::DeclContext *Val) {
+ return ::clang::DeclContext::ToDecl(Val);
}
};
-template<> struct simplify_type< ::clang::ContextDecl*>
- : public simplify_type<const ::clang::ContextDecl*> {};
+template<> struct simplify_type< ::clang::DeclContext*>
+ : public simplify_type<const ::clang::DeclContext*> {};
-template<> struct simplify_type<const ::clang::ContextDecl> {
+template<> struct simplify_type<const ::clang::DeclContext> {
typedef ::clang::Decl SimpleType;
- static SimpleType &getSimplifiedValue(const ::clang::ContextDecl &Val) {
- return *::clang::ContextDecl::ToDecl(&Val);
+ static SimpleType &getSimplifiedValue(const ::clang::DeclContext &Val) {
+ return *::clang::DeclContext::ToDecl(&Val);
}
};
-template<> struct simplify_type< ::clang::ContextDecl>
- : public simplify_type<const ::clang::ContextDecl> {};
+template<> struct simplify_type< ::clang::DeclContext>
+ : public simplify_type<const ::clang::DeclContext> {};
-/// Implement cast_convert_val for ContextDecl, so that we can dyn_cast from
-/// a Decl class to ContextDecl.
+/// Implement cast_convert_val for DeclContext, so that we can dyn_cast from
+/// a Decl class to DeclContext.
template<class FromTy>
-struct cast_convert_val< ::clang::ContextDecl,const FromTy,const FromTy> {
- static ::clang::ContextDecl &doit(const FromTy &Val) {
- return *::clang::ContextDecl::FromDecl(&Val);
+struct cast_convert_val< ::clang::DeclContext,const FromTy,const FromTy> {
+ static ::clang::DeclContext &doit(const FromTy &Val) {
+ return *::clang::DeclContext::FromDecl(&Val);
}
};
template<class FromTy>
-struct cast_convert_val< ::clang::ContextDecl,FromTy,FromTy>
- : public cast_convert_val< ::clang::ContextDecl,const FromTy,const FromTy>
+struct cast_convert_val< ::clang::DeclContext,FromTy,FromTy>
+ : public cast_convert_val< ::clang::DeclContext,const FromTy,const FromTy>
{};
template<class FromTy>
-struct cast_convert_val< ::clang::ContextDecl,const FromTy*,const FromTy*> {
- static ::clang::ContextDecl *doit(const FromTy *Val) {
- return ::clang::ContextDecl::FromDecl(Val);
+struct cast_convert_val< ::clang::DeclContext,const FromTy*,const FromTy*> {
+ static ::clang::DeclContext *doit(const FromTy *Val) {
+ return ::clang::DeclContext::FromDecl(Val);
}
};
template<class FromTy>
-struct cast_convert_val< ::clang::ContextDecl,FromTy*,FromTy*>
- : public cast_convert_val< ::clang::ContextDecl,const FromTy*,const FromTy*>
+struct cast_convert_val< ::clang::DeclContext,FromTy*,FromTy*>
+ : public cast_convert_val< ::clang::DeclContext,const FromTy*,const FromTy*>
{};
} // end namespace llvm
/// A selector represents a unique name for a method. The selector names for
/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
///
-class ObjCMethodDecl : public Decl, public ContextDecl {
+class ObjCMethodDecl : public Decl, public DeclContext {
public:
enum ImplementationControl { None, Required, Optional };
private:
bool isVariadic = false,
ImplementationControl impControl = None)
: Decl(ObjCMethod, beginLoc),
- ContextDecl(ObjCMethod),
+ DeclContext(ObjCMethod),
IsInstance(isInstance), IsVariadic(isVariadic),
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
MethodContext(static_cast<NamedDecl*>(contextDecl)),
/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
/// typically inherit from NSObject (an exception is NSProxy).
///
-class ObjCInterfaceDecl : public NamedDecl, public ContextDecl {
+class ObjCInterfaceDecl : public NamedDecl, public DeclContext {
/// TypeForDecl - This indicates the Type object that represents this
/// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
Type *TypeForDecl;
ObjCInterfaceDecl(SourceLocation atLoc,
unsigned numRefProtos,
IdentifierInfo *Id, bool FD, bool isInternal)
- : NamedDecl(ObjCInterface, atLoc, Id), ContextDecl(ObjCInterface),
+ : NamedDecl(ObjCInterface, atLoc, Id), DeclContext(ObjCInterface),
TypeForDecl(0), SuperClass(0),
ReferencedProtocols(0), NumReferencedProtocols(0), Ivars(0),
NumIvars(0),
/// }
///
class ObjCIvarDecl : public FieldDecl {
- ObjCIvarDecl(ContextDecl *CD, SourceLocation L,
- IdentifierInfo *Id, QualType T)
- : FieldDecl(ObjCIvar, CD, L, Id, T) {}
+ ObjCIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T)
+ : FieldDecl(ObjCIvar, L, Id, T) {}
public:
- static ObjCIvarDecl *Create(ASTContext &C, ObjCInterfaceDecl *CD,
- SourceLocation L,
+ static ObjCIvarDecl *Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id, QualType T);
enum AccessControl {
FieldDecl *FieldDecls[4];
for (unsigned i = 0; i < 4; ++i)
- FieldDecls[i] = FieldDecl::Create(*this, CFConstantStringTypeDecl,
- SourceLocation(), 0,
+ FieldDecls[i] = FieldDecl::Create(*this, SourceLocation(), 0,
FieldTypes[i]);
CFConstantStringTypeDecl->defineBody(FieldDecls, 4);
// Decl Allocation/Deallocation Method Implementations
//===----------------------------------------------------------------------===//
-BlockVarDecl *BlockVarDecl::Create(ASTContext &C, ContextDecl *CD,
+BlockVarDecl *BlockVarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L,
IdentifierInfo *Id, QualType T,
StorageClass S, ScopedDecl *PrevDecl) {
}
-FileVarDecl *FileVarDecl::Create(ASTContext &C, ContextDecl *CD,
+FileVarDecl *FileVarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S,
ScopedDecl *PrevDecl) {
return new (Mem) FileVarDecl(CD, L, Id, T, S, PrevDecl);
}
-ParmVarDecl *ParmVarDecl::Create(ASTContext &C, ContextDecl *CD,
+ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S,
ScopedDecl *PrevDecl) {
return new (Mem) ParmVarDecl(CD, L, Id, T, S, PrevDecl);
}
-FunctionDecl *FunctionDecl::Create(ASTContext &C, ContextDecl *CD,
+FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L,
IdentifierInfo *Id, QualType T,
StorageClass S, bool isInline,
return new (Mem) FunctionDecl(CD, L, Id, T, S, isInline, PrevDecl);
}
-FieldDecl *FieldDecl::Create(ASTContext &C, RecordDecl *CD, SourceLocation L,
+FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id, QualType T, Expr *BW) {
void *Mem = C.getAllocator().Allocate<FieldDecl>();
- return new (Mem) FieldDecl(CD, L, Id, T, BW);
+ return new (Mem) FieldDecl(L, Id, T, BW);
}
return new (Mem) EnumConstantDecl(CD, L, Id, T, E, V, PrevDecl);
}
-TypedefDecl *TypedefDecl::Create(ASTContext &C, ContextDecl *CD,
+TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L,
IdentifierInfo *Id, QualType T,
ScopedDecl *PD) {
return new (Mem) TypedefDecl(CD, L, Id, T, PD);
}
-EnumDecl *EnumDecl::Create(ASTContext &C, ContextDecl *CD, SourceLocation L,
+EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *CD, SourceLocation L,
IdentifierInfo *Id,
ScopedDecl *PrevDecl) {
void *Mem = C.getAllocator().Allocate<EnumDecl>();
return new (Mem) EnumDecl(CD, L, Id, PrevDecl);
}
-RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, ContextDecl *CD,
+RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl) {
void *Mem = C.getAllocator().Allocate<RecordDecl>();
}
//===----------------------------------------------------------------------===//
-// ContextDecl Implementation
+// DeclContext Implementation
//===----------------------------------------------------------------------===//
-ContextDecl *ContextDecl::getParent() const {
+DeclContext *DeclContext::getParent() const {
if (ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
- return SD->getContextDecl();
+ return SD->getDeclContext();
else
return NULL;
}
-Decl *ContextDecl::ToDecl (const ContextDecl *D) {
+Decl *DeclContext::ToDecl (const DeclContext *D) {
return CastTo<Decl>(D);
}
-ContextDecl *ContextDecl::FromDecl (const Decl *D) {
- return CastTo<ContextDecl>(D);
+DeclContext *DeclContext::FromDecl (const Decl *D) {
+ return CastTo<DeclContext>(D);
}
//===----------------------------------------------------------------------===//
isInternal);
}
-ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCInterfaceDecl *CD,
- SourceLocation L,
+ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id, QualType T) {
void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
- return new (Mem) ObjCIvarDecl(CD, L, Id, T);
+ return new (Mem) ObjCIvarDecl(L, Id, T);
}
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
void ScopedDecl::EmitInRec(Serializer& S) const {
NamedDecl::EmitInRec(S);
S.EmitPtr(getNext()); // From ScopedDecl.
- S.EmitPtr(cast_or_null<Decl>(getContextDecl())); // From ScopedDecl.
+ S.EmitPtr(cast_or_null<Decl>(getDeclContext())); // From ScopedDecl.
}
void ScopedDecl::ReadInRec(Deserializer& D) {
D.ReadPtr(Next); // From ScopedDecl.
Decl *TmpD;
D.ReadPtr(TmpD); // From ScopedDecl.
- CtxDecl = cast_or_null<ContextDecl>(TmpD);
+ CtxDecl = cast_or_null<DeclContext>(TmpD);
}
//===------------------------------------------------------------===//
}
FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
- FieldDecl* decl = new FieldDecl(0, SourceLocation(), NULL, QualType(), 0);
+ FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0);
decl->DeclType.ReadBackpatch(D);
decl->ReadInRec(D);
decl->BitWidth = D.ReadOwnedPtr<Expr>();
RecordDecl::Create(Context, Decl::Struct, NULL,
SourceLocation(),
&IT.get("objc_object"), 0);
- FieldDecl *IsaDecl = FieldDecl::Create(Context, ObjectTag,
- SourceLocation(), 0,
+ FieldDecl *IsaDecl = FieldDecl::Create(Context, SourceLocation(), 0,
Context.getObjCClassType());
ObjectTag->defineBody(&IsaDecl, 1);
QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag));
class ASTConsumer;
class Preprocessor;
class Decl;
- class ContextDecl;
+ class DeclContext;
class NamedDecl;
class ScopedDecl;
class Expr;
/// the method decl for the method being parsed.
ObjCMethodDecl *CurMethodDecl;
- ContextDecl *CurContext;
+ DeclContext *CurContext;
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
/// it (which acts like the label decl in some ways). Forward referenced
DeclTy **Elements, unsigned NumElements);
private:
/// Set the current declaration context until it gets popped.
- void PushContextDecl(ContextDecl *CD);
- void PopContextDecl();
+ void PushDeclContext(DeclContext *CD);
+ void PopDeclContext();
/// Subroutines of ActOnDeclarator().
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
return 0;
}
-void Sema::PushContextDecl(ContextDecl *CD) {
+void Sema::PushDeclContext(DeclContext *CD) {
assert(CD->getParent() == CurContext &&
- "The next ContextDecl should be directly contained in the current one.");
+ "The next DeclContext should be directly contained in the current one.");
CurContext = CD;
}
-void Sema::PopContextDecl() {
- assert(CurContext && "ContextDecl imbalance!");
+void Sema::PopDeclContext() {
+ assert(CurContext && "DeclContext imbalance!");
CurContext = CurContext->getParent();
}
Decl *decl = static_cast<Decl*>(ActOnDeclarator(GlobalScope, D, 0));
FunctionDecl *FD = cast<FunctionDecl>(decl);
CurFunctionDecl = FD;
- PushContextDecl(FD);
+ PushDeclContext(FD);
// Create Decl objects for each parameter, adding them to the FunctionDecl.
llvm::SmallVector<ParmVarDecl*, 16> Params;
MD->setBody((Stmt*)Body);
CurMethodDecl = 0;
}
- PopContextDecl();
+ PopDeclContext();
// Verify and clean out per-function state.
// Check goto/label use.
// FIXME: Chain fielddecls together.
FieldDecl *NewFD;
- if (RecordDecl *RD = dyn_cast<RecordDecl>(TagDecl))
- NewFD = FieldDecl::Create(Context, RD, Loc, II, T, BitWidth);
+ if (isa<RecordDecl>(TagDecl))
+ NewFD = FieldDecl::Create(Context, Loc, II, T, BitWidth);
else if (isa<ObjCInterfaceDecl>(TagDecl) ||
isa<ObjCImplementationDecl>(TagDecl) ||
isa<ObjCCategoryDecl>(TagDecl) ||
// properties can appear within a protocol.
// See corresponding FIXME in DeclObjC.h:ObjCPropertyDecl.
isa<ObjCProtocolDecl>(TagDecl))
- NewFD = ObjCIvarDecl::Create(Context, dyn_cast<ObjCInterfaceDecl>(TagDecl), Loc, II, T);
+ NewFD = ObjCIvarDecl::Create(Context, Loc, II, T);
else
assert(0 && "Sema::ActOnField(): Unknown TagDecl");
// Allow all of Sema to see that we are entering a method definition.
CurMethodDecl = MDecl;
- PushContextDecl(MDecl);
+ PushDeclContext(MDecl);
// Create Decl objects for each parameter, entrring them in the scope for
// binding to their use.