From: Devang Patel Date: Thu, 1 Nov 2007 16:29:56 +0000 (+0000) Subject: Propagate bitfield info. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54e62357516ace7175a923dad4f94463e793e516;p=clang Propagate bitfield info. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43613 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 0d993b8fcc..ee5327f0cd 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1628,7 +1628,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagDecl, FieldDecl *NewFD; if (isa(static_cast(TagDecl))) - NewFD = new FieldDecl(Loc, II, T); + NewFD = new FieldDecl(Loc, II, T, BitWidth); else if (isa(static_cast(TagDecl)) || isa(static_cast(TagDecl))) NewFD = new ObjcIvarDecl(Loc, II, T); diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 0ed304cab7..10d4c06cd4 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -417,15 +417,20 @@ private: /// represent a member of a struct/union/class. class FieldDecl : public NamedDecl { QualType DeclType; + Expr *BitWidth; public: - FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T) - : NamedDecl(Field, L, Id), DeclType(T) {} - FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T) - : NamedDecl(DK, L, Id), DeclType(T) {} + FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T, + Expr *BW = NULL) + : NamedDecl(Field, L, Id), DeclType(T), BitWidth(BW) {} + FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T, + Expr *BW = NULL) + : NamedDecl(DK, L, Id), DeclType(T), BitWidth(BW) {} QualType getType() const { return DeclType; } QualType getCanonicalType() const { return DeclType.getCanonicalType(); } + bool isBitField() const { return BitWidth != NULL; } + Expr *getBitWidth() const { return BitWidth; } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= FieldFirst && D->getKind() <= FieldLast;