]> granicus.if.org Git - clang/commitdiff
Centralize the management of CXXRecordDecl::DefinitionData's
authorDouglas Gregor <dgregor@apple.com>
Mon, 27 Sep 2010 23:39:06 +0000 (23:39 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 27 Sep 2010 23:39:06 +0000 (23:39 +0000)
Polymorphic bit in CXXRecordDecl itself. Yes, this is also part of
<rdar://problem/8459981>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114925 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/Sema/SemaDeclCXX.cpp

index 26020ba6c45046914a41cfc5c93717b6d18f9ca2..53bd720c97c630e0ea548e1b7ca4e35ada899b39 100644 (file)
@@ -708,10 +708,6 @@ public:
   /// which means that the class contains or inherits a virtual function.
   bool isPolymorphic() const { return data().Polymorphic; }
 
-  /// setPolymorphic - Set whether this class is polymorphic (C++
-  /// [class.virtual]).
-  void setPolymorphic(bool Poly) { data().Polymorphic = Poly; }
-
   /// isAbstract - Whether this class is abstract (C++ [class.abstract]),
   /// which means that the class contains or inherits a pure virtual function.
   bool isAbstract() const { return data().Abstract; }
index b4c130428c50a0a9816929f9785a35d5414f40d5..151d333afccc04d11129b3ebb99f61e0c5e2d87f 100644 (file)
@@ -110,6 +110,12 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
     if (!BaseClassDecl->isEmpty())
       data().Empty = false;
     
+    // C++ [class.virtual]p1:
+    //   A class that declares or inherits a virtual function is called a 
+    //   polymorphic class.
+    if (BaseClassDecl->isPolymorphic())
+      data().Polymorphic = true;
+    
     // Now go through all virtual bases of this base and add them.
     for (CXXRecordDecl::base_class_iterator VBase =
           BaseClassDecl->vbases_begin(),
@@ -298,6 +304,11 @@ CXXRecordDecl::addedMember(Decl *D) {
       // Virtual functions make the class non-empty.
       // FIXME: Standard ref?
       data().Empty = false;
+
+      // C++ [class.virtual]p1:
+      //   A class that declares or inherits a virtual function is called a 
+      //   polymorphic class.
+      data().Polymorphic = true;
     }
   }
   
@@ -640,7 +651,6 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) {
 
 void CXXRecordDecl::setMethodAsVirtual(FunctionDecl *Method) {
   Method->setVirtualAsWritten(true);
-  setPolymorphic(true);
   setHasTrivialConstructor(false);
   setHasTrivialCopyConstructor(false);
   setHasTrivialCopyAssignment(false);
index c9a19dd6258acf1abb74d406eccac341e27bbb0b..ebf467fe7aa3671a582517321002898ca9f7d361 100644 (file)
@@ -516,12 +516,6 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
 void Sema::SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
                                           const CXXRecordDecl *BaseClass,
                                           bool BaseIsVirtual) {
-  // C++ [class.virtual]p1:
-  //   A class that [...] inherits a virtual function is called a polymorphic
-  //   class.
-  if (BaseClass->isPolymorphic())
-    Class->setPolymorphic(true);
-
   if (BaseIsVirtual) {
     // C++ [class.ctor]p5:
     //   A constructor is trivial if its class has no virtual base classes.