Skip to content

Commit

Permalink
[clang][NFC] Annotate Sema/DeclSpec.h with preferred_type
Browse files Browse the repository at this point in the history
This helps debuggers to display values in bit-fields in a more helpful way.
  • Loading branch information
Endilll committed Feb 10, 2024
1 parent 2a51c56 commit 3a05e76
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions clang/include/clang/Sema/DeclSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,36 +353,57 @@ class DeclSpec {

private:
// storage-class-specifier
/*SCS*/unsigned StorageClassSpec : 3;
/*TSCS*/unsigned ThreadStorageClassSpec : 2;
LLVM_PREFERRED_TYPE(SCS)
unsigned StorageClassSpec : 3;
LLVM_PREFERRED_TYPE(TSCS)
unsigned ThreadStorageClassSpec : 2;
LLVM_PREFERRED_TYPE(bool)
unsigned SCS_extern_in_linkage_spec : 1;

// type-specifier
/*TypeSpecifierWidth*/ unsigned TypeSpecWidth : 2;
/*TSC*/unsigned TypeSpecComplex : 2;
/*TSS*/unsigned TypeSpecSign : 2;
/*TST*/unsigned TypeSpecType : 7;
LLVM_PREFERRED_TYPE(TypeSpecifierWidth)
unsigned TypeSpecWidth : 2;
LLVM_PREFERRED_TYPE(TSC)
unsigned TypeSpecComplex : 2;
LLVM_PREFERRED_TYPE(TypeSpecifierSign)
unsigned TypeSpecSign : 2;
LLVM_PREFERRED_TYPE(TST)
unsigned TypeSpecType : 7;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeAltiVecVector : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeAltiVecPixel : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeAltiVecBool : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeSpecOwned : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeSpecPipe : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned TypeSpecSat : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned ConstrainedAuto : 1;

// type-qualifiers
LLVM_PREFERRED_TYPE(TQ)
unsigned TypeQualifiers : 5; // Bitwise OR of TQ.

// function-specifier
LLVM_PREFERRED_TYPE(bool)
unsigned FS_inline_specified : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned FS_forceinline_specified: 1;
LLVM_PREFERRED_TYPE(bool)
unsigned FS_virtual_specified : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned FS_noreturn_specified : 1;

// friend-specifier
LLVM_PREFERRED_TYPE(bool)
unsigned Friend_specified : 1;

// constexpr-specifier
LLVM_PREFERRED_TYPE(ConstexprSpecKind)
unsigned ConstexprSpecifier : 2;

union {
Expand Down Expand Up @@ -1246,6 +1267,7 @@ struct DeclaratorChunk {

struct PointerTypeInfo {
/// The type qualifiers: const/volatile/restrict/unaligned/atomic.
LLVM_PREFERRED_TYPE(DeclSpec::TQ)
unsigned TypeQuals : 5;

/// The location of the const-qualifier, if any.
Expand Down Expand Up @@ -1279,12 +1301,15 @@ struct DeclaratorChunk {
struct ArrayTypeInfo {
/// The type qualifiers for the array:
/// const/volatile/restrict/__unaligned/_Atomic.
LLVM_PREFERRED_TYPE(DeclSpec::TQ)
unsigned TypeQuals : 5;

/// True if this dimension included the 'static' keyword.
LLVM_PREFERRED_TYPE(bool)
unsigned hasStatic : 1;

/// True if this dimension was [*]. In this case, NumElts is null.
LLVM_PREFERRED_TYPE(bool)
unsigned isStar : 1;

/// This is the size of the array, or null if [] or [*] was specified.
Expand Down Expand Up @@ -1331,28 +1356,35 @@ struct DeclaratorChunk {
/// hasPrototype - This is true if the function had at least one typed
/// parameter. If the function is () or (a,b,c), then it has no prototype,
/// and is treated as a K&R-style function.
LLVM_PREFERRED_TYPE(bool)
unsigned hasPrototype : 1;

/// isVariadic - If this function has a prototype, and if that
/// proto ends with ',...)', this is true. When true, EllipsisLoc
/// contains the location of the ellipsis.
LLVM_PREFERRED_TYPE(bool)
unsigned isVariadic : 1;

/// Can this declaration be a constructor-style initializer?
LLVM_PREFERRED_TYPE(bool)
unsigned isAmbiguous : 1;

/// Whether the ref-qualifier (if any) is an lvalue reference.
/// Otherwise, it's an rvalue reference.
LLVM_PREFERRED_TYPE(bool)
unsigned RefQualifierIsLValueRef : 1;

/// ExceptionSpecType - An ExceptionSpecificationType value.
LLVM_PREFERRED_TYPE(ExceptionSpecificationType)
unsigned ExceptionSpecType : 4;

/// DeleteParams - If this is true, we need to delete[] Params.
LLVM_PREFERRED_TYPE(bool)
unsigned DeleteParams : 1;

/// HasTrailingReturnType - If this is true, a trailing return type was
/// specified.
LLVM_PREFERRED_TYPE(bool)
unsigned HasTrailingReturnType : 1;

/// The location of the left parenthesis in the source.
Expand Down Expand Up @@ -1567,6 +1599,7 @@ struct DeclaratorChunk {
struct BlockPointerTypeInfo {
/// For now, sema will catch these as invalid.
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
LLVM_PREFERRED_TYPE(DeclSpec::TQ)
unsigned TypeQuals : 5;

void destroy() {
Expand All @@ -1575,6 +1608,7 @@ struct DeclaratorChunk {

struct MemberPointerTypeInfo {
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
LLVM_PREFERRED_TYPE(DeclSpec::TQ)
unsigned TypeQuals : 5;
/// Location of the '*' token.
SourceLocation StarLoc;
Expand Down Expand Up @@ -1767,6 +1801,7 @@ class DecompositionDeclarator {
/// The bindings.
Binding *Bindings;
unsigned NumBindings : 31;
LLVM_PREFERRED_TYPE(bool)
unsigned DeleteBindings : 1;

friend class Declarator;
Expand Down Expand Up @@ -1883,33 +1918,42 @@ class Declarator {
SmallVector<DeclaratorChunk, 8> DeclTypeInfo;

/// InvalidType - Set by Sema::GetTypeForDeclarator().
LLVM_PREFERRED_TYPE(bool)
unsigned InvalidType : 1;

/// GroupingParens - Set by Parser::ParseParenDeclarator().
LLVM_PREFERRED_TYPE(bool)
unsigned GroupingParens : 1;

/// FunctionDefinition - Is this Declarator for a function or member
/// definition and, if so, what kind?
///
/// Actually a FunctionDefinitionKind.
LLVM_PREFERRED_TYPE(FunctionDefinitionKind)
unsigned FunctionDefinition : 2;

/// Is this Declarator a redeclaration?
LLVM_PREFERRED_TYPE(bool)
unsigned Redeclaration : 1;

/// true if the declaration is preceded by \c __extension__.
LLVM_PREFERRED_TYPE(bool)
unsigned Extension : 1;

/// Indicates whether this is an Objective-C instance variable.
LLVM_PREFERRED_TYPE(bool)
unsigned ObjCIvar : 1;

/// Indicates whether this is an Objective-C 'weak' property.
LLVM_PREFERRED_TYPE(bool)
unsigned ObjCWeakProperty : 1;

/// Indicates whether the InlineParams / InlineBindings storage has been used.
LLVM_PREFERRED_TYPE(bool)
unsigned InlineStorageUsed : 1;

/// Indicates whether this declarator has an initializer.
LLVM_PREFERRED_TYPE(bool)
unsigned HasInitializer : 1;

/// Attributes attached to the declarator.
Expand Down

0 comments on commit 3a05e76

Please sign in to comment.