X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FClangASTNodesEmitter.h;h=712333bd2d251216b83712681e801b89853da917;hb=8b8515c225c799e9df69bde8ffffa3c72cec9445;hp=c4ce9fa820682cee4744bed81630242bc8e7794d;hpb=44ed2c31a5b3233fd11575346d2bd3551578f631;p=oota-llvm.git diff --git a/utils/TableGen/ClangASTNodesEmitter.h b/utils/TableGen/ClangASTNodesEmitter.h index c4ce9fa8206..712333bd2d2 100644 --- a/utils/TableGen/ClangASTNodesEmitter.h +++ b/utils/TableGen/ClangASTNodesEmitter.h @@ -15,19 +15,67 @@ #define CLANGAST_EMITTER_H #include "TableGenBackend.h" +#include "Record.h" +#include +#include +#include namespace llvm { -/// ClangStmtNodesEmitter - The top-level class emits .def files containing +/// ClangASTNodesEmitter - The top-level class emits .inc files containing /// declarations of Clang statements. /// -class ClangStmtNodesEmitter : public TableGenBackend { +class ClangASTNodesEmitter : public TableGenBackend { + // A map from a node to each of its derived nodes. + typedef std::multimap ChildMap; + typedef ChildMap::const_iterator ChildIterator; + RecordKeeper &Records; + Record Root; + const std::string &BaseSuffix; + + // Create a macro-ized version of a name + static std::string macroName(std::string S) { + for (unsigned i = 0; i < S.size(); ++i) + S[i] = std::toupper(S[i]); + + return S; + } + + // Return the name to be printed in the base field. Normally this is + // the record's name plus the base suffix, but if it is the root node and + // the suffix is non-empty, it's just the suffix. + std::string baseName(Record &R) { + if (&R == &Root && !BaseSuffix.empty()) + return BaseSuffix; + + return R.getName() + BaseSuffix; + } + + std::pair EmitNode (const ChildMap &Tree, raw_ostream& OS, + Record *Base); +public: + explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N, + const std::string &S) + : Records(R), Root(N, SMLoc(), R), BaseSuffix(S) + {} + + // run - Output the .inc file contents + void run(raw_ostream &OS); +}; + +/// ClangDeclContextEmitter - Emits an addendum to a .inc file to enumerate the +/// clang declaration contexts. +/// +class ClangDeclContextEmitter : public TableGenBackend { + RecordKeeper &Records; + public: - explicit ClangStmtNodesEmitter(RecordKeeper &R) - : Records(R) {} + explicit ClangDeclContextEmitter(RecordKeeper &R) + : Records(R) + {} - // run - Output the .def file contents + // run - Output the .inc file contents void run(raw_ostream &OS); };