aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Wodnicki <pawel@32bitmicro.com>2012-11-27 21:56:38 +0000
committerPawel Wodnicki <pawel@32bitmicro.com>2012-11-27 21:56:38 +0000
commit01b6cc647b14b7ecfde1b162c02de85f42de04c2 (patch)
treefd2886508224d3965f6b634432b4f8763e94ca4d
parent262316ade163fe86c53bb03edc3d7bd683b18f5c (diff)
downloadllvm-01b6cc647b14b7ecfde1b162c02de85f42de04c2.zip
llvm-01b6cc647b14b7ecfde1b162c02de85f42de04c2.tar.gz
llvm-01b6cc647b14b7ecfde1b162c02de85f42de04c2.tar.bz2
Merging r168277: into 3.2 release branch.
Documentation parsing: propely handle a lone '\endverbatim' and emit a warning. We actually used to assert on this. Thanks to NAKAMURA Takumi for noticing this! llvm-svn: 168730
-rw-r--r--clang/include/clang/Basic/DiagnosticCommentKinds.td6
-rw-r--r--clang/lib/AST/CommentParser.cpp8
-rw-r--r--clang/test/Sema/warn-documentation.cpp18
3 files changed, 32 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td b/clang/include/clang/Basic/DiagnosticCommentKinds.td
index 7203ac7..e6dfe5b 100644
--- a/clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -131,5 +131,11 @@ def warn_doc_deprecated_not_sync : Warning<
def note_add_deprecation_attr : Note<
"add a deprecation attribute to the declaration to silence this warning">;
+// verbatim block commands
+
+def warn_verbatim_block_end_without_start : Warning<
+ "'\\%0' command does not terminate a verbatim text block">,
+ InGroup<Documentation>, DefaultIgnore;
+
} // end of documentation issue category
} // end of AST component
diff --git a/clang/lib/AST/CommentParser.cpp b/clang/lib/AST/CommentParser.cpp
index d053dc0..d0a8474 100644
--- a/clang/lib/AST/CommentParser.cpp
+++ b/clang/lib/AST/CommentParser.cpp
@@ -554,6 +554,14 @@ BlockContentComment *Parser::parseParagraphOrBlockCommand() {
return parseBlockCommand();
break; // Block command ahead, finish this parapgaph.
}
+ if (Info->IsVerbatimBlockEndCommand) {
+ Diag(Tok.getLocation(),
+ diag::warn_verbatim_block_end_without_start)
+ << Info->Name
+ << SourceRange(Tok.getLocation(), Tok.getEndLocation());
+ consumeToken();
+ continue;
+ }
if (Info->IsUnknownCommand) {
Content.push_back(S.actOnUnknownCommand(Tok.getLocation(),
Tok.getEndLocation(),
diff --git a/clang/test/Sema/warn-documentation.cpp b/clang/test/Sema/warn-documentation.cpp
index b5d3300..3eca3c8 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -502,6 +502,24 @@ enum test_returns_wrong_decl_8 {
namespace test_returns_wrong_decl_10 { };
+// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
+/// \endverbatim
+int test_verbatim_1();
+
+// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
+/// \endcode
+int test_verbatim_2();
+
+// FIXME: we give a bad diagnostic here because we throw away non-documentation
+// comments early.
+//
+// expected-warning@+2 {{'\endcode' command does not terminate a verbatim text block}}
+/// \code
+// foo
+/// \endcode
+int test_verbatim_3();
+
+
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
int test1; ///< \brief\author Aaa