diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-12 23:55:49 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-12 23:55:49 +0000 |
| commit | 4d1288a67e06d786cb86058280a4f2d9f024bc45 (patch) | |
| tree | 6d5e4eafd8ef16b8898379838aa6b289f2e8d1ec /clang/Sema/SemaExpr.cpp | |
| parent | b8bd2db8b37028bb6a53cb17fc20e31827ebbaba (diff) | |
| download | bcm5719-llvm-4d1288a67e06d786cb86058280a4f2d9f024bc45.tar.gz bcm5719-llvm-4d1288a67e06d786cb86058280a4f2d9f024bc45.zip | |
Concatenation of objc strings.
llvm-svn: 44964
Diffstat (limited to 'clang/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/Sema/SemaExpr.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 98ede439f68..c6260344f1b 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/Sema/SemaExpr.cpp @@ -2049,11 +2049,30 @@ Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, ExprTy **Strings, unsigned NumStrings) { - - // FIXME: This is passed in an ARRAY of strings which need to be concatenated. - // Handle this case here. For now we just ignore all but the first one. SourceLocation AtLoc = AtLocs[0]; StringLiteral* S = static_cast<StringLiteral *>(Strings[0]); + if (NumStrings > 1) { + // Concatenate objc strings. + StringLiteral* ES = static_cast<StringLiteral *>(Strings[NumStrings-1]); + SourceLocation EndLoc = ES->getSourceRange().getEnd(); + unsigned Length = 0; + for (unsigned i = 0; i < NumStrings; i++) + Length += static_cast<StringLiteral *>(Strings[i])->getByteLength(); + char *strBuf = new char [Length]; + char *p = strBuf; + bool isWide = false; + for (unsigned i = 0; i < NumStrings; i++) { + S = static_cast<StringLiteral *>(Strings[i]); + if (S->isWide()) + isWide = true; + memcpy(p, S->getStrData(), S->getByteLength()); + p += S->getByteLength(); + delete S; + } + S = new StringLiteral(strBuf, Length, + isWide, Context.getPointerType(Context.CharTy), + AtLoc, EndLoc); + } if (CheckBuiltinCFStringArgument(S)) return true; |

