aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-12 23:27:11 +0000
committerChris Lattner <sabre@nondot.org>2010-05-12 23:27:11 +0000
commitedd8df9cd260a74cfeea3c921a78d5f33c659573 (patch)
tree4de0d5468c65e9e235d603853e5c6c04dba1a6fb
parentface9818b52a6d47e4aa055a4bfcd435aed6010f (diff)
"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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103671 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Frontend/DocumentXML.h15
-rw-r--r--lib/Frontend/DeclXML.cpp3
-rw-r--r--test/Coverage/ast-printing.cpp2
3 files changed, 16 insertions, 4 deletions
diff --git a/include/clang/Frontend/DocumentXML.h b/include/clang/Frontend/DocumentXML.h
index 5227c12c2c..73d892105f 100644
--- a/include/clang/Frontend/DocumentXML.h
+++ b/include/clang/Frontend/DocumentXML.h
@@ -146,12 +146,23 @@ inline void DocumentXML::initialize(ASTContext &Context) {
//---------------------------------------------------------
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))
+ << "\"";
}
//---------------------------------------------------------
diff --git a/lib/Frontend/DeclXML.cpp b/lib/Frontend/DeclXML.cpp
index 3ae25f9b7d..97a7f55583 100644
--- a/lib/Frontend/DeclXML.cpp
+++ b/lib/Frontend/DeclXML.cpp
@@ -49,7 +49,8 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> {
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(),
diff --git a/test/Coverage/ast-printing.cpp b/test/Coverage/ast-printing.cpp
index 1a75fb4c63..0de5642289 100644
--- a/test/Coverage/ast-printing.cpp
+++ b/test/Coverage/ast-printing.cpp
@@ -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