<br><br>On Tuesday, March 5, 2013, Fariborz Jahanian  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: fjahanian<br>
Date: Mon Mar  4 19:05:07 2013<br>
New Revision: 176468<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=176468&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=176468&view=rev</a><br>
Log:<br>
doc parsing. We want to issue a strong warning when<br>
an @function comment is not followed by a function decl.<br>
// rdar://13094352<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/CommentCommandTraits.h<br>
    cfe/trunk/include/clang/AST/CommentCommands.td<br>
    cfe/trunk/include/clang/AST/CommentSema.h<br>
    cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td<br>
    cfe/trunk/lib/AST/CommentParser.cpp<br>
    cfe/trunk/lib/AST/CommentSema.cpp<br>
    cfe/trunk/test/Sema/warn-documentation.cpp<br>
    cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/CommentCommandTraits.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentCommandTraits.h?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentCommandTraits.h?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/CommentCommandTraits.h (original)<br>
+++ cfe/trunk/include/clang/AST/CommentCommandTraits.h Mon Mar  4 19:05:07 2013<br>
@@ -100,7 +100,10 @@ struct CommandInfo {<br>
   ///   \fn void f(int a);<br>
   /// \endcode<br>
   unsigned IsDeclarationCommand : 1;<br>
-<br>
+<br>
+  /// \brief True if verbatim-like line command is a function declaraton.<br>
+  unsigned IsFunctionDeclarationCommand : 1;<br>
+<br>
   /// \brief True if this command is unknown.  This \c CommandInfo object was<br>
   /// created during parsing.<br>
   unsigned IsUnknownCommand : 1;<br>
<br>
Modified: cfe/trunk/include/clang/AST/CommentCommands.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentCommands.td?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentCommands.td?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/CommentCommands.td (original)<br>
+++ cfe/trunk/include/clang/AST/CommentCommands.td Mon Mar  4 19:05:07 2013<br>
@@ -24,6 +24,7 @@ class Command<string name> {<br>
   bit IsVerbatimBlockEndCommand = 0;<br>
   bit IsVerbatimLineCommand = 0;<br>
   bit IsDeclarationCommand = 0;<br>
+  bit IsFunctionDeclarationCommand = 0;<br>
 }<br>
<br>
 class InlineCommand<string name> : Command<name> {<br>
@@ -59,6 +60,12 @@ class DeclarationVerbatimLineCommand<str<br>
   let IsDeclarationCommand = 1;<br>
 }<br>
<br>
+class FunctionDeclarationVerbatimLineCommand<string name> :<br>
+      VerbatimLineCommand<name> {<br>
+  let IsDeclarationCommand = 1;<br>
+  let IsFunctionDeclarationCommand = 1;<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 // InlineCommand<br>
 //===----------------------------------------------------------------------===//<br>
@@ -179,7 +186,7 @@ def Interface : DeclarationVerbatimLineC<br>
 def Protocol  : DeclarationVerbatimLineCommand<"protocol">;<br>
 def Category  : DeclarationVerbatimLineCommand<"category">;<br>
 def Template  : DeclarationVerbatimLineCommand<"template">;<br>
-def Function  : DeclarationVerbatimLineCommand<"function">;<br>
+def Function  : FunctionDeclarationVerbatimLineCommand<"function">;<br>
 def Method    : DeclarationVerbatimLineCommand<"method">;<br>
 def Callback  : DeclarationVerbatimLineCommand<"callback">;<br>
 def Const     : DeclarationVerbatimLineCommand<"const">;<br>
<br>
Modified: cfe/trunk/include/clang/AST/CommentSema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/CommentSema.h (original)<br>
+++ cfe/trunk/include/clang/AST/CommentSema.h Mon Mar  4 19:05:07 2013<br>
@@ -198,6 +198,8 @@ public:<br>
   void checkBlockCommandDuplicate(const BlockCommandComment *Command);<br>
<br>
   void checkDeprecatedCommand(const BlockCommandComment *Comment);<br>
+<br>
+  void checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment);<br>
<br>
   /// Resolve parameter names to parameter indexes in function declaration.<br>
   /// Emit diagnostics about unknown parametrs.<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Mon Mar  4 19:05:07 2013<br>
@@ -73,6 +73,11 @@ def warn_doc_param_not_attached_to_a_fun<br>
   "a function declaration">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
+def warn_doc_function_not_attached_to_a_function_decl : Warning<<br>
+  "'@function' command used in a comment that is attached to "</blockquote><div><br></div><div>This diagnostic has an issue of backslash versus at, similar to what you were fixing recently.</div><div><br>
</div><div>Dmitri<span></span></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  "a non-function declaration immediately following it">,<br>
+  InGroup<Documentation>, DefaultIgnore;<br>
+<br>
 def warn_doc_param_duplicate : Warning<<br>
   "parameter '%0' is already documented">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
Modified: cfe/trunk/lib/AST/CommentParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/CommentParser.cpp (original)<br>
+++ cfe/trunk/lib/AST/CommentParser.cpp Mon Mar  4 19:05:07 2013<br>
@@ -706,6 +706,8 @@ VerbatimLineComment *Parser::parseVerbat<br>
                                                 TextBegin,<br>
                                                 Text);<br>
   consumeToken();<br>
