summaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-02-01 21:35:00 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-02-01 21:35:00 +0000
commit123063377428540752bad91c7fbd536a762e31bd (patch)
treef131a156bf0b3912bc02dd7adaf4898c01c8a119 /lib/AST
parentd1b6c770bea9b3da66c6c1eb9a7c483ed7e55c1e (diff)
Notes
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/ExprConstant.cpp9
1 files changed, 8 insertions, 1 deletions
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<ObjCEncodeExpr>(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<PredefinedExpr>(Lit))
Lit = PE->getFunctionName();
const StringLiteral *S = cast<StringLiteral>(Lit);