diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-12-23 05:19:47 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-12-23 05:19:47 +0000 |
commit | 8df65e4a2a88e0780a6ec8bffeb4f6ae79fdeca6 (patch) | |
tree | 1c0b24b90c1ebf42315312bdc4f60859010bb051 /clang/lib/Basic | |
parent | 96cdc4930522efa7816ae614647364bbfc7bdd2a (diff) | |
download | bcm5719-llvm-8df65e4a2a88e0780a6ec8bffeb4f6ae79fdeca6.tar.gz bcm5719-llvm-8df65e4a2a88e0780a6ec8bffeb4f6ae79fdeca6.zip |
Add an assert to catch improperly constructed %diff sequences in
diagnostics and fix one such diagnostic.
Sadly, this assert doesn't catch this bug because we have no tests that
emit this diagnostic! Doh! I'm following up on the commit that
introduces it to get that fixed. Then this assert will help in a more
direct way.
llvm-svn: 290417
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 1f4316af3ff..7529c475d6b 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -742,7 +742,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, // "%diff{compare $ to $|other text}1,2" // treat it as: // "compare %1 to %2" - const char *Pipe = ScanFormat(Argument, Argument + ArgumentLen, '|'); + const char *ArgumentEnd = Argument + ArgumentLen; + const char *Pipe = ScanFormat(Argument, ArgumentEnd, '|'); + assert(ScanFormat(Pipe + 1, ArgumentEnd, '|') == ArgumentEnd && + "Found too many '|'s in a %diff modifier!"); const char *FirstDollar = ScanFormat(Argument, Pipe, '$'); const char *SecondDollar = ScanFormat(FirstDollar + 1, Pipe, '$'); const char ArgStr1[] = { '%', static_cast<char>('0' + ArgNo) }; |