Move ContainsPointerToDataMember to CodeGenTypes. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103792 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 2595ff0..68b31ae 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -984,32 +984,8 @@
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)) {
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index f53dd83..291cd7f 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -467,3 +467,27 @@
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;
+}
diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h
index 10e71e2..a2c222b 100644
--- a/lib/CodeGen/CodeGenTypes.h
+++ b/lib/CodeGen/CodeGenTypes.h
@@ -186,6 +186,10 @@
/// 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