ClangASTNodesEmitter.h [plain text]
#ifndef CLANGAST_EMITTER_H
#define CLANGAST_EMITTER_H
#include "TableGenBackend.h"
#include "Record.h"
#include <string>
#include <cctype>
#include <map>
namespace llvm {
class ClangASTNodesEmitter : public TableGenBackend {
typedef std::multimap<Record*, Record*> ChildMap;
typedef ChildMap::const_iterator ChildIterator;
RecordKeeper &Records;
Record Root;
const std::string &BaseSuffix;
static std::string macroName(std::string S) {
for (unsigned i = 0; i < S.size(); ++i)
S[i] = std::toupper(S[i]);
return S;
}
std::string baseName(Record &R) {
if (&R == &Root && !BaseSuffix.empty())
return BaseSuffix;
return R.getName() + BaseSuffix;
}
std::pair<Record *, Record *> 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)
{}
void run(raw_ostream &OS);
};
class ClangDeclContextEmitter : public TableGenBackend {
RecordKeeper &Records;
public:
explicit ClangDeclContextEmitter(RecordKeeper &R)
: Records(R)
{}
void run(raw_ostream &OS);
};
}
#endif