forked from OSchip/llvm-project
Generalize DeclSpec::TypedefRep to allow it to hold any type representation.
Use it to hold the declaration object for a struct/union. llvm-svn: 39282
This commit is contained in:
parent
90a26b0758
commit
b9d572a0a8
|
@ -78,7 +78,7 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
//case DeclSpec::TST_union:
|
||||
//case DeclSpec::TST_struct:
|
||||
case DeclSpec::TST_typedef: {
|
||||
Decl *D = (Decl *)DS.getTypenameRep();
|
||||
Decl *D = static_cast<Decl *>(DS.getTypeRep());
|
||||
assert(D && "Didn't get a decl for a typedef?");
|
||||
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
|
||||
DS.getTypeSpecSign() == 0 &&
|
||||
|
|
|
@ -171,11 +171,11 @@ bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
|
|||
}
|
||||
|
||||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
||||
const char *&PrevSpec, void *TypeRep) {
|
||||
const char *&PrevSpec, void *Rep) {
|
||||
if (TypeSpecType != TST_unspecified)
|
||||
return BadSpecifier(TypeSpecType, PrevSpec);
|
||||
TypeSpecType = T;
|
||||
TypenameRep = TypeRep;
|
||||
TypeRep = Rep;
|
||||
TSTLoc = Loc;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ void Parser::ParseStructUnionSpecifier(DeclSpec &DS) {
|
|||
ParseStructUnionBody(TagType, TagDecl);
|
||||
|
||||
const char *PrevSpec = 0;
|
||||
if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec))
|
||||
if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagDecl))
|
||||
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
//case DeclSpec::TST_union:
|
||||
//case DeclSpec::TST_struct:
|
||||
case DeclSpec::TST_typedef: {
|
||||
Decl *D = (Decl *)DS.getTypenameRep();
|
||||
Decl *D = static_cast<Decl *>(DS.getTypeRep());
|
||||
assert(D && "Didn't get a decl for a typedef?");
|
||||
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
|
||||
DS.getTypeSpecSign() == 0 &&
|
||||
|
|
|
@ -111,9 +111,10 @@ private:
|
|||
// function-specifier
|
||||
bool FS_inline_specified : 1;
|
||||
|
||||
// TypenameRep - If TypeSpecType == TST_typedef, this contains the
|
||||
// representation for the typedef.
|
||||
void *TypenameRep;
|
||||
/// TypeRep - This contains action-specific information about a specific TST.
|
||||
/// For example, for a typedef or struct, it might contain the declaration for
|
||||
/// these.
|
||||
void *TypeRep;
|
||||
|
||||
// attributes.
|
||||
// FIXME: implement declspec attributes.
|
||||
|
@ -135,7 +136,7 @@ public:
|
|||
TypeSpecType(TST_unspecified),
|
||||
TypeQualifiers(TSS_unspecified),
|
||||
FS_inline_specified(false),
|
||||
TypenameRep(0) {
|
||||
TypeRep(0) {
|
||||
}
|
||||
|
||||
// storage-class-specifier
|
||||
|
@ -158,7 +159,7 @@ public:
|
|||
TSC getTypeSpecComplex() const { return TypeSpecComplex; }
|
||||
TSS getTypeSpecSign() const { return TypeSpecSign; }
|
||||
TST getTypeSpecType() const { return TypeSpecType; }
|
||||
void *getTypenameRep() const { return TypenameRep; }
|
||||
void *getTypeRep() const { return TypeRep; }
|
||||
|
||||
SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; }
|
||||
SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
|
||||
|
@ -210,7 +211,7 @@ public:
|
|||
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec);
|
||||
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec);
|
||||
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
||||
void *TypenameRep = 0);
|
||||
void *TypeRep = 0);
|
||||
|
||||
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
|
||||
const LangOptions &Lang);
|
||||
|
|
Loading…
Reference in New Issue