]> granicus.if.org Git - clang/commitdiff
A new helper function to set various bits in the class when
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Dec 2009 18:44:40 +0000 (18:44 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Dec 2009 18:44:40 +0000 (18:44 +0000)
a new virtual function is declared/instantiated. it is used
in couple of places.

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

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp

index 81f85e81a00ae675f22a54512f6d4cc840360027..340096c9dc3c3e75c68e684b54a6e29705e2448c 100644 (file)
@@ -533,6 +533,10 @@ public:
   /// [dcl.init.aggr]).
   void setAggregate(bool Agg) { Aggregate = Agg; }
 
+  /// setMethodAsVirtual - Make input method virtual and set the necesssary 
+  /// special function bits and other bits accordingly.
+  void setMethodAsVirtual(FunctionDecl *Method);
+
   /// isPOD - Whether this class is a POD-type (C++ [class]p4), which is a class
   /// that is an aggregate that has no non-static non-POD data members, no
   /// reference data members, no user-defined copy assignment operator and no
index 89ea097a33c112b707dc5525e0a456f13230b047..979723a19547c25044095a4311696708fc2bdb35 100644 (file)
@@ -439,6 +439,18 @@ void CXXRecordDecl::addConversionFunction(FunctionTemplateDecl *ConvDecl) {
   Conversions.addDecl(ConvDecl);
 }
 
+
+void CXXRecordDecl::setMethodAsVirtual(FunctionDecl *Method) {
+  Method->setVirtualAsWritten(true);
+  setAggregate(false);
+  setPOD(false);
+  setEmpty(false);
+  setPolymorphic(true);
+  setHasTrivialConstructor(false);
+  setHasTrivialCopyConstructor(false);
+  setHasTrivialCopyAssignment(false);
+}
+
 CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const {
   if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo())
     return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
index ea5e47a9a3413c1d0773c4dd56b3c1c24bf0f82a..e02849f5d59b9576ac1a36e031dc37c61db51e5d 100644 (file)
@@ -2822,15 +2822,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
                              SourceRange(D.getDeclSpec().getVirtualSpecLoc()));
     } else {
       // Okay: Add virtual to the method.
-      cast<CXXMethodDecl>(NewFD)->setVirtualAsWritten(true);
       CXXRecordDecl *CurClass = cast<CXXRecordDecl>(DC);
-      CurClass->setAggregate(false);
-      CurClass->setPOD(false);
-      CurClass->setEmpty(false);
-      CurClass->setPolymorphic(true);
-      CurClass->setHasTrivialConstructor(false);
-      CurClass->setHasTrivialCopyConstructor(false);
-      CurClass->setHasTrivialCopyAssignment(false);
+      CurClass->setMethodAsVirtual(NewFD);
     }
   }
 
index 394f0eee72afa11305107b93047cbb07d83a805b..ec28f474179939dc00200c0f6f1de8a1a9af051e 100644 (file)
@@ -1359,13 +1359,8 @@ TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New,
 
   CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
   New->setAccess(Tmpl->getAccess());
-  if (Tmpl->isVirtualAsWritten()) {
-    New->setVirtualAsWritten(true);
-    Record->setAggregate(false);
-    Record->setPOD(false);
-    Record->setEmpty(false);
-    Record->setPolymorphic(true);
-  }
+  if (Tmpl->isVirtualAsWritten())
+    Record->setMethodAsVirtual(New);
 
   // FIXME: attributes
   // FIXME: New needs a pointer to Tmpl