From e5deb79d0e7f1c81fdc9ae89ed5a4edc9a589581 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Mon, 30 Jul 2012 18:05:28 +0000 Subject: Comment parser: don't crash on a completely empty \param followed by a block command git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160975 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/CommentParser.cpp | 4 ++-- test/Sema/warn-documentation.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp index 607ace3546..6d535673f8 100644 --- a/lib/AST/CommentParser.cpp +++ b/lib/AST/CommentParser.cpp @@ -318,9 +318,9 @@ BlockCommandComment *Parser::parseBlockCommand() { if (Tok.is(tok::command) && S.isBlockCommand(Tok.getCommandName())) { // Block command ahead. We can't nest block commands, so pretend that this // command has an empty argument. - ParagraphComment *PC = S.actOnParagraphComment( + ParagraphComment *Paragraph = S.actOnParagraphComment( ArrayRef()); - return S.actOnBlockCommandFinish(BC, PC); + return S.actOnBlockCommandFinish(IsParam ? PC : BC, Paragraph); } if (IsParam || NumArgs > 0) { diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 5ec3ffcf68..87d8840c7a 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -298,3 +298,9 @@ namespace test_attach24 { */ void test_nocrash1(int); +// We used to crash on this. +// expected-warning@+2 {{empty paragraph passed to '\param' command}} +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \param\brief +void test_nocrash2(int); + -- cgit v1.2.1