From 0b1f76b658ec6966a67164dc8c7c55a8960b1917 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sun, 29 Sep 2013 12:02:57 +0000 Subject: clang-format: Fix assertion on incomplete string literals. Before, this could would lead to an assert: llvm::errs() << " << a; llvm-svn: 191639 --- clang/lib/Format/TokenAnnotator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format') diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 992104fe4c2..6772c894dc0 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1161,7 +1161,11 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.is(tok::lessless)) { if (Left.is(tok::string_literal)) { StringRef Content = Left.TokenText; - Content = Content.drop_back(1).drop_front(1).trim(); + if (Content.startswith("\"")) + Content = Content.drop_front(1); + if (Content.endswith("\"")) + Content = Content.drop_back(1); + Content = Content.trim(); if (Content.size() > 1 && (Content.back() == ':' || Content.back() == '=')) return 25; -- cgit v1.2.3