From 5828a1d8e9e9876a89ddd52b8f5160723cfbdfda Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 23 Apr 2014 17:44:58 +0000 Subject: Objective-C [IRGen]. Fixes a crash in IRGen involving use of 'typeof' to extract type of an @encode expression used in an initializer. // rdar://16655340 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207004 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprConstant.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExprConstant.cpp') diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index bce0475cbc..4e615922fe 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -836,7 +836,10 @@ public: // as an inline array. std::string Str; CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str); - const ConstantArrayType *CAT = cast(E->getType()); + QualType T = E->getType(); + if (T->getTypeClass() == Type::TypeOfExpr) + T = cast(T)->getUnderlyingExpr()->getType(); + const ConstantArrayType *CAT = cast(T); // Resize the string to the right size, adding zeros at the end, or // truncating as needed. -- cgit v1.2.3