summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-15 18:06:43 +0000
committerChris Lattner <sabre@nondot.org>2010-06-15 18:06:43 +0000
commitc548be9ab3c6101d05c0411b608f04d5c60ca339 (patch)
tree404980c3081c987c1e56c9c09ea9f62fd19adeff /clang/lib/Lex
parenta8687ae490f3c1b27475785eed9fb64984fe2b7c (diff)
downloadbcm5719-llvm-c548be9ab3c6101d05c0411b608f04d5c60ca339.tar.gz
bcm5719-llvm-c548be9ab3c6101d05c0411b608f04d5c60ca339.zip
Remove a dead argument to ProcessUCNEscape.
Fix string concatenation to treat escapes in concatenated strings that are wide because of other string chunks to process the escapes as wide themselves. Before we would warn about and miscompile the attached testcase. This fixes rdar://8040728 - miscompile + warning: hex escape sequence out of range llvm-svn: 106012
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/LiteralSupport.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index ff4d28f1288..b8fd3ce9e9f 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -169,9 +169,8 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
/// we will likely rework our support for UCN's.
static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
char *&ResultBuf, bool &HadError,
- SourceLocation Loc, bool IsWide, Preprocessor &PP,
- bool Complain)
-{
+ SourceLocation Loc, Preprocessor &PP,
+ bool Complain) {
// FIXME: Add a warning - UCN's are only valid in C++ & C99.
// FIXME: Handle wide strings.
@@ -835,11 +834,8 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
// TODO: Input character set mapping support.
// Skip L marker for wide strings.
- bool ThisIsWide = false;
- if (ThisTokBuf[0] == 'L') {
+ if (ThisTokBuf[0] == 'L')
++ThisTokBuf;
- ThisIsWide = true;
- }
assert(ThisTokBuf[0] == '"' && "Expected quote, lexer broken?");
++ThisTokBuf;
@@ -884,14 +880,13 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
// Is this a Universal Character Name escape?
if (ThisTokBuf[1] == 'u' || ThisTokBuf[1] == 'U') {
ProcessUCNEscape(ThisTokBuf, ThisTokEnd, ResultPtr,
- hadError, StringToks[i].getLocation(), ThisIsWide, PP,
- Complain);
+ hadError, StringToks[i].getLocation(), PP, Complain);
continue;
}
// Otherwise, this is a non-UCN escape character. Process it.
unsigned ResultChar = ProcessCharEscape(ThisTokBuf, ThisTokEnd, hadError,
StringToks[i].getLocation(),
- ThisIsWide, PP, Complain);
+ AnyWide, PP, Complain);
// Note: our internal rep of wide char tokens is always little-endian.
*ResultPtr++ = ResultChar & 0xFF;
OpenPOWER on IntegriCloud