[cfe-commits] r161531 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng test/Index/Inputs/CommentXML/valid-function-07.xml test/Index/annotate-comments.cpp tools/libclang/CXComment.cpp

Dmitri Gribenko gribozavr at gmail.com
Wed Aug 8 15:10:25 PDT 2012


Author: gribozavr
Date: Wed Aug  8 17:10:24 2012
New Revision: 161531

URL: http://llvm.org/viewvc/llvm-project?rev=161531&view=rev
Log:
Comment XML: use xml:space="preserve" in Verbatim tags, so that XML tidy does
not compress spaces in verbatim content.

Modified:
    cfe/trunk/bindings/xml/comment-xml-schema.rng
    cfe/trunk/test/Index/Inputs/CommentXML/valid-function-07.xml
    cfe/trunk/test/Index/annotate-comments.cpp
    cfe/trunk/tools/libclang/CXComment.cpp

Modified: cfe/trunk/bindings/xml/comment-xml-schema.rng
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/xml/comment-xml-schema.rng?rev=161531&r1=161530&r2=161531&view=diff
==============================================================================
--- cfe/trunk/bindings/xml/comment-xml-schema.rng (original)
+++ cfe/trunk/bindings/xml/comment-xml-schema.rng Wed Aug  8 17:10:24 2012
@@ -385,6 +385,9 @@
         </zeroOrMore>
       </element>
       <element name="Verbatim">
+        <attribute name="xml:space">
+          <value>preserve</value>
+        </attribute>
         <attribute name="kind">
           <!-- TODO: add all Doxygen verbatim kinds -->
           <choice>

Modified: cfe/trunk/test/Index/Inputs/CommentXML/valid-function-07.xml
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/CommentXML/valid-function-07.xml?rev=161531&r1=161530&r2=161531&view=diff
==============================================================================
--- cfe/trunk/test/Index/Inputs/CommentXML/valid-function-07.xml (original)
+++ cfe/trunk/test/Index/Inputs/CommentXML/valid-function-07.xml Wed Aug  8 17:10:24 2012
@@ -24,6 +24,7 @@
 <ResultDiscussion><Para>Eee.</Para></ResultDiscussion>
 <Discussion>
   <Para>Fff</Para>
+  <Verbatim xml:space="preserve" kind="verbatim">Ggg</Verbatim>
 </Discussion>
 </Function>
 

Modified: cfe/trunk/test/Index/annotate-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments.cpp?rev=161531&r1=161530&r2=161531&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-comments.cpp (original)
+++ cfe/trunk/test/Index/annotate-comments.cpp Wed Aug  8 17:10:24 2012
@@ -778,7 +778,7 @@
 // CHECK-NEXT:         (CXComment_HTMLStartTag Name=[a] Attrs: href=http://example.com/)
 // CHECK-NEXT:         (CXComment_Text Text=[Aaa])
 // CHECK-NEXT:         (CXComment_HTMLEndTag Name=[a])))]
-// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[<pre> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></pre>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="338" column="6"><Name>comment_to_html_conversion_24</Name><USR>c:@F at comment_to_html_conversion_24#</USR><Discussion><Verbatim kind="verbatim"> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></Verbatim></Discussion></Function>]
+// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[<pre> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></pre>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="338" column="6"><Name>comment_to_html_conversion_24</Name><USR>c:@F at comment_to_html_conversion_24#</USR><Discussion><Verbatim xml:space="preserve" kind="verbatim"> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></Verbatim></Discussion></Function>]
 // CHECK-NEXT:  CommentAST=[
 // CHECK-NEXT:    (CXComment_FullComment
 // CHECK-NEXT:       (CXComment_Paragraph IsWhitespace

Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=161531&r1=161530&r2=161531&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Wed Aug  8 17:10:24 2012
@@ -982,8 +982,8 @@
     return;
 
   Result << llvm::StringSwitch<const char *>(C->getCommandName())
-      .Case("code", "<Verbatim kind=\"code\">")
-      .Default("<Verbatim kind=\"verbatim\">");
+      .Case("code", "<Verbatim xml:space=\"preserve\" kind=\"code\">")
+      .Default("<Verbatim xml:space=\"preserve\" kind=\"verbatim\">");
   for (unsigned i = 0; i != NumLines; ++i) {
     appendToResultWithXMLEscaping(C->getText(i));
     if (i + 1 != NumLines)
@@ -999,7 +999,7 @@
 
 void CommentASTToXMLConverter::visitVerbatimLineComment(
                                   const VerbatimLineComment *C) {
-  Result << "<Verbatim kind=\"verbatim\">";
+  Result << "<Verbatim xml:space=\"preserve\" kind=\"verbatim\">";
   appendToResultWithXMLEscaping(C->getText());
   Result << "</Verbatim>";
 }





More information about the cfe-commits mailing list