+  S.checkFunctionDeclVerbatimLine(VL);<br>
+<br>
   return VL;<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/lib/AST/CommentSema.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/CommentSema.cpp (original)<br>
+++ cfe/trunk/lib/AST/CommentSema.cpp Mon Mar  4 19:05:07 2013<br>
@@ -88,6 +88,15 @@ ParamCommandComment *Sema::actOnParamCom<br>
   return Command;<br>
 }<br>
<br>
+void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {<br>
+  const CommandInfo *Info = Traits.getCommandInfo(Comment->getCommandID());<br>
+  if (Info->IsFunctionDeclarationCommand &&<br>
+      !isFunctionDecl())<br>
+    Diag(Comment->getLocation(),<br>
+         diag::warn_doc_function_not_attached_to_a_function_decl)<br>
+    << Comment->getSourceRange();<br>
+}<br>
+<br>
 void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,<br>
                                          SourceLocation ArgLocBegin,<br>
                                          SourceLocation ArgLocEnd,<br>
<br>
Modified: cfe/trunk/test/Sema/warn-documentation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)<br>
+++ cfe/trunk/test/Sema/warn-documentation.cpp Mon Mar  4 19:05:07 2013<br>
@@ -911,3 +911,12 @@ int test_nocrash12();<br>
 ///@param x@param y<br>
 int test_nocrash13(int x, int y);<br>
<br>
+// expected-warning@+3 {{'@function' command used in a comment that is attached to a non-function declaration immediately following it}}<br>
+// expected-warning@+3 {{'@param' command used in a comment that is not attached to a function declaration}}<br>
+// expected-warning@+3 {{'@result' command used in a comment that is not attached to a function or method declaration}}<br>
+/*!    @function Base64EncodeEx<br>
+       @param  inFlags  This is error flag<br>
+       @result Error<br>
+*/<br>
+typedef unsigned int Base64Flags;<br>
+unsigned Base64EncodeEx(Base64Flags    inFlags);<br>
<br>
Modified: cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp?rev=176468&r1=176467&r2=176468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp?rev=176468&r1=176467&r2=176468&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp (original)<br>
+++ cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp Mon Mar  4 19:05:07 2013<br>
@@ -47,6 +47,7 @@ void EmitClangCommentCommandInfo(RecordK<br>
        << Tag.getValueAsBit("IsVerbatimBlockEndCommand") << ", "<br>
        << Tag.getValueAsBit("IsVerbatimLineCommand") << ", "<br>
        << Tag.getValueAsBit("IsDeclarationCommand") << ", "<br>
+       << Tag.getValueAsBit("IsFunctionDeclarationCommand") << ", "<br>
        << /* IsUnknownCommand = */ "0"<br>
        << " }";<br>
     if (i + 1 != e)<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'cfe-commits@cs.uiuc.edu')">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote><br><br>-- <br>main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/<br>