This is similar to the last patch and supports doxygen's \todo command.
In this patch I place the <Todo> named tag at the very end after the 
<Discussion> tags
(which are for rando comment blocks). Once, placement of this tag is agreed on, 
I will add test cases.

Please review.

- Thanks, Fariborz

        
Index: bindings/xml/comment-xml-schema.rng
===================================================================
--- bindings/xml/comment-xml-schema.rng (revision 174114)
+++ bindings/xml/comment-xml-schema.rng (working copy)
@@ -45,6 +45,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -106,6 +109,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -147,10 +153,12 @@
       <optional>
         <ref name="ResultDiscussion" />
       </optional>
-
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -187,6 +195,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -223,6 +234,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -259,6 +273,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -295,6 +312,9 @@
       <optional>
         <ref name="Discussion" />
       </optional>
+      <optional>
+        <ref name="Todo" />
+      </optional>
     </element>
   </define>
 
@@ -366,6 +386,14 @@
     </element>
   </define>
 
+  <define name="Todo">
+    <element name="Todo">
+      <oneOrMore>
+        <ref name="TextBlockContent" />
+      </oneOrMore>
+    </element>
+  </define>
+
   <define name="TemplateParameters">
     <element name="TemplateParameters">
       <!-- Parameter elements should be sorted according to position. -->
Index: include/clang/AST/CommentCommandTraits.h
===================================================================
--- include/clang/AST/CommentCommandTraits.h    (revision 174114)
+++ include/clang/AST/CommentCommandTraits.h    (working copy)
@@ -71,6 +71,9 @@
 
   /// \brief True if this is a \\headerfile-like command.
   unsigned IsHeaderfileCommand : 1;
+  
+  /// \brief True if this is a \\todo-like command.
+  unsigned IsTodoCommand : 1;
 
   /// True if we don't want to warn about this command being passed an empty
   /// paragraph.  Meaningful only for block commands.
Index: include/clang/AST/CommentCommands.td
===================================================================
--- include/clang/AST/CommentCommands.td        (revision 174114)
+++ include/clang/AST/CommentCommands.td        (working copy)
@@ -17,6 +17,7 @@
   bit IsTParamCommand = 0;
   bit IsDeprecatedCommand = 0;
   bit IsHeaderfileCommand = 0;
+  bit IsTodoCommand = 0;
 
   bit IsEmptyParagraphAllowed = 0;
 
@@ -95,6 +96,7 @@
 }
 
 def Headerfile : BlockCommand<"headerfile"> { let IsHeaderfileCommand = 1; }
+def Todo : BlockCommand<"todo"> { let IsTodoCommand = 1; }
 
 // We don't do any additional semantic analysis for the following
 // BlockCommands.  It might be a good idea to do something extra for them, but
@@ -114,7 +116,6 @@
 def Sa         : BlockCommand<"sa">;
 def See        : BlockCommand<"see">;
 def Since      : BlockCommand<"since">;
-def Todo       : BlockCommand<"todo">;
 def Version    : BlockCommand<"version">;
 def Warning    : BlockCommand<"warning">;
 
Index: include/clang/AST/CommentSema.h
===================================================================
--- include/clang/AST/CommentSema.h     (revision 174114)
+++ include/clang/AST/CommentSema.h     (working copy)
@@ -63,6 +63,9 @@
   
   /// AST node for the \\headerfile command.
   const BlockCommandComment *HeaderfileCommand;
+  
+  /// AST node for the \\todo command.
+  const BlockCommandComment *TodoCommand;
 
   DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
     return Diags.Report(Loc, DiagID);
Index: lib/AST/CommentSema.cpp
===================================================================
--- lib/AST/CommentSema.cpp     (revision 174114)
+++ lib/AST/CommentSema.cpp     (working copy)
@@ -30,7 +30,7 @@
            const Preprocessor *PP) :
     Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags), Traits(Traits),
     PP(PP), ThisDeclInfo(NULL), BriefCommand(NULL), ReturnsCommand(NULL),
-    HeaderfileCommand(NULL) {
+    HeaderfileCommand(NULL), TodoCommand(NULL) {
 }
 
 void Sema::setDecl(const Decl *D) {
@@ -492,6 +492,12 @@
       return;
     }
     PrevCommand = HeaderfileCommand;
+  } else if (Info->IsTodoCommand) {
+    if (!TodoCommand) {
+      TodoCommand = Command;
+      return;
+    }
+    PrevCommand = TodoCommand;
   } else {
     // We don't want to check this command for duplicates.
     return;
Index: tools/libclang/CXComment.cpp
===================================================================
--- tools/libclang/CXComment.cpp        (revision 174114)
+++ tools/libclang/CXComment.cpp        (working copy)
@@ -412,6 +412,7 @@
 
   const BlockContentComment *Brief;
   const BlockContentComment *Headerfile;
+  const BlockContentComment *Todo;
   const ParagraphComment *FirstParagraph;
   const BlockCommandComment *Returns;
   SmallVector<const ParamCommandComment *, 8> Params;
@@ -421,7 +422,8 @@
 
 FullCommentParts::FullCommentParts(const FullComment *C,
                                    const CommandTraits &Traits) :
-    Brief(NULL), Headerfile(NULL), FirstParagraph(NULL), Returns(NULL) {
+    Brief(NULL), Headerfile(NULL), Todo(NULL), FirstParagraph(NULL),
+    Returns(NULL) {
   for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
        I != E; ++I) {
     const Comment *Child = *I;
@@ -453,6 +455,10 @@
         Headerfile = BCC;
         break;
       }
+      if (!Todo && Info->IsTodoCommand) {
+        Todo = BCC;
+        break;
+      }
       if (!Returns && Info->IsReturnsCommand) {
         Returns = BCC;
         break;
@@ -789,6 +795,9 @@
 
   if (Parts.Returns)
     visit(Parts.Returns);
+  
+  if (Parts.Todo)
+    visit(Parts.Todo);
 
   Result.flush();
 }
@@ -1324,7 +1333,7 @@
       Result << "</Availability>";
     }
   }
-
+  
   {
     bool StartTagEmitted = false;
     for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {
@@ -1341,6 +1350,12 @@
       Result << "</Discussion>";
   }
 
+  if (Parts.Todo) {
+    Result << "<Todo>";
+    visit(Parts.Todo);
+    Result << "</Todo>";
+  }
+  
   Result << RootEndTag;
 
   Result.flush();
Index: utils/TableGen/ClangCommentCommandInfoEmitter.cpp
===================================================================
--- utils/TableGen/ClangCommentCommandInfoEmitter.cpp   (revision 174114)
+++ utils/TableGen/ClangCommentCommandInfoEmitter.cpp   (working copy)
@@ -42,6 +42,7 @@
        << Tag.getValueAsBit("IsTParamCommand") << ", "
        << Tag.getValueAsBit("IsDeprecatedCommand") << ", "
        << Tag.getValueAsBit("IsHeaderfileCommand") << ", "
+       << Tag.getValueAsBit("IsTodoCommand") << ", "
        << Tag.getValueAsBit("IsEmptyParagraphAllowed") << ", "
        << Tag.getValueAsBit("IsVerbatimBlockCommand") << ", "
        << Tag.getValueAsBit("IsVerbatimBlockEndCommand") << ", "
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to