summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-06 08:58:57 +0000
committerDaniel Jasper <djasper@google.com>2015-05-06 08:58:57 +0000
commit62c78f547471aaccf639f6ec32bf3e633bc4effd (patch)
treef42c54ca15d52ee643301e25b16e2184d43dfe09 /clang/lib/Format
parent4d9ec17f1e7dd096c3b04222e169ddb00a7f353d (diff)
downloadbcm5719-llvm-62c78f547471aaccf639f6ec32bf3e633bc4effd.tar.gz
bcm5719-llvm-62c78f547471aaccf639f6ec32bf3e633bc4effd.zip
clang-format: Prevent assertion discovered by fuzzer.
llvm-svn: 236578
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 39ac66b27fa..fa12d4dd7ab 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -895,8 +895,16 @@ private:
(!Current.Previous || Current.Previous->isNot(tok::l_square))) {
Current.Type = TT_BinaryOperator;
} else if (Current.is(tok::comment)) {
- Current.Type =
- Current.TokenText.startswith("/*") ? TT_BlockComment : TT_LineComment;
+ if (Current.TokenText.startswith("/*")) {
+ if (Current.TokenText.endswith("*/"))
+ Current.Type = TT_BlockComment;
+ else
+ // The lexer has for some reason determined a comment here. But we
+ // cannot really handle it, if it isn't properly terminated.
+ Current.Tok.setKind(tok::unknown);
+ } else {
+ Current.Type = TT_LineComment;
+ }
} else if (Current.is(tok::r_paren)) {
if (rParenEndsCast(Current))
Current.Type = TT_CastRParen;
OpenPOWER on IntegriCloud