diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-07 01:03:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-07 01:03:30 +0000 |
commit | cfee35b84587c42aa4cf09f446ca63dcdded09dc (patch) | |
tree | 34f680c397eea007646ccbacdab4e6c8da10877b /clang/lib/Frontend/StmtXML.cpp | |
parent | 3e76b502a42ac221ea41456a7631735024f8649b (diff) | |
download | bcm5719-llvm-cfee35b84587c42aa4cf09f446ca63dcdded09dc.tar.gz bcm5719-llvm-cfee35b84587c42aa4cf09f446ca63dcdded09dc.zip |
Remove the AST printer (-ast-print-xml), which is too incomplete and
too low-level to actually be useful but is just interesting enough for
people to try to use it (which won't actually work beyond toy examples).
To bring back the AST printer, it needs to be:
- Complete, covering all of C/C++/Objective-C
- Documented, with appropriate Schema against which we can validate
the output
- Designed for C/C++/Objective-C, not Clang's specific ASTs
- Stable across Clang versions
- Well-tested
llvm-svn: 127141
Diffstat (limited to 'clang/lib/Frontend/StmtXML.cpp')
-rw-r--r-- | clang/lib/Frontend/StmtXML.cpp | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/clang/lib/Frontend/StmtXML.cpp b/clang/lib/Frontend/StmtXML.cpp deleted file mode 100644 index 257c1ccb005..00000000000 --- a/clang/lib/Frontend/StmtXML.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//===--- StmtXML.cpp - XML implementation for Stmt ASTs ------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the Stmt::dumpXML methods, which dump out the -// AST to an XML document. -// -//===----------------------------------------------------------------------===// - -#include "clang/Frontend/DocumentXML.h" -#include "clang/AST/StmtVisitor.h" -#include "clang/AST/DeclObjC.h" -#include "clang/AST/DeclCXX.h" -#include "clang/Basic/SourceManager.h" -using namespace clang; - -//===----------------------------------------------------------------------===// -// StmtXML Visitor -//===----------------------------------------------------------------------===// - -namespace { - class StmtXML : public StmtVisitor<StmtXML> { - DocumentXML& Doc; - - //static const char *getOpcodeStr(UnaryOperator::Opcode Op); - //static const char *getOpcodeStr(BinaryOperator::Opcode Op); - - - void addSpecialAttribute(const char* pName, StringLiteral* Str) { - Doc.addAttribute(pName, Doc.escapeString(Str->getString().data(), - Str->getString().size())); - } - - void addSpecialAttribute(const char* pName, SizeOfAlignOfExpr* S) { - if (S->isArgumentType()) - Doc.addAttribute(pName, S->getArgumentType()); - } - - void addSpecialAttribute(const char* pName, CXXTypeidExpr* S) { - if (S->isTypeOperand()) - Doc.addAttribute(pName, S->getTypeOperand()); - } - - - public: - StmtXML(DocumentXML& doc) - : Doc(doc) { - } - - void DumpSubTree(Stmt *S) { - if (S) { - Visit(S); - if (DeclStmt* DS = dyn_cast<DeclStmt>(S)) { - for (DeclStmt::decl_iterator DI = DS->decl_begin(), - DE = DS->decl_end(); DI != DE; ++DI) { - Doc.PrintDecl(*DI); - } - } else { - for (Stmt::child_range i = S->children(); i; ++i) - DumpSubTree(*i); - } - Doc.toParent(); - } else { - Doc.addSubNode("NULL").toParent(); - } - } - - -#define NODE_XML( CLASS, NAME ) \ - void Visit##CLASS(CLASS* S) \ - { \ - typedef CLASS tStmtType; \ - Doc.addSubNode(NAME); - -#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, S->FN); -#define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type") -#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, S->FN); -#define ATTRIBUTE_SPECIAL_XML( FN, NAME ) addSpecialAttribute(NAME, S); -#define ATTRIBUTE_FILE_LOCATION_XML Doc.addLocationRange(S->getSourceRange()); - - -#define ATTRIBUTE_ENUM_XML( FN, NAME ) \ - { \ - const char* pAttributeName = NAME; \ - const bool optional = false; \ - switch (S->FN) { \ - default: assert(0 && "unknown enum value"); - -#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME ) \ - { \ - const char* pAttributeName = NAME; \ - const bool optional = true; \ - switch (S->FN) { \ - default: assert(0 && "unknown enum value"); - -#define ENUM_XML( VALUE, NAME ) case VALUE: if ((!optional) || NAME[0]) Doc.addAttribute(pAttributeName, NAME); break; -#define END_ENUM_XML } } -#define END_NODE_XML } - -#define ID_ATTRIBUTE_XML Doc.addAttribute("id", S); -#define SUB_NODE_XML( CLASS ) -#define SUB_NODE_SEQUENCE_XML( CLASS ) -#define SUB_NODE_OPT_XML( CLASS ) - -#include "clang/Frontend/StmtXML.def" - }; -} - -//===----------------------------------------------------------------------===// -// Stmt method implementations -//===----------------------------------------------------------------------===// - -/// dumpAll - This does a dump of the specified AST fragment and all subtrees. -void DocumentXML::PrintStmt(const Stmt *S) { - StmtXML P(*this); - P.DumpSubTree(const_cast<Stmt*>(S)); -} - |