зеркало из https://github.com/microsoft/clang-1.git
Add create methods for ObjCCategoryDecl, ObjCForwardProtocolDecl, ObjCClassDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48426 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
62db2f4214
Коммит
61f9d41036
|
@ -523,7 +523,7 @@ public:
|
||||||
class ObjCClassDecl : public Decl {
|
class ObjCClassDecl : public Decl {
|
||||||
ObjCInterfaceDecl **ForwardDecls;
|
ObjCInterfaceDecl **ForwardDecls;
|
||||||
unsigned NumForwardDecls;
|
unsigned NumForwardDecls;
|
||||||
public:
|
|
||||||
ObjCClassDecl(SourceLocation L, ObjCInterfaceDecl **Elts, unsigned nElts)
|
ObjCClassDecl(SourceLocation L, ObjCInterfaceDecl **Elts, unsigned nElts)
|
||||||
: Decl(ObjCClass, L) {
|
: Decl(ObjCClass, L) {
|
||||||
if (nElts) {
|
if (nElts) {
|
||||||
|
@ -534,6 +534,10 @@ public:
|
||||||
}
|
}
|
||||||
NumForwardDecls = nElts;
|
NumForwardDecls = nElts;
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
static ObjCClassDecl *Create(ASTContext &C, SourceLocation L,
|
||||||
|
ObjCInterfaceDecl **Elts, unsigned nElts);
|
||||||
|
|
||||||
void setInterfaceDecl(unsigned idx, ObjCInterfaceDecl *OID) {
|
void setInterfaceDecl(unsigned idx, ObjCInterfaceDecl *OID) {
|
||||||
assert(idx < NumForwardDecls && "index out of range");
|
assert(idx < NumForwardDecls && "index out of range");
|
||||||
ForwardDecls[idx] = OID;
|
ForwardDecls[idx] = OID;
|
||||||
|
@ -553,7 +557,7 @@ public:
|
||||||
class ObjCForwardProtocolDecl : public Decl {
|
class ObjCForwardProtocolDecl : public Decl {
|
||||||
ObjCProtocolDecl **ReferencedProtocols;
|
ObjCProtocolDecl **ReferencedProtocols;
|
||||||
unsigned NumReferencedProtocols;
|
unsigned NumReferencedProtocols;
|
||||||
public:
|
|
||||||
ObjCForwardProtocolDecl(SourceLocation L,
|
ObjCForwardProtocolDecl(SourceLocation L,
|
||||||
ObjCProtocolDecl **Elts, unsigned nElts)
|
ObjCProtocolDecl **Elts, unsigned nElts)
|
||||||
: Decl(ObjCForwardProtocol, L) {
|
: Decl(ObjCForwardProtocol, L) {
|
||||||
|
@ -565,6 +569,11 @@ public:
|
||||||
ReferencedProtocols = 0;
|
ReferencedProtocols = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
static ObjCForwardProtocolDecl *Create(ASTContext &C, SourceLocation L,
|
||||||
|
ObjCProtocolDecl **Elts, unsigned Num);
|
||||||
|
|
||||||
|
|
||||||
void setForwardProtocolDecl(unsigned idx, ObjCProtocolDecl *OID) {
|
void setForwardProtocolDecl(unsigned idx, ObjCProtocolDecl *OID) {
|
||||||
assert(idx < NumReferencedProtocols && "index out of range");
|
assert(idx < NumReferencedProtocols && "index out of range");
|
||||||
ReferencedProtocols[idx] = OID;
|
ReferencedProtocols[idx] = OID;
|
||||||
|
@ -625,7 +634,7 @@ class ObjCCategoryDecl : public NamedDecl {
|
||||||
|
|
||||||
SourceLocation EndLoc; // marks the '>' or identifier.
|
SourceLocation EndLoc; // marks the '>' or identifier.
|
||||||
SourceLocation AtEndLoc; // marks the end of the entire interface.
|
SourceLocation AtEndLoc; // marks the end of the entire interface.
|
||||||
public:
|
|
||||||
ObjCCategoryDecl(SourceLocation L, unsigned numRefProtocol,IdentifierInfo *Id)
|
ObjCCategoryDecl(SourceLocation L, unsigned numRefProtocol,IdentifierInfo *Id)
|
||||||
: NamedDecl(ObjCCategory, L, Id),
|
: NamedDecl(ObjCCategory, L, Id),
|
||||||
ClassInterface(0), ReferencedProtocols(0), NumReferencedProtocols(0),
|
ClassInterface(0), ReferencedProtocols(0), NumReferencedProtocols(0),
|
||||||
|
@ -639,7 +648,12 @@ public:
|
||||||
NumReferencedProtocols = numRefProtocol;
|
NumReferencedProtocols = numRefProtocol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
|
||||||
|
static ObjCCategoryDecl *Create(ASTContext &C, SourceLocation L,
|
||||||
|
unsigned numRefProtocol, IdentifierInfo *Id);
|
||||||
|
|
||||||
|
|
||||||
ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
|
ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
|
||||||
void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
|
void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,26 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, SourceLocation L,
|
||||||
return new (Mem) ObjCProtocolDecl(L, numRefProtos, Id);
|
return new (Mem) ObjCProtocolDecl(L, numRefProtos, Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, SourceLocation L,
|
||||||
|
ObjCInterfaceDecl **Elts, unsigned nElts) {
|
||||||
|
void *Mem = C.getAllocator().Allocate<ObjCClassDecl>();
|
||||||
|
return new (Mem) ObjCClassDecl(L, Elts, nElts);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjCForwardProtocolDecl *
|
||||||
|
ObjCForwardProtocolDecl::Create(ASTContext &C, SourceLocation L,
|
||||||
|
ObjCProtocolDecl **Elts, unsigned NumElts) {
|
||||||
|
void *Mem = C.getAllocator().Allocate<ObjCForwardProtocolDecl>();
|
||||||
|
return new (Mem) ObjCForwardProtocolDecl(L, Elts, NumElts);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, SourceLocation L,
|
||||||
|
unsigned numRefProtocol,
|
||||||
|
IdentifierInfo *Id) {
|
||||||
|
void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
|
||||||
|
return new (Mem) ObjCCategoryDecl(L, numRefProtocol, Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Objective-C Decl Implementation
|
// Objective-C Decl Implementation
|
||||||
|
|
|
@ -268,8 +268,8 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
||||||
|
|
||||||
Protocols.push_back(PDecl);
|
Protocols.push_back(PDecl);
|
||||||
}
|
}
|
||||||
return new ObjCForwardProtocolDecl(AtProtocolLoc,
|
return ObjCForwardProtocolDecl::Create(Context, AtProtocolLoc,
|
||||||
&Protocols[0], Protocols.size());
|
&Protocols[0], Protocols.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Sema::DeclTy *Sema::ActOnStartCategoryInterface(
|
Sema::DeclTy *Sema::ActOnStartCategoryInterface(
|
||||||
|
@ -280,8 +280,9 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(
|
||||||
SourceLocation EndProtoLoc) {
|
SourceLocation EndProtoLoc) {
|
||||||
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
|
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
|
||||||
|
|
||||||
ObjCCategoryDecl *CDecl = new ObjCCategoryDecl(AtInterfaceLoc, NumProtoRefs,
|
ObjCCategoryDecl *CDecl =
|
||||||
CategoryName);
|
ObjCCategoryDecl::Create(Context, AtInterfaceLoc, NumProtoRefs,
|
||||||
|
CategoryName);
|
||||||
CDecl->setClassInterface(IDecl);
|
CDecl->setClassInterface(IDecl);
|
||||||
|
|
||||||
/// Check that class of this category is already completely declared.
|
/// Check that class of this category is already completely declared.
|
||||||
|
@ -605,7 +606,8 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
|
||||||
Interfaces.push_back(IDecl);
|
Interfaces.push_back(IDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ObjCClassDecl(AtClassLoc, &Interfaces[0], Interfaces.size());
|
return ObjCClassDecl::Create(Context, AtClassLoc,
|
||||||
|
&Interfaces[0], Interfaces.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче