diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-10-30 23:22:22 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-10-30 23:22:22 +0000 |
commit | 82c6dc72adc30e785ce5bc6e8b43ae92070d2e08 (patch) | |
tree | e096c14e70f29d9677c92f99111a6dd0b0b72bf5 | |
parent | b3fa55f18d7b3759b3a6547719cf5b3418370a96 (diff) |
Handle string encoding diagnostics when there are too many invalid ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167059 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 4 | ||||
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 3 | ||||
-rw-r--r-- | test/Misc/wrong-encoding.c | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 9990222daa..e47f3e1857 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -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, diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 2896dc3bf7..91edf4f4a0 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -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()); diff --git a/test/Misc/wrong-encoding.c b/test/Misc/wrong-encoding.c index db37af9d2b..1f186b7939 100644 --- a/test/Misc/wrong-encoding.c +++ b/test/Misc/wrong-encoding.c @@ -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 |