<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 1, 2013, at 4:29 PM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br>On Saturday, March 2, 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: Fri Mar  1 16:51:30 2013<br>
New Revision: 176387<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=176387&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=176387&view=rev</a><br>
Log:<br>
comment parsing. Keep the original command format<br>
in AST for source fidelity and use it in diagnostics<br>
to refer to the original format. // <a href="rdar://13066276">rdar://13066276</a><br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/Comment.h<br>
    cfe/trunk/include/clang/AST/CommentLexer.h<br>
    cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td<br>
    cfe/trunk/lib/AST/CommentLexer.cpp<br>
    cfe/trunk/lib/AST/CommentParser.cpp<br>
    cfe/trunk/lib/AST/CommentSema.cpp<br>
    cfe/trunk/test/Sema/warn-documentation.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Comment.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=176387&r1=176386&r2=176387&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=176387&r1=176386&r2=176387&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/Comment.h (original)<br>
+++ cfe/trunk/include/clang/AST/Comment.h Fri Mar  1 16:51:30 2013<br>
@@ -570,13 +570,16 @@ protected:<br>
<br>
   /// Paragraph argument.<br>
   ParagraphComment *Paragraph;<br>
-<br>
+<br>
+  /// Header Doc command, if true<br>
+  bool HDCommand;<br>
+<br>
   BlockCommandComment(CommentKind K,<br>
                       SourceLocation LocBegin,<br>
                       SourceLocation LocEnd,<br>
                       unsigned CommandID) :<br>
       BlockContentComment(K, LocBegin, LocEnd),<br>
-      Paragraph(NULL) {<br>
+      Paragraph(NULL), HDCommand(false) {<br>
     setLocation(getCommandNameBeginLoc());<br>
     BlockCommandCommentBits.CommandID = CommandID;<br>
   }<br>
@@ -586,7 +589,7 @@ public:<br>
                       SourceLocation LocEnd,<br>
                       unsigned CommandID) :<br>
       BlockContentComment(BlockCommandCommentKind, LocBegin, LocEnd),<br>
-      Paragraph(NULL) {<br>
+      Paragraph(NULL), HDCommand(false) {<br>
     setLocation(getCommandNameBeginLoc());<br>
     BlockCommandCommentBits.CommandID = CommandID;<br>
   }<br>
@@ -657,6 +660,14 @@ public:<br>
     if (NewLocEnd.isValid())<br>
       setSourceRange(SourceRange(getLocStart(), NewLocEnd));<br>
   }<br>
+<br>
+  bool getHDCommand() const LLVM_READONLY {<br>
+    return HDCommand;<br>
+  }<br>
+<br>
+  void setHDCommand(bool HDC) {<br>
+    HDCommand = HDC;<br>
+  }<br>
 };<br>
<br>
 /// Doxygen <a href="smb://param">\\param</a> command.<br>
<br>
Modified: cfe/trunk/include/clang/AST/CommentLexer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentLexer.h?rev=176387&r1=176386&r2=176387&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentLexer.h?rev=176387&r1=176386&r2=176387&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/CommentLexer.h (original)<br>
+++ cfe/trunk/include/clang/AST/CommentLexer.h Fri Mar  1 16:51:30 2013<br>
@@ -75,6 +75,9 @@ class Token {<br>
   /// unused (command spelling can be found with CommandTraits).  Otherwise,<br>
   /// contains the length of the string that starts at TextPtr.<br>
   unsigned IntVal;<br>
+<br>
+  /// This command is a Header Doc command (command starts with '@').<br>
+  bool     HDCommand;</blockquote><div><br></div><div>This is unfortunate that we increase sizeof Token.  We use Token as a value type that should be cheap to copy.  I think we could carry this information in the token kind, by defining 'backslash command' and 'at command' tokens.</div></blockquote><div><br></div>OK.</div><div><br><blockquote type="cite">
<div> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
<br>
 public:<br>
   SourceLocation getLocation() const LLVM_READONLY { return Loc; }<br>
@@ -122,6 +125,10 @@ public:<br>
     return IntVal;<br>
   }<br>
