]> granicus.if.org Git - clang/commitdiff
Comment parsing: handle \deprecated command. It is a block command, but it
authorDmitri Gribenko <gribozavr@gmail.com>
Thu, 13 Sep 2012 20:36:01 +0000 (20:36 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Thu, 13 Sep 2012 20:36:01 +0000 (20:36 +0000)
should be fine to use it without further explanations in the attached
paragraph, so the warning about empty paragraph was turned off for it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163836 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CommentCommandTraits.h
include/clang/AST/CommentCommands.td
lib/AST/CommentSema.cpp
test/Sema/warn-documentation.cpp
utils/TableGen/ClangCommentCommandInfoEmitter.cpp

index 07d9a489e32ad69ae749ada95c19194c744610e4..73ded54a31b8ae3a3f35912191bf0ce88e083618 100644 (file)
@@ -66,6 +66,10 @@ struct CommandInfo {
   /// a template parameter (\\tparam or an alias).
   unsigned IsTParamCommand : 1;
 
+  /// True if we don't want to warn about this command being passed an empty
+  /// paragraph.  Meaningful only for block commands.
+  unsigned IsEmptyParagraphAllowed : 1;
+
   /// \brief True if this command is a verbatim-like block command.
   ///
   /// A verbatim-like block command eats every character (except line starting
index 7238b535b3e00d7db2ccf29221ce4ce09ad001d7..787a0161abfc3651571866593f703081ba1968a6 100644 (file)
@@ -12,6 +12,8 @@ class Command<string name> {
   bit IsParamCommand = 0;
   bit IsTParamCommand = 0;
 
+  bit IsEmptyParagraphAllowed = 0;
+
   bit IsVerbatimBlockCommand = 0;
   bit IsVerbatimBlockEndCommand = 0;
   bit IsVerbatimLineCommand = 0;
@@ -73,6 +75,8 @@ def Tparam : BlockCommand<"tparam"> { let IsTParamCommand = 1; }
 // HeaderDoc
 def Templatefield : BlockCommand<"templatefield"> { let IsTParamCommand = 1; }
 
+def Deprecated : BlockCommand<"deprecated"> { let IsEmptyParagraphAllowed = 1; }
+
 def Author     : BlockCommand<"author">;
 def Authors    : BlockCommand<"authors">;
 def Bug        : BlockCommand<"bug">;
index 477717f735ef4475cecd1c716b0687df95df9342..6d84a2a4b91f82ea054e58e8a16103311e09d437 100644 (file)
@@ -415,6 +415,9 @@ FullComment *Sema::actOnFullComment(
 }
 
 void Sema::checkBlockCommandEmptyParagraph(BlockCommandComment *Command) {
+  if (Traits.getCommandInfo(Command->getCommandID())->IsEmptyParagraphAllowed)
+    return;
+
   ParagraphComment *Paragraph = Command->getParagraph();
   if (Paragraph->isWhitespace()) {
     SourceLocation DiagLoc;
index 28544e0a81b1a867ed5c2654b218d12ba2b96aa6..a18a0a44a4ed85ca8e8acddd110c07429db47b60 100644 (file)
@@ -371,6 +371,19 @@ using test_tparam14 = test_tparam13<T, int>;
 template<typename T>
 using test_tparam15 = test_tparam13<T, int>;
 
+
+/// Aaa
+/// \deprecated Bbb
+void test_deprecated_1(int a);
+
+// We don't want \deprecated to warn about empty paragraph.  It is fine to use
+// \deprecated by itself without explanations.
+
+/// Aaa
+/// \deprecated
+void test_deprecated_2(int a);
+
+
 // no-warning
 /// \returns Aaa
 int test_returns_right_decl_1(int);
index 11b2f51f71b68060e9f6e9a40e09b1c7c9b0a15e..599d1385a8332fdc73b1a753dc393c76f388409e 100644 (file)
@@ -38,6 +38,7 @@ void EmitClangCommentCommandInfo(RecordKeeper &Records, raw_ostream &OS) {
        << Tag.getValueAsBit("IsReturnsCommand") << ", "
        << Tag.getValueAsBit("IsParamCommand") << ", "
        << Tag.getValueAsBit("IsTParamCommand") << ", "
+       << Tag.getValueAsBit("IsEmptyParagraphAllowed") << ", "
        << Tag.getValueAsBit("IsVerbatimBlockCommand") << ", "
        << Tag.getValueAsBit("IsVerbatimBlockEndCommand") << ", "
        << Tag.getValueAsBit("IsVerbatimLineCommand") << ", "