[cfe-commits] r49261 - in /cfe/trunk: Driver/RewriteTest.cpp include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/DeclObjC.h lib/AST/ASTContext.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/AST/DeclSerialization.cpp lib/Sema/Sema.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclObjC.cpp
Chris Lattner
sabre at nondot.org
Sat Apr 5 21:47:35 PDT 2008
Author: lattner
Date: Sat Apr 5 23:47:34 2008
New Revision: 49261
URL: http://llvm.org/viewvc/llvm-project?rev=49261&view=rev
Log:
This patch contains these changes:
-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl
Patch by Argiris Kirtzidis!
Modified:
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/AST/DeclSerialization.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Sat Apr 5 23:47:34 2008
@@ -1839,8 +1839,7 @@
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);
@@ -1867,8 +1866,7 @@
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);
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Apr 5 23:47:34 2008
@@ -58,15 +58,15 @@
///
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; }
@@ -83,8 +83,8 @@
// 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;
}
@@ -110,7 +110,7 @@
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:
@@ -143,7 +143,7 @@
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:
@@ -196,12 +196,12 @@
/// 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.
@@ -220,12 +220,12 @@
/// 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);
@@ -247,13 +247,13 @@
/// 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);
@@ -279,7 +279,7 @@
/// 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
@@ -302,16 +302,16 @@
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);
@@ -371,18 +371,14 @@
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; }
@@ -390,7 +386,6 @@
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;
@@ -415,7 +410,7 @@
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) {}
@@ -460,7 +455,7 @@
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:
@@ -475,13 +470,13 @@
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);
@@ -504,14 +499,14 @@
/// 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:
@@ -542,7 +537,7 @@
/// 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;
@@ -552,14 +547,14 @@
/// 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);
@@ -612,7 +607,7 @@
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!");
@@ -621,7 +616,7 @@
}
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);
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sat Apr 5 23:47:34 2008
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the Decl and ContextDecl interfaces.
+// This file defines the Decl and DeclContext interfaces.
//
//===----------------------------------------------------------------------===//
@@ -21,7 +21,7 @@
namespace clang {
class FunctionDecl;
class ObjCMethodDecl;
-class TagDecl;
+class EnumDecl;
class ObjCInterfaceDecl;
/// Decl - This represents one declaration (or definition), e.g. a variable,
@@ -191,20 +191,20 @@
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(); }
@@ -221,23 +221,21 @@
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) {
@@ -249,80 +247,79 @@
}
}
- /// 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
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Apr 5 23:47:34 2008
@@ -48,7 +48,7 @@
/// 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:
@@ -96,7 +96,7 @@
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)),
@@ -198,7 +198,7 @@
/// 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;
@@ -239,7 +239,7 @@
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),
@@ -381,12 +381,10 @@
/// }
///
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 {
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Apr 5 23:47:34 2008
@@ -1131,8 +1131,7 @@
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);
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Apr 5 23:47:34 2008
@@ -204,7 +204,7 @@
// 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) {
@@ -213,7 +213,7 @@
}
-FileVarDecl *FileVarDecl::Create(ASTContext &C, ContextDecl *CD,
+FileVarDecl *FileVarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S,
ScopedDecl *PrevDecl) {
@@ -221,7 +221,7 @@
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) {
@@ -229,7 +229,7 @@
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,
@@ -238,10 +238,10 @@
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);
}
@@ -254,7 +254,7 @@
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) {
@@ -262,14 +262,14 @@
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>();
@@ -330,22 +330,22 @@
}
//===----------------------------------------------------------------------===//
-// 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);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Apr 5 23:47:34 2008
@@ -45,11 +45,10 @@
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,
Modified: cfe/trunk/lib/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclSerialization.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Sat Apr 5 23:47:34 2008
@@ -106,7 +106,7 @@
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) {
@@ -114,7 +114,7 @@
D.ReadPtr(Next); // From ScopedDecl.
Decl *TmpD;
D.ReadPtr(TmpD); // From ScopedDecl.
- CtxDecl = cast_or_null<ContextDecl>(TmpD);
+ CtxDecl = cast_or_null<DeclContext>(TmpD);
}
//===------------------------------------------------------------===//
@@ -306,7 +306,7 @@
}
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>();
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat Apr 5 23:47:34 2008
@@ -120,8 +120,7 @@
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));
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sat Apr 5 23:47:34 2008
@@ -32,7 +32,7 @@
class ASTConsumer;
class Preprocessor;
class Decl;
- class ContextDecl;
+ class DeclContext;
class NamedDecl;
class ScopedDecl;
class Expr;
@@ -75,7 +75,7 @@
/// 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
@@ -250,8 +250,8 @@
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,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Apr 5 23:47:34 2008
@@ -40,14 +40,14 @@
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();
}
@@ -1081,7 +1081,7 @@
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;
@@ -1126,7 +1126,7 @@
MD->setBody((Stmt*)Body);
CurMethodDecl = 0;
}
- PopContextDecl();
+ PopDeclContext();
// Verify and clean out per-function state.
// Check goto/label use.
@@ -1353,8 +1353,8 @@
// 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) ||
@@ -1362,7 +1362,7 @@
// 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");
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=49261&r1=49260&r2=49261&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Apr 5 23:47:34 2008
@@ -33,7 +33,7 @@
// 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.
More information about the cfe-commits
mailing list