<br>
+  bool getHDCommand() const LLVM_READONLY {<br>
+    return HDCommand;<br>
+  }<br>
+<br>
   void setCommandID(unsigned ID) {<br>
     assert(is(tok::command));<br>
     IntVal = ID;<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=176387&r1=176386&r2=176387&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176387&r1=176386&r2=176387&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Fri Mar  1 16:51:30 2013<br>
@@ -44,18 +44,18 @@ def note_doc_html_end_tag : Note<<br>
 // Commands<br>
<br>
 def warn_doc_block_command_empty_paragraph : Warning<<br>
-  "empty paragraph passed to '\\%0' command">,<br>
+  "empty paragraph passed to '%select{\\|@}0%1' command">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
 def warn_doc_block_command_duplicate : Warning<<br>
-  "duplicated command '\\%0'">,<br>
+  "duplicated command '%select{\\|@}0%1'">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
 def note_doc_block_command_previous : Note<<br>
-  "previous command '\\%0' here">;<br>
+  "previous command '%select{\\|@}0%1' here">;<br>
<br>
 def note_doc_block_command_previous_alias : Note<<br>
-  "previous command '\\%0' (an alias of '\\%1') here">;<br>
+  "previous command '%select{\\|@}0%1' (an alias of '\\%2') here">;<br>
<br>
 // \param command<br>
<br>
@@ -111,14 +111,14 @@ def note_doc_tparam_name_suggestion : No<br>
 // \returns command<br>
<br>
 def warn_doc_returns_not_attached_to_a_function_decl : Warning<<br>
-  "'\\%0' command used in a comment that is not attached to "<br>
+  "'%select{\\|@}0%1' command used in a comment that is not attached to "<br>
   "a function or method declaration">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
 def warn_doc_returns_attached_to_a_void_function : Warning<<br>
-  "'\\%0' command used in a comment that is attached to a "<br>
+  "'%select{\\|@}0%1' command used in a comment that is attached to a "<br>
   "%select{function returning void|constructor|destructor|"<br>
-  "method returning void}1">,<br>
+  "method returning void}2">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
 // \deprecated command<br>
@@ -134,7 +134,7 @@ def note_add_deprecation_attr : Note<<br>
 // verbatim block commands<br>
<br>
 def warn_verbatim_block_end_without_start : Warning<<br>
-  "'\\%0' command does not terminate a verbatim text block">,<br>
+  "'%select{\\|@}0%1' command does not terminate a verbatim text block">,<br>
   InGroup<Documentation>, DefaultIgnore;<br>
<br>
 } // end of documentation issue category<br>
<br>
Modified: cfe/trunk/lib/AST/CommentLexer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=176387&r1=176386&r2=176387&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=176387&r1=176386&r2=176387&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/CommentLexer.cpp (original)<br>
+++ cfe/trunk/lib/AST/CommentLexer.cpp Fri Mar  1 16:51:30 2013<br>
@@ -298,6 +298,7 @@ void Lexer::lexCommentText(Token &T) {<br>
     switch(*TokenPtr) {<br>
       case '\\':<br>
       case '@': {<br>
+        T.HDCommand = (*TokenPtr == '@');<br>
         TokenPtr++;<br>
         if (TokenPtr == CommentEnd) {<br>
           formTextToken(T, TokenPtr);<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=176387&r1=176386&r2=176387&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=176387&r1=176386&r2=176387&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/CommentParser.cpp (original)<br>
+++ cfe/trunk/lib/AST/CommentParser.cpp Fri Mar  1 16:51:30 2013<br>
@@ -313,15 +313,18 @@ BlockCommandComment *Parser::parseBlockC<br>
     PC = S.actOnParamCommandStart(Tok.getLocation(),<br>
                                   Tok.getEndLocation(),<br>
                                   Tok.getCommandID());<br>
+    PC->setHDCommand(Tok.getHDCommand());</blockquote><div><br></div><div>This kind of fixups that are done after AST node is created is fragile -- we could forget to insert a fixup in a new place where we create ASTnodes.  This flag (or an enum?!) should be an argument for the onstructor.</div></blockquote><div><br></div>Yeh, I was first going to pass down to these 3 actOn…. routines but changes would have become substantive. So I did not.</div><div>But, I agree with he underlying argument.</div><div><br></div><div>- fj</div><div><br></div><br></body></html>