mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 09:01:19 +00:00
RecordDecl:
- Remove method 'isForwardDecl'; this functionality is already provided by 'isDefinition()' - Move method definitions to be co-located with other RecordDecl methods. llvm-svn: 55649
This commit is contained in:
parent
cc4d6ce532
commit
52baf50f62
@ -821,14 +821,7 @@ public:
|
||||
RecordDecl *PrevDecl);
|
||||
|
||||
virtual void Destroy(ASTContext& C);
|
||||
|
||||
/// isForwardDeclaration - Returns true if this RecordDecl represents a
|
||||
/// forward declaration.
|
||||
bool isForwardDeclaration() const {
|
||||
assert ((!Members || NextDecl == 0) && "(Members != 0) => (NextDecl == 0)");
|
||||
return !Members;
|
||||
}
|
||||
|
||||
|
||||
/// getDefinitionDecl - Returns the RecordDecl for the struct/union that
|
||||
/// represents the actual definition (i.e., not a forward declaration).
|
||||
/// This method returns NULL if no such RecordDecl exists.
|
||||
|
@ -114,65 +114,6 @@ void EnumDecl::Destroy(ASTContext& C) {
|
||||
Decl::Destroy(C);
|
||||
}
|
||||
|
||||
//==------------------------------------------------------------------------==//
|
||||
// RecordDecl methods.
|
||||
//==------------------------------------------------------------------------==//
|
||||
|
||||
RecordDecl::RecordDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, RecordDecl *PrevDecl)
|
||||
: TagDecl(DK, DC, L, Id, 0), NextDecl(0) {
|
||||
|
||||
HasFlexibleArrayMember = false;
|
||||
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
|
||||
Members = 0;
|
||||
NumMembers = -1;
|
||||
|
||||
// Hook up the RecordDecl chain.
|
||||
if (PrevDecl) {
|
||||
RecordDecl* Tmp = PrevDecl->NextDecl;
|
||||
// 'Tmp' might be non-NULL if it is the RecordDecl that provides the
|
||||
// definition of the struct/union. By construction, the last RecordDecl
|
||||
// in the chain is the 'defining' RecordDecl.
|
||||
if (Tmp) {
|
||||
assert (Tmp->NextDecl == 0);
|
||||
assert (Tmp->Members && "Previous RecordDecl has a NextDecl that is "
|
||||
"not the 'defining' RecordDecl");
|
||||
|
||||
NextDecl = Tmp;
|
||||
}
|
||||
|
||||
PrevDecl->NextDecl = this;
|
||||
}
|
||||
}
|
||||
|
||||
RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
RecordDecl *PrevDecl) {
|
||||
void *Mem = C.getAllocator().Allocate<RecordDecl>();
|
||||
Kind DK;
|
||||
switch (TK) {
|
||||
default: assert(0 && "Invalid TagKind!");
|
||||
case TK_enum: assert(0 && "Enum TagKind passed for Record!");
|
||||
case TK_struct: DK = Struct; break;
|
||||
case TK_union: DK = Union; break;
|
||||
case TK_class: DK = Class; break;
|
||||
}
|
||||
return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
|
||||
}
|
||||
|
||||
/// getDefinitionDecl - Returns the RecordDecl for the struct/union that
|
||||
/// represents the actual definition (i.e., not a forward declaration).
|
||||
/// This method returns NULL if no such RecordDecl exists.
|
||||
const RecordDecl* RecordDecl::getDefinitionDecl() const {
|
||||
const RecordDecl* R = this;
|
||||
|
||||
for (RecordDecl* N = R->NextDecl; N; N = R->NextDecl)
|
||||
R = N;
|
||||
|
||||
return R->Members ? R : 0;
|
||||
}
|
||||
|
||||
|
||||
FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C,
|
||||
SourceLocation L,
|
||||
StringLiteral *Str) {
|
||||
@ -262,6 +203,49 @@ unsigned FunctionDecl::getMinRequiredArguments() const {
|
||||
// RecordDecl Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
RecordDecl::RecordDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, RecordDecl *PrevDecl)
|
||||
: TagDecl(DK, DC, L, Id, 0), NextDecl(0) {
|
||||
|
||||
HasFlexibleArrayMember = false;
|
||||
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
|
||||
Members = 0;
|
||||
NumMembers = -1;
|
||||
|
||||
// Hook up the RecordDecl chain.
|
||||
if (PrevDecl) {
|
||||
RecordDecl* Tmp = PrevDecl->NextDecl;
|
||||
// 'Tmp' might be non-NULL if it is the RecordDecl that provides the
|
||||
// definition of the struct/union. By construction, the last RecordDecl
|
||||
// in the chain is the 'defining' RecordDecl.
|
||||
if (Tmp) {
|
||||
assert (Tmp->NextDecl == 0);
|
||||
assert (Tmp->isDefinition()
|
||||
&& "Previous RecordDecl has a NextDecl that is "
|
||||
"not the 'defining' RecordDecl");
|
||||
|
||||
NextDecl = Tmp;
|
||||
}
|
||||
|
||||
PrevDecl->NextDecl = this;
|
||||
}
|
||||
}
|
||||
|
||||
RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
RecordDecl *PrevDecl) {
|
||||
void *Mem = C.getAllocator().Allocate<RecordDecl>();
|
||||
Kind DK;
|
||||
switch (TK) {
|
||||
default: assert(0 && "Invalid TagKind!");
|
||||
case TK_enum: assert(0 && "Enum TagKind passed for Record!");
|
||||
case TK_struct: DK = Struct; break;
|
||||
case TK_union: DK = Union; break;
|
||||
case TK_class: DK = Class; break;
|
||||
}
|
||||
return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
|
||||
}
|
||||
|
||||
RecordDecl::~RecordDecl() {
|
||||
delete[] Members;
|
||||
}
|
||||
@ -274,7 +258,6 @@ void RecordDecl::Destroy(ASTContext& C) {
|
||||
TagDecl::Destroy(C);
|
||||
}
|
||||
|
||||
|
||||
/// defineBody - When created, RecordDecl's correspond to a forward declared
|
||||
/// record. This method is used to mark the decl as being defined, with the
|
||||
/// specified contents.
|
||||
@ -298,3 +281,16 @@ FieldDecl *RecordDecl::getMember(IdentifierInfo *II) {
|
||||
return Members[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getDefinitionDecl - Returns the RecordDecl for the struct/union that
|
||||
/// represents the actual definition (i.e., not a forward declaration).
|
||||
/// This method returns NULL if no such RecordDecl exists.
|
||||
const RecordDecl* RecordDecl::getDefinitionDecl() const {
|
||||
const RecordDecl* R = this;
|
||||
|
||||
for (RecordDecl* N = R->NextDecl; N; N = R->NextDecl)
|
||||
R = N;
|
||||
|
||||
return R->Members ? R : 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user