summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2016-02-17 21:09:50 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2016-02-17 21:09:50 +0000
commit9d8ac61fec65b20472a4e6ad9b17472828029971 (patch)
tree0cc13b596e7d67ab3bff1bf140625d177835e3a5 /clang/lib
parent51a8de9f7af7930fb4a865e48ee0875cac7c1404 (diff)
downloadbcm5719-llvm-9d8ac61fec65b20472a4e6ad9b17472828029971.tar.gz
bcm5719-llvm-9d8ac61fec65b20472a4e6ad9b17472828029971.zip
[CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog
The assert is triggered because isObjCRetainableType() is called on the canonicalized return type that has been stripped of the typedefs and attributes attached to it. To fix this assert, this commit gets the original return type from CurCodeDecl or BlockInfo and uses it instead of the canoicalized type. rdar://problem/24470031 Differential Revision: http://reviews.llvm.org/D16914 llvm-svn: 261151
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 61b2fe78db7..281292f764c 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -14,6 +14,7 @@
#include "CGCall.h"
#include "ABIInfo.h"
+#include "CGBlocks.h"
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CodeGenFunction.h"
@@ -2462,9 +2463,26 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
// In ARC, end functions that return a retainable type with a call
// to objc_autoreleaseReturnValue.
if (AutoreleaseResult) {
+#ifndef NDEBUG
+ // Type::isObjCRetainabletype has to be called on a QualType that hasn't
+ // been stripped of the typedefs, so we cannot use RetTy here. Get the
+ // original return type of FunctionDecl, CurCodeDecl, and BlockDecl from
+ // CurCodeDecl or BlockInfo.
+ QualType RT;
+
+ if (auto *FD = dyn_cast<FunctionDecl>(CurCodeDecl))
+ RT = FD->getReturnType();
+ else if (auto *MD = dyn_cast<ObjCMethodDecl>(CurCodeDecl))
+ RT = MD->getReturnType();
+ else if (isa<BlockDecl>(CurCodeDecl))
+ RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
+ else
+ llvm_unreachable("Unexpected function/method type");
+
assert(getLangOpts().ObjCAutoRefCount &&
!FI.isReturnsRetained() &&
- RetTy->isObjCRetainableType());
+ RT->isObjCRetainableType());
+#endif
RV = emitAutoreleaseOfResult(*this, RV);
}
OpenPOWER on IntegriCloud