Author: krasimir Date: Thu May 18 10:16:24 2017 New Revision: 303353 URL: http://llvm.org/viewvc/llvm-project?rev=303353&view=rev Log: [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 Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=303353&r1=303352&r2=303353&view=diff ============================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu May 18 10:16:24 2017 @@ -429,8 +429,9 @@ void UnwrappedLineParser::parseBlock(boo 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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits