]> granicus.if.org Git - clang/commitdiff
Move ContainsPointerToDataMember to CodeGenTypes. No functionality change.
authorAnders Carlsson <andersca@mac.com>
Fri, 14 May 2010 19:41:56 +0000 (19:41 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 14 May 2010 19:41:56 +0000 (19:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103792 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CodeGenTypes.cpp
lib/CodeGen/CodeGenTypes.h

index 2595ff0060ca5e027444a00c51710b2f23804634..68b31aefa6d836561e74225adec074978f8c8687 100644 (file)
@@ -984,32 +984,8 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
   return C;
 }
 
-static bool containsPointerToDataMember(CodeGenTypes &Types, QualType T) {
-  // No need to check for member pointers when not compiling C++.
-  if (!Types.getContext().getLangOptions().CPlusPlus)
-    return false;
-  
-  T = Types.getContext().getBaseElementType(T);
-  
-  if (const RecordType *RT = T->getAs<RecordType>()) {
-    const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
-    
-    // FIXME: It would be better if there was a way to explicitly compute the
-    // record layout instead of converting to a type.
-    Types.ConvertTagDeclType(RD);
-    
-    const CGRecordLayout &Layout = Types.getCGRecordLayout(RD);
-    return Layout.containsPointerToDataMember();
-  }
-    
-  if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
-    return !MPT->getPointeeType()->isFunctionType();
-  
-  return false;
-}
-
 llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
-  if (!containsPointerToDataMember(getTypes(), T))
+  if (!getTypes().ContainsPointerToDataMember(T))
     return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
     
   if (const ConstantArrayType *CAT = Context.getAsConstantArrayType(T)) {
index f53dd83d7035193912b1c7050cda0ec72e693bab..291cd7fbde76e2e92b7614c4d4738b9ea43e066d 100644 (file)
@@ -467,3 +467,27 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *TD) const {
   assert(Layout && "Unable to find record layout information for type");
   return *Layout;
 }
+
+bool CodeGenTypes::ContainsPointerToDataMember(QualType T) {
+  // No need to check for member pointers when not compiling C++.
+  if (!Context.getLangOptions().CPlusPlus)
+    return false;
+  
+  T = Context.getBaseElementType(T);
+  
+  if (const RecordType *RT = T->getAs<RecordType>()) {
+    const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
+    
+    // FIXME: It would be better if there was a way to explicitly compute the
+    // record layout instead of converting to a type.
+    ConvertTagDeclType(RD);
+    
+    const CGRecordLayout &Layout = getCGRecordLayout(RD);
+    return Layout.containsPointerToDataMember();
+  }
+  
+  if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
+    return !MPT->getPointeeType()->isFunctionType();
+  
+  return false;
+}
index 10e71e2a03fa08944ed15047100fe2f1755214a9..a2c222b9a64061ab18b0bf08ffe4f57d7ff5fe40 100644 (file)
@@ -186,6 +186,10 @@ public:  // These are internal details of CGT that shouldn't be used externally.
   /// argument types it would be passed as on the provided vector \arg
   /// ArgTys. See ABIArgInfo::Expand.
   void GetExpandedTypes(QualType Ty, std::vector<const llvm::Type*> &ArgTys);
+  
+  /// ContainsPointerToDataMember - Return whether the given type contains a
+  /// pointer to a data member.
+  bool ContainsPointerToDataMember(QualType T);
 };
 
 }  // end namespace CodeGen