Handle string encoding diagnostics when there are too many invalid ranges.

llvm-svn: 167059
This commit is contained in:
David Blaikie 2012-10-30 23:22:22 +00:00
parent 2a523d864d
commit a0613170b4
3 changed files with 10 additions and 1 deletions

View File

@ -964,6 +964,10 @@ public:
"Too many arguments to diagnostic!");
DiagObj->DiagFixItHints[NumFixits++] = Hint;
}
bool hasMaxRanges() const {
return NumRanges == DiagnosticsEngine::MaxRanges;
}
};
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,

View File

@ -1425,7 +1425,8 @@ bool StringLiteralParser::CopyStringFragment(const Token &Tok,
const char *NextStart = resync_utf8(ErrorPtr, Fragment.end());
StringRef NextFragment(NextStart, Fragment.end()-NextStart);
while (!ConvertUTF8toWide(CharByteWidth, NextFragment, ResultPtr,
while (!Builder.hasMaxRanges() &&
!ConvertUTF8toWide(CharByteWidth, NextFragment, ResultPtr,
ErrorPtrTmp)) {
const char *ErrorPtr = reinterpret_cast<const char *>(ErrorPtrTmp);
NextStart = resync_utf8(ErrorPtr, Fragment.end());

View File

@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value %s 2>&1 | FileCheck -strict-whitespace %s
// REQUIRES: asserts
void foo() {
@ -30,4 +31,7 @@ void foo() {
"xxé¿xxxxxxxxxxxxxxxxxxxxxé¿xx";
// CHECK: {{^ "xx<E9><BF>xxxxxxxxxxxxxxxxxxxxx<E9><BF>xx";}}
// CHECK: {{^ \^~~~~~~~ ~~~~~~~~}}
"xé¿xé¿xé¿xé¿xé¿xé¿xé¿xé¿xé¿xé¿xé¿xé¿x";
}
// CHECK-NOT:Assertion