aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
commit3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f (patch)
tree0bbe07708f7571f8b5291f6d7b96c102b7c99dee /lib/CodeGen/CodeGenTypes.cpp
parenta0482fa4e7fa27b01184f938097f0666b78016dd (diff)
downloadsrc-3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f.tar.gz
src-3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f.zip
Vendor import of clang r114020 (from the release_28 branch):vendor/clang/clang-r114020
Notes
Notes: svn path=/vendor/clang/dist/; revision=212795 svn path=/vendor/clang/clang-r114020/; revision=212796; tag=vendor/clang/clang-r114020
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index d469b906fca1..5ab65c5779b6 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -13,6 +13,7 @@
#include "CodeGenTypes.h"
#include "CGCall.h"
+#include "CGCXXABI.h"
#include "CGRecordLayout.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
@@ -26,9 +27,10 @@ using namespace clang;
using namespace CodeGen;
CodeGenTypes::CodeGenTypes(ASTContext &Ctx, llvm::Module& M,
- const llvm::TargetData &TD, const ABIInfo &Info)
+ const llvm::TargetData &TD, const ABIInfo &Info,
+ CGCXXABI &CXXABI)
: Context(Ctx), Target(Ctx.Target), TheModule(M), TheTargetData(TD),
- TheABIInfo(Info) {
+ TheABIInfo(Info), TheCXXABI(CXXABI) {
}
CodeGenTypes::~CodeGenTypes() {
@@ -400,17 +402,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
}
case Type::MemberPointer: {
- // FIXME: This is ABI dependent. We use the Itanium C++ ABI.
- // http://www.codesourcery.com/public/cxx-abi/abi.html#member-pointers
- // If we ever want to support other ABIs this needs to be abstracted.
-
- QualType ETy = cast<MemberPointerType>(Ty).getPointeeType();
- const llvm::Type *PtrDiffTy =
- ConvertTypeRecursive(Context.getPointerDiffType());
- if (ETy->isFunctionType())
- return llvm::StructType::get(TheModule.getContext(), PtrDiffTy, PtrDiffTy,
- NULL);
- return PtrDiffTy;
+ return getCXXABI().ConvertMemberPointerType(cast<MemberPointerType>(&Ty));
}
}
@@ -491,31 +483,34 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *TD) const {
return *Layout;
}
-bool CodeGenTypes::ContainsPointerToDataMember(QualType T) {
+bool CodeGenTypes::isZeroInitializable(QualType T) {
// No need to check for member pointers when not compiling C++.
if (!Context.getLangOptions().CPlusPlus)
- return false;
+ return true;
T = Context.getBaseElementType(T);
+ // Records are non-zero-initializable if they contain any
+ // non-zero-initializable subobjects.
if (const RecordType *RT = T->getAs<RecordType>()) {
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
-
- return ContainsPointerToDataMember(RD);
+ return isZeroInitializable(RD);
}
-
+
+ // We have to ask the ABI about member pointers.
if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
- return !MPT->getPointeeType()->isFunctionType();
+ return getCXXABI().isZeroInitializable(MPT);
- return false;
+ // Everything else is okay.
+ return true;
}
-bool CodeGenTypes::ContainsPointerToDataMember(const CXXRecordDecl *RD) {
+bool CodeGenTypes::isZeroInitializable(const CXXRecordDecl *RD) {
// 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();
+ return Layout.isZeroInitializable();
}