summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-02-25 12:26:20 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-02-25 12:26:20 +0000
commitcdac761475699c097731d4bc045eade6c5f8b536 (patch)
treea8e198c82235ef08560314c66295a692981663f1 /clang/lib/Sema/SemaExprObjC.cpp
parentfc188424376671277266f2c4fb5e37498b512bfb (diff)
downloadbcm5719-llvm-cdac761475699c097731d4bc045eade6c5f8b536.tar.gz
bcm5719-llvm-cdac761475699c097731d4bc045eade6c5f8b536.zip
Sema: When merging objc string literals, give the result a constant array type.
Also assert that we never create non-array string literals again. PR18939. llvm-svn: 202147
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 54aa6a610e0..3a7e83c5ac1 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -67,10 +67,14 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
// Create the aggregate string with the appropriate content and location
// information.
- S = StringLiteral::Create(Context, StrBuf,
- StringLiteral::Ascii, /*Pascal=*/false,
- Context.getPointerType(Context.CharTy),
- &StrLocs[0], StrLocs.size());
+ const ConstantArrayType *CAT = Context.getAsConstantArrayType(S->getType());
+ assert(CAT && "String literal not of constant array type!");
+ QualType StrTy = Context.getConstantArrayType(
+ CAT->getElementType(), llvm::APInt(32, StrBuf.size() + 1),
+ CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
+ S = StringLiteral::Create(Context, StrBuf, StringLiteral::Ascii,
+ /*Pascal=*/false, StrTy, &StrLocs[0],
+ StrLocs.size());
}
return BuildObjCStringLiteral(AtLocs[0], S);
OpenPOWER on IntegriCloud