[cfe-commits] r90716 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/AST/RecordLayoutBuilder.cpp

Eli Friedman eli.friedman at gmail.com
Sun Dec 6 12:50:05 PST 2009


Author: efriedma
Date: Sun Dec  6 14:50:05 2009
New Revision: 90716

URL: http://llvm.org/viewvc/llvm-project?rev=90716&view=rev
Log:
Move helper onto CXXMethodDecl.


Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=90716&r1=90715&r2=90716&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Dec  6 14:50:05 2009
@@ -870,6 +870,8 @@
     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;

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=90716&r1=90715&r2=90716&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sun Dec  6 14:50:05 2009
@@ -644,6 +644,25 @@
   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,

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=90716&r1=90715&r2=90716&view=diff

==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sun Dec  6 14:50:05 2009
@@ -663,20 +663,6 @@
   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 @@
     // 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.





More information about the cfe-commits mailing list