forked from OSchip/llvm-project
add accessors to DeclSpec, start moving clients over to use them.
llvm-svn: 39221
This commit is contained in:
parent
0d0111b8e4
commit
f055d43211
|
@ -77,10 +77,10 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
//case DeclSpec::TST_union:
|
||||
//case DeclSpec::TST_struct:
|
||||
case DeclSpec::TST_typedef: {
|
||||
Decl *D = (Decl *)DS.TypenameRep;
|
||||
Decl *D = (Decl *)DS.getTypenameRep();
|
||||
assert(D && "Didn't get a decl for a typedef?");
|
||||
assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
|
||||
DS.TypeSpecSign == 0 &&
|
||||
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
|
||||
DS.getTypeSpecSign() == 0 &&
|
||||
"Can't handle qualifiers on typedef names yet!");
|
||||
// TypeQuals handled by caller.
|
||||
return Ctx.getTypeDeclType(cast<TypedefDecl>(D));
|
||||
|
|
|
@ -28,10 +28,7 @@ unsigned DeclSpec::getParsedSpecifiers() const {
|
|||
if (TypeQualifiers != TQ_unspecified)
|
||||
Res |= PQ_TypeQualifier;
|
||||
|
||||
if (TypeSpecWidth != TSW_unspecified ||
|
||||
TypeSpecComplex != TSC_unspecified ||
|
||||
TypeSpecSign != TSS_unspecified ||
|
||||
TypeSpecType != TST_unspecified)
|
||||
if (hasTypeSpecifier())
|
||||
Res |= PQ_TypeSpecifier;
|
||||
|
||||
if (FS_inline_specified)
|
||||
|
|
|
@ -25,7 +25,7 @@ struct TypeNameInfo {
|
|||
|
||||
TypeNameInfo(bool istypename, TypeNameInfo *prev) {
|
||||
isTypeName = istypename;
|
||||
Prev = prev;
|
||||
Prev = prev;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,8 @@ MinimalAction::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
|
|||
if (II == 0) return 0;
|
||||
|
||||
TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>();
|
||||
bool isTypeName = D.getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef;
|
||||
bool isTypeName =
|
||||
D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef;
|
||||
|
||||
// this check avoids creating TypeNameInfo objects for the common case.
|
||||
// It does need to handle the uncommon case of shadowing a typedef name with a
|
||||
|
|
|
@ -253,10 +253,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
|
|||
// This identifier can only be a typedef name if we haven't already seen
|
||||
// a type-specifier. Without this check we misparse:
|
||||
// typedef int X; struct Y { short X; }; as 'short int'.
|
||||
if (DS.TypeSpecType == DeclSpec::TST_unspecified &&
|
||||
DS.TypeSpecWidth == DeclSpec::TSW_unspecified &&
|
||||
DS.TypeSpecComplex == DeclSpec::TSC_unspecified &&
|
||||
DS.TypeSpecSign == DeclSpec::TSS_unspecified) {
|
||||
if (!DS.hasTypeSpecifier()) {
|
||||
// It has to be available as a typedef too!
|
||||
if (void *TypeRep = Actions.isTypeName(*Tok.getIdentifierInfo(),
|
||||
CurScope)) {
|
||||
|
@ -990,7 +987,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
|
|||
ParseAttributes();
|
||||
|
||||
// Verify C99 6.7.5.3p2: The only SCS allowed is 'register'.
|
||||
switch (DS.StorageClassSpec) {
|
||||
switch (DS.getStorageClassSpec()) {
|
||||
case DeclSpec::SCS_unspecified:
|
||||
case DeclSpec::SCS_register:
|
||||
break;
|
||||
|
|
|
@ -77,10 +77,10 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
//case DeclSpec::TST_union:
|
||||
//case DeclSpec::TST_struct:
|
||||
case DeclSpec::TST_typedef: {
|
||||
Decl *D = (Decl *)DS.TypenameRep;
|
||||
Decl *D = (Decl *)DS.getTypenameRep();
|
||||
assert(D && "Didn't get a decl for a typedef?");
|
||||
assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
|
||||
DS.TypeSpecSign == 0 &&
|
||||
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
|
||||
DS.getTypeSpecSign() == 0 &&
|
||||
"Can't handle qualifiers on typedef names yet!");
|
||||
// TypeQuals handled by caller.
|
||||
return Ctx.getTypeDeclType(cast<TypedefDecl>(D));
|
||||
|
|
|
@ -93,8 +93,6 @@ public:
|
|||
PQ_FunctionSpecifier = 8
|
||||
};
|
||||
|
||||
|
||||
|
||||
// storage-class-specifier
|
||||
SCS StorageClassSpec : 3;
|
||||
bool SCS_thread_specified : 1;
|
||||
|
@ -111,6 +109,7 @@ public:
|
|||
// function-specifier
|
||||
bool FS_inline_specified : 1;
|
||||
|
||||
private:
|
||||
|
||||
// TypenameRep - If TypeSpecType == TST_typedef, this contains the
|
||||
// representation for the typedef.
|
||||
|
@ -118,6 +117,7 @@ public:
|
|||
|
||||
// attributes.
|
||||
// FIXME: implement declspec attributes.
|
||||
public:
|
||||
|
||||
DeclSpec()
|
||||
: StorageClassSpec(SCS_unspecified),
|
||||
|
@ -131,6 +131,34 @@ public:
|
|||
TypenameRep(0) {
|
||||
}
|
||||
|
||||
// storage-class-specifier
|
||||
SCS getStorageClassSpec() const { return StorageClassSpec; }
|
||||
bool isThreadSpecified() const { return SCS_thread_specified; }
|
||||
|
||||
// type-specifier
|
||||
TSW getTypeSpecWidth() const { return TypeSpecWidth; }
|
||||
TSC getTypeSpecComplex() const { return TypeSpecComplex; }
|
||||
TSS getTypeSpecSign() const { return TypeSpecSign; }
|
||||
TST getTypeSpecType() const { return TypeSpecType; }
|
||||
void *getTypenameRep() const { return TypenameRep; }
|
||||
|
||||
// type-qualifiers
|
||||
|
||||
/// getTypeQualifiers - Return a set of TQs.
|
||||
unsigned getTypeQualifiers() const { return TypeQualifiers; }
|
||||
|
||||
// function-specifier
|
||||
bool isInlineSpecified() const { return FS_inline_specified; }
|
||||
|
||||
/// hasTypeSpecifier - Return true if any type-specifier has been found.
|
||||
bool hasTypeSpecifier() const {
|
||||
return getTypeSpecType() != DeclSpec::TST_unspecified ||
|
||||
getTypeSpecWidth() != DeclSpec::TSW_unspecified ||
|
||||
getTypeSpecComplex() != DeclSpec::TSC_unspecified ||
|
||||
getTypeSpecSign() != DeclSpec::TSS_unspecified;
|
||||
}
|
||||
|
||||
|
||||
/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
|
||||
/// DeclSpec includes.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue