From: Dmitri Gribenko Date: Thu, 21 Jun 2012 00:28:14 +0000 (+0000) Subject: RawCommentList::addComment: fix the assertion so it actually checks that new comment... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd1be2c90c6bbc83fe420da51733469a4904831b;p=clang RawCommentList::addComment: fix the assertion so it actually checks that new comment is after the last one (change Comments[0] to Comments.back()), and handle the case of two consecutive comments, e.g. /** *//* */. There is already a testcase for that (but it didn't trigger the assert because the assert itself was wrong). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158882 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/RawCommentList.cpp b/lib/AST/RawCommentList.cpp index 06510294e7..1baa9b87eb 100644 --- a/lib/AST/RawCommentList.cpp +++ b/lib/AST/RawCommentList.cpp @@ -159,8 +159,10 @@ void RawCommentList::addComment(const RawComment &RC) { return; assert((Comments.empty() || + Comments.back().getSourceRange().getEnd() == + RC.getSourceRange().getBegin() || SourceMgr.isBeforeInTranslationUnit( - Comments[0].getSourceRange().getEnd(), + Comments.back().getSourceRange().getEnd(), RC.getSourceRange().getBegin())) && "comments are not coming in source order");