summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-05-18 15:16:24 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-05-18 15:16:24 +0000
commit9f5608a862901d5f882caf6aa23832086593299b (patch)
tree3bcb38ae375ccbd2c31d71b07d4754d9391d0ef5 /clang/lib/Format/UnwrappedLineParser.cpp
parent8a7508970a57297bf6ae398c1abaae38535ebe8e (diff)
downloadbcm5719-llvm-9f5608a862901d5f882caf6aa23832086593299b.tar.gz
bcm5719-llvm-9f5608a862901d5f882caf6aa23832086593299b.zip
[clang-format] Fix MatchingOpeningBlockLineIndex computation
Summary: Computed line index must be relative to the current 'parent' node, and thus use CurrentLines instead of Lines. Without this, a child line's MatchingOpeningBlockLineIndex is out of range of the parent's list of line, which can cause crash or unexpected behavior if this field is used in childs. Contributed by @Typz! Reviewers: krasimir, djasper Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32524 llvm-svn: 303353
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 31c66ffb00a..e2762cd42c4 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -429,8 +429,9 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
parseParens();
addUnwrappedLine();
- size_t OpeningLineIndex =
- Lines.empty() ? (UnwrappedLine::kInvalidIndex) : (Lines.size() - 1);
+ size_t OpeningLineIndex = CurrentLines->empty()
+ ? (UnwrappedLine::kInvalidIndex)
+ : (CurrentLines->size() - 1);
ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
MustBeDeclaration);
OpenPOWER on IntegriCloud