本文整理汇总了C++中AST::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ AST::setName方法的具体用法?C++ AST::setName怎么用?C++ AST::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST
的用法示例。
在下文中一共展示了AST::setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AST
void C2ModuleLoader::load(C2::Module* c2Mod) {
clang::SourceLocation loc;
AST* ast = new AST("<generated>", false);
ASTContext& Context = ast->getASTContext();
ast->setName("c2", loc);
c2Mod->addAST(ast);
// uint64 buildtime
{
// make constant, CTC_NONE
QualType QT = Type::UInt64();
QT.addConst();
uint64_t value = time(0);
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, value, false));
// TODO get error without value if CTC_NONE, CTC_FULL gives out-of-bounds for value 123?!!
init->setCTC(CTC_NONE); // Don't check range, only type
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "buildtime", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int8 min_int8
{
QualType QT = Type::Int8();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, -128, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "min_int8", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int8 max_int8
{
QualType QT = Type::Int8();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 127, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_int8", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// uint8 min_uint8
{
QualType QT = Type::UInt8();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 0, false));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "min_uint8", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// uint8 max_uint8
{
QualType QT = Type::UInt8();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 255, false));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_uint8", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int16 min_int16
{
QualType QT = Type::Int16();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, -32768, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "min_int16", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int16 max_int16
{
QualType QT = Type::Int16();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 32767, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_int16", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
//.........这里部分代码省略.........