[cfe-commits] r65168 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclObjC.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 20 13:35:14 PST 2009
Author: lattner
Date: Fri Feb 20 15:35:13 2009
New Revision: 65168
URL: http://llvm.org/viewvc/llvm-project?rev=65168&view=rev
Log:
add plumbing to get ASTContext& down to allocation/deallocation points in ObjCList,
but don't start using it yet. Renamed some methods to be more consistent.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=65168&r1=65167&r2=65168&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Feb 20 15:35:13 2009
@@ -43,13 +43,13 @@
assert(List == 0 && "Destroy should have been called before dtor");
}
- void Destroy();
+ void Destroy(ASTContext &Ctx);
unsigned size() const { return NumElts; }
bool empty() const { return NumElts == 0; }
protected:
- void set(void *const* InList, unsigned Elts);
+ void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
};
@@ -60,8 +60,8 @@
template <typename T>
class ObjCList : public ObjCListBase {
public:
- void set(T* const* InList, unsigned Elts) {
- ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts);
+ void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
+ ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
}
typedef T* const * iterator;
@@ -195,8 +195,9 @@
param_iterator param_begin() const { return ParamInfo.begin(); }
param_iterator param_end() const { return ParamInfo.end(); }
- void setMethodParams(ParmVarDecl *const *NewParamInfo, unsigned NumParams) {
- ParamInfo.set(NewParamInfo, NumParams);
+ void setMethodParams(ParmVarDecl *const *List, unsigned Num,
+ ASTContext &C) {
+ ParamInfo.set(List, Num, C);
}
/// createImplicitParams - Used to lazily create the self and cmd
@@ -398,16 +399,15 @@
unsigned ivar_size() const { return IVars.size(); }
bool ivar_empty() const { return IVars.empty(); }
- /// addReferencedProtocols - Set the list of protocols that this interface
+ /// setProtocolList - Set the list of protocols that this interface
/// implements.
- void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
- ReferencedProtocols.set(List, NumRPs);
+ void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
+ ASTContext &C) {
+ ReferencedProtocols.set(List, Num, C);
}
- void addInstanceVariablesToClass(ObjCIvarDecl * const* ivars, unsigned Num,
- SourceLocation RBracLoc) {
- IVars.set(ivars, Num);
- setLocEnd(RBracLoc);
+ void setIVarList(ObjCIvarDecl * const *List, unsigned Num, ASTContext &C) {
+ IVars.set(List, Num, C);
}
FieldDecl *lookupFieldDeclForIvar(ASTContext &Context,
const ObjCIvarDecl *ivar);
@@ -589,10 +589,11 @@
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
- /// addReferencedProtocols - Set the list of protocols that this interface
+ /// setProtocolList - Set the list of protocols that this interface
/// implements.
- void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
- ReferencedProtocols.set(List, NumRPs);
+ void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
+ ASTContext &C) {
+ ReferencedProtocols.set(List, Num, C);
}
// Lookup a method. First, we search locally. If a method isn't
@@ -620,10 +621,7 @@
ObjCList<ObjCInterfaceDecl> ForwardDecls;
ObjCClassDecl(DeclContext *DC, SourceLocation L,
- ObjCInterfaceDecl *const *Elts, unsigned nElts)
- : Decl(ObjCClass, DC, L) {
- ForwardDecls.set(Elts, nElts);
- }
+ ObjCInterfaceDecl *const *Elts, unsigned nElts, ASTContext &C);
virtual ~ObjCClassDecl() {}
public:
@@ -650,7 +648,8 @@
ObjCList<ObjCProtocolDecl> ReferencedProtocols;
ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
- ObjCProtocolDecl *const *Elts, unsigned nElts);
+ ObjCProtocolDecl *const *Elts, unsigned nElts,
+ ASTContext &C);
virtual ~ObjCForwardProtocolDecl() {}
public:
@@ -715,10 +714,11 @@
const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
- /// addReferencedProtocols - Set the list of protocols that this interface
+ /// setProtocolList - Set the list of protocols that this interface
/// implements.
- void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
- ReferencedProtocols.set(List, NumRPs);
+ void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
+ ASTContext &C) {
+ ReferencedProtocols.set(List, Num, C);
}
const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
@@ -890,8 +890,8 @@
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
- void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num) {
- IVars.set(InArray, Num);
+ void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num, ASTContext &C) {
+ IVars.set(InArray, Num, C);
}
void addInstanceMethod(ObjCMethodDecl *method) {
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=65168&r1=65167&r2=65168&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Feb 20 15:35:13 2009
@@ -20,13 +20,13 @@
// ObjCListBase
//===----------------------------------------------------------------------===//
-void ObjCListBase::Destroy() {
+void ObjCListBase::Destroy(ASTContext &Ctx) {
delete[] List;
NumElts = 0;
List = 0;
}
-void ObjCListBase::set(void *const* InList, unsigned Elts) {
+void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
assert(List == 0 && "Elements already set!");
if (Elts == 0) return; // Setting to an empty list is a noop.
@@ -206,14 +206,14 @@
isVariadic, isSynthesized, impControl);
}
-void ObjCMethodDecl::Destroy(ASTContext& C) {
+void ObjCMethodDecl::Destroy(ASTContext &C) {
if (Body) Body->Destroy(C);
if (SelfDecl) SelfDecl->Destroy(C);
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- ParamInfo.Destroy();
+ ParamInfo.Destroy(C);
Decl::Destroy(C);
}
@@ -300,7 +300,7 @@
for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- IVars.Destroy();
+ IVars.Destroy(C);
// FIXME: CategoryList?
// FIXME: Because there is no clear ownership
@@ -377,7 +377,7 @@
}
void ObjCProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.Destroy();
+ ReferencedProtocols.Destroy(C);
ObjCContainerDecl::Destroy(C);
}
@@ -413,11 +413,19 @@
// ObjCClassDecl
//===----------------------------------------------------------------------===//
+ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L,
+ ObjCInterfaceDecl *const *Elts, unsigned nElts,
+ ASTContext &C)
+ : Decl(ObjCClass, DC, L) {
+ ForwardDecls.set(Elts, nElts, C);
+}
+
+
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
ObjCInterfaceDecl *const *Elts,
unsigned nElts) {
- return new (C) ObjCClassDecl(DC, L, Elts, nElts);
+ return new (C) ObjCClassDecl(DC, L, Elts, nElts, C);
}
void ObjCClassDecl::Destroy(ASTContext &C) {
@@ -430,7 +438,7 @@
// obviating this problem. Because of this situation, referenced
// ObjCInterfaceDecls are destroyed in ~TranslationUnit.
- ForwardDecls.Destroy();
+ ForwardDecls.Destroy(C);
Decl::Destroy(C);
}
@@ -438,23 +446,25 @@
// ObjCForwardProtocolDecl
//===----------------------------------------------------------------------===//
+ObjCForwardProtocolDecl::
+ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
+ ObjCProtocolDecl *const *Elts, unsigned nElts,
+ ASTContext &C)
+: Decl(ObjCForwardProtocol, DC, L) {
+ ReferencedProtocols.set(Elts, nElts, C);
+}
+
+
ObjCForwardProtocolDecl *
ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
ObjCProtocolDecl *const *Elts,
unsigned NumElts) {
- return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts);
-}
-
-ObjCForwardProtocolDecl::
-ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
- ObjCProtocolDecl *const *Elts, unsigned nElts)
- : Decl(ObjCForwardProtocol, DC, L) {
- ReferencedProtocols.set(Elts, nElts);
+ return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, C);
}
void ObjCForwardProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.Destroy();
+ ReferencedProtocols.Destroy(C);
Decl::Destroy(C);
}
@@ -543,8 +553,8 @@
}
/// Destroy - Call destructors and release memory.
-void ObjCImplementationDecl::Destroy(ASTContext& C) {
- IVars.Destroy();
+void ObjCImplementationDecl::Destroy(ASTContext &C) {
+ IVars.Destroy(C);
Decl::Destroy(C);
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=65168&r1=65167&r2=65168&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 20 15:35:13 2009
@@ -3688,7 +3688,9 @@
} else {
ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(&RecFields[0]);
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl)) {
- ID->addInstanceVariablesToClass(ClsFields, RecFields.size(), RBrac);
+ ID->setIVarList(ClsFields, RecFields.size(), Context);
+ ID->setLocEnd(RBrac);
+
// Must enforce the rule that ivars in the base classes may not be
// duplicates.
if (ID->getSuperClass()) {
@@ -3707,7 +3709,7 @@
else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
- IMPDecl->setIVarList(ClsFields, RecFields.size());
+ IMPDecl->setIVarList(ClsFields, RecFields.size(), Context);
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
}
}
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=65168&r1=65167&r2=65168&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Feb 20 15:35:13 2009
@@ -152,7 +152,8 @@
/// Check then save referenced protocols.
if (NumProtoRefs) {
- IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
+ IDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,
+ Context);
IDecl->setLocEnd(EndProtoLoc);
}
@@ -245,7 +246,7 @@
ProcessDeclAttributeList(PDecl, AttrList);
if (NumProtoRefs) {
/// Check then save referenced protocols.
- PDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
+ PDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context);
PDecl->setLocEnd(EndProtoLoc);
}
@@ -509,7 +510,7 @@
CDecl->insertNextClassCategory();
if (NumProtoRefs) {
- CDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
+ CDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context);
CDecl->setLocEnd(EndProtoLoc);
}
@@ -634,7 +635,8 @@
/// (legacy objective-c @implementation decl without an @interface decl).
/// Add implementations's ivar to the synthesize class's ivar list.
if (IDecl->ImplicitInterfaceDecl()) {
- IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace);
+ IDecl->setIVarList(ivars, numIvars, Context);
+ IDecl->setLocEnd(RBrace);
return;
}
// If implementation has empty ivar list, just return.
@@ -1166,7 +1168,7 @@
property->getType(),
VarDecl::None,
0);
- SetterMethod->setMethodParams(&Argument, 1);
+ SetterMethod->setMethodParams(&Argument, 1, Context);
CD->addDecl(SetterMethod);
} else
// A user declared setter will be synthesize when @synthesize of
@@ -1395,7 +1397,7 @@
Params.push_back(Param);
}
- ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs());
+ ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs(), Context);
ObjCMethod->setObjCDeclQualifier(
CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));
const ObjCMethodDecl *PrevMethod = 0;
@@ -1560,14 +1562,11 @@
ICDecl,
true, false, true,
ObjCMethodDecl::Required);
- ParmVarDecl *Argument = ParmVarDecl::Create(Context,
- SetterDecl,
+ ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterDecl,
SourceLocation(),
FD.D.getIdentifier(),
- T,
- VarDecl::None,
- 0);
- SetterDecl->setMethodParams(&Argument, 1);
+ T, VarDecl::None, 0);
+ SetterDecl->setMethodParams(&Argument, 1, Context);
PIDecl->setSetterMethodDecl(SetterDecl);
}
else
More information about the cfe-commits
mailing list