aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/LiteralSupport.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-16 18:51:42 +0000
committerChris Lattner <sabre@nondot.org>2009-01-16 18:51:42 +0000
commitbbee00b6456e90a09f63c83c20233e6c5ad6000a (patch)
tree679de00fd95293991c271a0022eeabd5bdf3311c /lib/Lex/LiteralSupport.cpp
parent99890659385f052412d479e8569b10069ac2b12b (diff)
minor cleanups to StringLiteralParser: no need to pass target info
into its ctor. Also, make it handle validity checking of pascal strings instead of making clients do it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
-rw-r--r--lib/Lex/LiteralSupport.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index fbd2c326ea..76c90e4ed0 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -647,8 +647,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
///
StringLiteralParser::
StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
- Preprocessor &pp, TargetInfo &t)
- : PP(pp), Target(t) {
+ Preprocessor &pp) : PP(pp) {
// Scan all of the string portions, remember the max individual token length,
// computing a bound on the concatenated string length, and see whether any
// piece is a wide-string. If any of the string portions is a wide-string
@@ -684,7 +683,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
wchar_tByteWidth = ~0U;
if (AnyWide) {
- wchar_tByteWidth = Target.getWCharWidth();
+ wchar_tByteWidth = PP.getTargetInfo().getWCharWidth();
assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!");
wchar_tByteWidth /= 8;
}
@@ -787,6 +786,15 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
*ResultPtr++ = 0;
}
- if (Pascal)
+ if (Pascal) {
ResultBuf[0] = ResultPtr-&ResultBuf[0]-1;
+
+ // Verify that pascal strings aren't too large.
+ if (GetStringLength() > 256)
+ PP.Diag(StringToks[0].getLocation(), diag::err_pascal_string_too_long)
+ << SourceRange(StringToks[0].getLocation(),
+ StringToks[NumStringToks-1].getLocation());
+ hadError = 1;
+ return;
+ }
}