summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-12-23 05:19:47 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-12-23 05:19:47 +0000
commit8df65e4a2a88e0780a6ec8bffeb4f6ae79fdeca6 (patch)
tree1c0b24b90c1ebf42315312bdc4f60859010bb051 /clang/lib/Basic
parent96cdc4930522efa7816ae614647364bbfc7bdd2a (diff)
downloadbcm5719-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.cpp5
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) };
OpenPOWER on IntegriCloud