[cfe-commits] r103792 - in /cfe/trunk/lib/CodeGen: CGExprConstant.cpp CodeGenTypes.cpp CodeGenTypes.h
Anders Carlsson
andersca at mac.com
Fri May 14 12:41:56 PDT 2010
Author: andersca
Date: Fri May 14 14:41:56 2010
New Revision: 103792
URL: http://llvm.org/viewvc/llvm-project?rev=103792&view=rev
Log:
Move ContainsPointerToDataMember to CodeGenTypes. No functionality change.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=103792&r1=103791&r2=103792&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri May 14 14:41:56 2010
@@ -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)) {
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=103792&r1=103791&r2=103792&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri May 14 14:41:56 2010
@@ -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;
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=103792&r1=103791&r2=103792&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Fri May 14 14:41:56 2010
@@ -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
More information about the cfe-commits
mailing list