diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-25 12:26:20 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-25 12:26:20 +0000 |
commit | 225d9cf75f9f7af8186e602ba856a9475401619b (patch) | |
tree | fac4a6a236d4f8bd15c8421cdd213a35552e1bb0 /lib/Sema/SemaExprObjC.cpp | |
parent | 927053b1049b46512d7f7ef0cfc90d11858a55ef (diff) | |
download | clang-225d9cf75f9f7af8186e602ba856a9475401619b.tar.gz clang-225d9cf75f9f7af8186e602ba856a9475401619b.tar.bz2 clang-225d9cf75f9f7af8186e602ba856a9475401619b.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 54aa6a610e..3a7e83c5ac 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/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); |