[cfe-commits] r103671 - in /cfe/trunk: include/clang/Frontend/DocumentXML.h lib/Frontend/DeclXML.cpp test/Coverage/ast-printing.cpp

Chris Lattner sabre at nondot.org
Wed May 12 16:27:11 PDT 2010


Author: lattner
Date: Wed May 12 18:27:11 2010
New Revision: 103671

URL: http://llvm.org/viewvc/llvm-project?rev=103671&view=rev
Log:
"this patch properly addresses escaping < and > which might appear
(e.g. for C++ operators) in the xml dump.

I also re-enabled the unit test for ast-print-xml (or so I think)
at least, make test didn't fail..."

patch by Sebastien Binet!


Modified:
    cfe/trunk/include/clang/Frontend/DocumentXML.h
    cfe/trunk/lib/Frontend/DeclXML.cpp
    cfe/trunk/test/Coverage/ast-printing.cpp

Modified: cfe/trunk/include/clang/Frontend/DocumentXML.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DocumentXML.h?rev=103671&r1=103670&r2=103671&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/DocumentXML.h (original)
+++ cfe/trunk/include/clang/Frontend/DocumentXML.h Wed May 12 18:27:11 2010
@@ -146,12 +146,23 @@
 //---------------------------------------------------------
 template<class T>
 inline void DocumentXML::addAttribute(const char* pName, const T& value) {
-  Out << ' ' << pName << "=\"" << value << "\"";
+  std::string repr;
+  {
+    llvm::raw_string_ostream buf(repr);
+    buf << value;
+    buf.flush();
+  }
+  
+  Out << ' ' << pName << "=\"" 
+      << DocumentXML::escapeString(repr.c_str(), repr.size())
+      << "\"";
 }
 
 //---------------------------------------------------------
 inline void DocumentXML::addPtrAttribute(const char* pName, const char* text) {
-  Out << ' ' << pName << "=\"" << text << "\"";
+  Out << ' ' << pName << "=\"" 
+      << DocumentXML::escapeString(text, strlen(text))
+      << "\"";
 }
 
 //---------------------------------------------------------

Modified: cfe/trunk/lib/Frontend/DeclXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DeclXML.cpp?rev=103671&r1=103670&r2=103671&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DeclXML.cpp (original)
+++ cfe/trunk/lib/Frontend/DeclXML.cpp Wed May 12 18:27:11 2010
@@ -49,7 +49,8 @@
     addSubNodes(cast<RecordDecl>(RD));
 
     if (RD->isDefinition()) {
-      Doc.addAttribute("num_bases", RD->getNumBases());
+      // FIXME: This breaks XML generation
+      //Doc.addAttribute("num_bases", RD->getNumBases());
 
       for (CXXRecordDecl::base_class_iterator 
              base = RD->bases_begin(),

Modified: cfe/trunk/test/Coverage/ast-printing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/ast-printing.cpp?rev=103671&r1=103670&r2=103671&view=diff
==============================================================================
--- cfe/trunk/test/Coverage/ast-printing.cpp (original)
+++ cfe/trunk/test/Coverage/ast-printing.cpp Wed May 12 18:27:11 2010
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only %s
 // RUN: %clang_cc1 -ast-print %s
 // RUN: %clang_cc1 -ast-dump %s
-// FIXME: %clang_cc1 -ast-print-xml -o %t %s
+// RUN: %clang_cc1 -ast-print-xml -o %t %s
 // RUN: %clang_cc1 -print-decl-contexts %s
 // RUN: %clang_cc1 -fdump-record-layouts %s
 





More information about the cfe-commits mailing list