This revision was automatically updated to reflect the committed changes.
Closed by commit rL367809: Adds a warning when an inline Doxygen comment has no 
argument (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64696?vs=211340&id=213287#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64696/new/

https://reviews.llvm.org/D64696

Files:
  cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
  cfe/trunk/lib/AST/CommentParser.cpp
  cfe/trunk/test/Sema/warn-documentation.cpp


Index: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
@@ -153,6 +153,12 @@
 def note_add_deprecation_attr : Note<
   "add a deprecation attribute to the declaration to silence this warning">;
 
+// inline contents commands
+
+def warn_doc_inline_contents_no_argument : Warning<
+  "'%select{\\|@}0%1' command does not have an argument">,
+  InGroup<Documentation>, DefaultIgnore;
+
 // verbatim block commands
 
 def warn_verbatim_block_end_without_start : Warning<
Index: cfe/trunk/test/Sema/warn-documentation.cpp
===================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp
+++ cfe/trunk/test/Sema/warn-documentation.cpp
@@ -1044,6 +1044,48 @@
 template <typename B>
 void test_attach38<int>::test_attach39(int, B);
 
+// The inline comments expect a string after the command.
+// expected-warning@+1 {{'\a' command does not have an argument}}
+/// \a
+int test_inline_no_argument_a_bad(int);
+
+/// \a A
+int test_inline_no_argument_a_good(int);
+
+// expected-warning@+1 {{'@b' command does not have an argument}}
+/// @b
+int test_inline_no_argument_b_bad(int);
+
+/// @b A
+int test_inline_no_argument_b_good(int);
+
+// expected-warning@+1 {{'\c' command does not have an argument}}
+/// \c
+int test_inline_no_argument_c_bad(int);
+
+/// \c A
+int test_inline_no_argument_c_good(int);
+
+// expected-warning@+1 {{'\e' command does not have an argument}}
+/// \e
+int test_inline_no_argument_e_bad(int);
+
+/// \e A
+int test_inline_no_argument_e_good(int);
+
+// expected-warning@+1 {{'\em' command does not have an argument}}
+/// \em
+int test_inline_no_argument_em_bad(int);
+
+/// \em A
+int test_inline_no_argument_em_good(int);
+
+// expected-warning@+1 {{'\p' command does not have an argument}}
+/// \p
+int test_inline_no_argument_p_bad(int);
+
+/// \p A
+int test_inline_no_argument_p_good(int);
 
 // PR13411, reduced.  We used to crash on this.
 /**
Index: cfe/trunk/lib/AST/CommentParser.cpp
===================================================================
--- cfe/trunk/lib/AST/CommentParser.cpp
+++ cfe/trunk/lib/AST/CommentParser.cpp
@@ -422,6 +422,12 @@
     IC = S.actOnInlineCommand(CommandTok.getLocation(),
                               CommandTok.getEndLocation(),
                               CommandTok.getCommandID());
+
+    Diag(CommandTok.getEndLocation().getLocWithOffset(1),
+         diag::warn_doc_inline_contents_no_argument)
+        << CommandTok.is(tok::at_command)
+        << Traits.getCommandInfo(CommandTok.getCommandID())->Name
+        << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
 
   Retokenizer.putBackLeftoverTokens();


Index: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
@@ -153,6 +153,12 @@
 def note_add_deprecation_attr : Note<
   "add a deprecation attribute to the declaration to silence this warning">;
 
+// inline contents commands
+
+def warn_doc_inline_contents_no_argument : Warning<
+  "'%select{\\|@}0%1' command does not have an argument">,
+  InGroup<Documentation>, DefaultIgnore;
+
 // verbatim block commands
 
 def warn_verbatim_block_end_without_start : Warning<
Index: cfe/trunk/test/Sema/warn-documentation.cpp
===================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp
+++ cfe/trunk/test/Sema/warn-documentation.cpp
@@ -1044,6 +1044,48 @@
 template <typename B>
 void test_attach38<int>::test_attach39(int, B);
 
+// The inline comments expect a string after the command.
+// expected-warning@+1 {{'\a' command does not have an argument}}
+/// \a
+int test_inline_no_argument_a_bad(int);
+
+/// \a A
+int test_inline_no_argument_a_good(int);
+
+// expected-warning@+1 {{'@b' command does not have an argument}}
+/// @b
+int test_inline_no_argument_b_bad(int);
+
+/// @b A
+int test_inline_no_argument_b_good(int);
+
+// expected-warning@+1 {{'\c' command does not have an argument}}
+/// \c
+int test_inline_no_argument_c_bad(int);
+
+/// \c A
+int test_inline_no_argument_c_good(int);
+
+// expected-warning@+1 {{'\e' command does not have an argument}}
+/// \e
+int test_inline_no_argument_e_bad(int);
+
+/// \e A
+int test_inline_no_argument_e_good(int);
+
+// expected-warning@+1 {{'\em' command does not have an argument}}
+/// \em
+int test_inline_no_argument_em_bad(int);
+
+/// \em A
+int test_inline_no_argument_em_good(int);
+
+// expected-warning@+1 {{'\p' command does not have an argument}}
+/// \p
+int test_inline_no_argument_p_bad(int);
+
+/// \p A
+int test_inline_no_argument_p_good(int);
 
 // PR13411, reduced.  We used to crash on this.
 /**
Index: cfe/trunk/lib/AST/CommentParser.cpp
===================================================================
--- cfe/trunk/lib/AST/CommentParser.cpp
+++ cfe/trunk/lib/AST/CommentParser.cpp
@@ -422,6 +422,12 @@
     IC = S.actOnInlineCommand(CommandTok.getLocation(),
                               CommandTok.getEndLocation(),
                               CommandTok.getCommandID());
+
+    Diag(CommandTok.getEndLocation().getLocWithOffset(1),
+         diag::warn_doc_inline_contents_no_argument)
+        << CommandTok.is(tok::at_command)
+        << Traits.getCommandInfo(CommandTok.getCommandID())->Name
+        << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
 
   Retokenizer.putBackLeftoverTokens();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to