diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-27 23:31:14 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-27 23:31:14 +0000 | 
| commit | 01daafc58a7fec37dfc41877f2a386cba0b6c5d3 (patch) | |
| tree | 2dd6ff56245346b45546b6818d176c04329bd3e9 /clang/lib/AST/DeclCXX.cpp | |
| parent | 6316021baea81f47cb561c3d77679faa78aa87cf (diff) | |
| download | bcm5719-llvm-01daafc58a7fec37dfc41877f2a386cba0b6c5d3.tar.gz bcm5719-llvm-01daafc58a7fec37dfc41877f2a386cba0b6c5d3.zip | |
Centralize the management of CXXRecordDecl::DefinitionData's Empty bit
in CXXRecordDecl itself. Yes, this is also part of <rdar://problem/8459981>.
llvm-svn: 114924
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
| -rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 29 | 
1 files changed, 27 insertions, 2 deletions
| diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 440eaddb7c1..b4c130428c5 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -105,6 +105,11 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,      //   A POD-struct is an aggregate class...      data().PlainOldData = false; +    // A class with a non-empty base class is not empty. +    // FIXME: Standard ref? +    if (!BaseClassDecl->isEmpty()) +      data().Empty = false; +          // Now go through all virtual bases of this base and add them.      for (CXXRecordDecl::base_class_iterator VBase =            BaseClassDecl->vbases_begin(), @@ -118,8 +123,12 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,        // Add this base if it's not already in the list.        if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)))            VBases.push_back(Base); +       +      // C++0x [meta.unary.prop] is_empty: +      //    T is a class type, but not a union type, with ... no virtual base +      //    classes +      data().Empty = false;      } -    }    if (VBases.empty()) @@ -285,6 +294,10 @@ CXXRecordDecl::addedMember(Decl *D) {        // C++ [class]p4:        //   A POD-struct is an aggregate class...        data().PlainOldData = false; +       +      // Virtual functions make the class non-empty. +      // FIXME: Standard ref? +      data().Empty = false;      }    } @@ -429,6 +442,19 @@ CXXRecordDecl::addedMember(Decl *D) {      QualType T = Context.getBaseElementType(Field->getType());      if (!T->isPODType())        data().PlainOldData = false; +     +    // If this is not a zero-length bit-field, then the class is not empty. +    if (data().Empty) { +      if (!Field->getBitWidth()) +        data().Empty = false; +      else if (!Field->getBitWidth()->isTypeDependent() && +               !Field->getBitWidth()->isValueDependent()) { +        llvm::APSInt Bits; +        if (Field->getBitWidth()->isIntegerConstantExpr(Bits, Context)) +          if (!!Bits) +            data().Empty = false; +      }  +    }    }  } @@ -614,7 +640,6 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) {  void CXXRecordDecl::setMethodAsVirtual(FunctionDecl *Method) {    Method->setVirtualAsWritten(true); -  setEmpty(false);    setPolymorphic(true);    setHasTrivialConstructor(false);    setHasTrivialCopyConstructor(false); | 

