]> granicus.if.org Git - clang/commitdiff
Move helper onto CXXMethodDecl.
authorEli Friedman <eli.friedman@gmail.com>
Sun, 6 Dec 2009 20:50:05 +0000 (20:50 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 6 Dec 2009 20:50:05 +0000 (20:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90716 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/AST/RecordLayoutBuilder.cpp

index 340096c9dc3c3e75c68e684b54a6e29705e2448c..083284c9083a63003e554c7cb4ef87edc82c8376 100644 (file)
@@ -870,6 +870,8 @@ public:
     return getType()->getAs<FunctionProtoType>()->getTypeQuals();
   }
 
+  bool hasInlineBody() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) {
     return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion;
index 5064ec5c7377f07442900e7de2ab68cb136274ef..766cb0181454cb7b9a850d1027e27c1a77fa8019 100644 (file)
@@ -644,6 +644,25 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   return C.getPointerType(ClassTy);
 }
 
+static bool MethodHasBody(const CXXMethodDecl *MD, const FunctionDecl *&fn) {
+  // Simple case: function has a body
+  if (MD->getBody(fn))
+    return true;
+
+  // Complex case: function is an instantiation of a function which has a
+  // body, but the definition hasn't been instantiated.
+  const FunctionDecl *PatternDecl = MD->getTemplateInstantiationPattern();
+  if (PatternDecl && PatternDecl->getBody(fn))
+    return true;
+
+  return false;
+}
+
+bool CXXMethodDecl::hasInlineBody() const {
+  const FunctionDecl *fn;
+  return MethodHasBody(this, fn) && !fn->isOutOfLine();
+}
+
 CXXBaseOrMemberInitializer::
 CXXBaseOrMemberInitializer(ASTContext &Context,
                            DeclaratorInfo *DInfo, CXXConstructorDecl *C,
index 4c7b9119348edd13f2d8809179c80c237ae22185..088673916f8191bb75026ae51d253a4e5afc3b72 100644 (file)
@@ -663,20 +663,6 @@ void ASTRecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) {
   Alignment = NewAlignment;
 }
 
-static bool MethodHasBody(const CXXMethodDecl *MD, const FunctionDecl *&fn) {
-  // Simple case: function has a body
-  if (MD->getBody(fn))
-    return true;
-
-  // Complex case: function is an instantiation of a function which has a
-  // body, but the definition hasn't been instantiated.
-  const FunctionDecl *PatternDecl = MD->getTemplateInstantiationPattern();
-  if (PatternDecl && PatternDecl->getBody(fn))
-    return true;
-
-  return false;
-}
-
 static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) {
   if (!RD->isDynamicClass())
     return 0;
@@ -695,9 +681,8 @@ static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) {
     // they don't have a body until they're defined.
     if (MD->isImplicit())
       continue;
-    
-    const FunctionDecl *fn;
-    if (MethodHasBody(MD, fn) && !fn->isOutOfLine())
+
+    if (MD->hasInlineBody())
       continue;
     
     // We found it.