]> granicus.if.org Git - clang/commitdiff
Propagate bitfield info.
authorDevang Patel <dpatel@apple.com>
Thu, 1 Nov 2007 16:29:56 +0000 (16:29 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 1 Nov 2007 16:29:56 +0000 (16:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43613 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
include/clang/AST/Decl.h

index 0d993b8fccc779d3e03e29c9810a342a2cc0cda5..ee5327f0cdd5f57d48ddbe5732a276d0363a2a2a 100644 (file)
@@ -1628,7 +1628,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagDecl,
   FieldDecl *NewFD;
   
   if (isa<RecordDecl>(static_cast<Decl *>(TagDecl)))
-    NewFD = new FieldDecl(Loc, II, T);
+    NewFD = new FieldDecl(Loc, II, T, BitWidth);
   else if (isa<ObjcInterfaceDecl>(static_cast<Decl *>(TagDecl))
            || isa<ObjcImplementationDecl>(static_cast<Decl *>(TagDecl)))
     NewFD = new ObjcIvarDecl(Loc, II, T);
index 0ed304cab77746a45abf4ffaada08d6fd1b37e72..10d4c06cd47f344a6e110f9f781ea6f7153b942f 100644 (file)
@@ -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;