From 123063377428540752bad91c7fbd536a762e31bd Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 1 Feb 2017 21:35:00 +0000 Subject: Vendor import of clang release_40 branch r293807: https://llvm.org/svn/llvm-project/cfe/branches/release_40@293807 --- lib/AST/ExprConstant.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/AST/ExprConstant.cpp') diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 5fab58a5af95..6a6baf96ad37 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2362,7 +2362,14 @@ static unsigned getBaseIndex(const CXXRecordDecl *Derived, /// Extract the value of a character from a string literal. static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit, uint64_t Index) { - // FIXME: Support ObjCEncodeExpr, MakeStringConstant + // FIXME: Support MakeStringConstant + if (const auto *ObjCEnc = dyn_cast(Lit)) { + std::string Str; + Info.Ctx.getObjCEncodingForType(ObjCEnc->getEncodedType(), Str); + assert(Index <= Str.size() && "Index too large"); + return APSInt::getUnsigned(Str.c_str()[Index]); + } + if (auto PE = dyn_cast(Lit)) Lit = PE->getFunctionName(); const StringLiteral *S = cast(Lit); -- cgit v1.3