diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-09-10 21:52:00 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-09-10 21:52:00 +0000 |
| commit | 9df56372e8eaaefc50a9ecae66a83e608d7a5eb6 (patch) | |
| tree | fa4001b27f49f5c8fa09e3a0e39bf4d30753f4ad /clang/lib/CodeGen | |
| parent | e0b44040aaa48a6f0b84ea18beffc7de33078731 (diff) | |
| download | bcm5719-llvm-9df56372e8eaaefc50a9ecae66a83e608d7a5eb6.tar.gz bcm5719-llvm-9df56372e8eaaefc50a9ecae66a83e608d7a5eb6.zip | |
[MS ABI] Make member pointers return true for isIncompleteType
The type of a member pointer is incomplete if it has no inheritance
model. This lets us reuse more general logic already embedded in clang.
llvm-svn: 247346
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGCXXABI.h | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 11 |
5 files changed, 5 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index 828c9ecfc6a..93e2db0d121 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -174,10 +174,6 @@ public: return true; } - virtual bool isTypeInfoCalculable(QualType Ty) const { - return !Ty->isIncompleteType(); - } - /// Create a null member pointer of the given type. virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT); diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index d4e0793fcce..e544ec5c408 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1586,7 +1586,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (const auto *RefTy = RetTy->getAs<ReferenceType>()) { QualType PTy = RefTy->getPointeeType(); - if (getCXXABI().isTypeInfoCalculable(PTy) && PTy->isConstantSizeType()) + if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy) .getQuantity()); else if (getContext().getTargetAddressSpace(PTy) == 0) @@ -1698,7 +1698,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (const auto *RefTy = ParamType->getAs<ReferenceType>()) { QualType PTy = RefTy->getPointeeType(); - if (getCXXABI().isTypeInfoCalculable(PTy) && PTy->isConstantSizeType()) + if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy) .getQuantity()); else if (getContext().getTargetAddressSpace(PTy) == 0) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 61993f8d542..83b5e01deef 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1906,9 +1906,8 @@ llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty, llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty, llvm::DIFile *U) { - uint64_t Size = CGM.getCXXABI().isTypeInfoCalculable(QualType(Ty, 0)) - ? CGM.getContext().getTypeSize(Ty) - : 0; + uint64_t Size = + !Ty->isIncompleteType() ? CGM.getContext().getTypeSize(Ty) : 0; llvm::DIType *ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U); if (Ty->isMemberDataPointerType()) return DBuilder.createMemberPointerType( diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 39bd2bc28e1..c948f8fdd9f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -117,7 +117,7 @@ CharUnits CodeGenFunction::getNaturalTypeAlignment(QualType T, if (Source) *Source = AlignmentSource::Type; CharUnits Alignment; - if (!CGM.getCXXABI().isTypeInfoCalculable(T)) { + if (T->isIncompleteType()) { Alignment = CharUnits::One(); // Shouldn't be used, but pessimistic is best. } else { // For C++ class pointees, we don't know whether we're pointing at a diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 5cefc72ed0c..a981dd6e6d2 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -594,17 +594,6 @@ public: return RD->hasAttr<MSInheritanceAttr>(); } - bool isTypeInfoCalculable(QualType Ty) const override { - if (!CGCXXABI::isTypeInfoCalculable(Ty)) - return false; - if (const auto *MPT = Ty->getAs<MemberPointerType>()) { - const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl(); - if (!RD->hasAttr<MSInheritanceAttr>()) - return false; - } - return true; - } - llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT) override; llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT, |

