本文整理汇总了C++中AST::addType方法的典型用法代码示例。如果您正苦于以下问题:C++ AST::addType方法的具体用法?C++ AST::addType怎么用?C++ AST::addType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST
的用法示例。
在下文中一共展示了AST::addType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AST
//.........这里部分代码省略.........
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "min_uint32", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// uint32 max_uint32
{
QualType QT = Type::UInt32();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 4294967295, false));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_uint32", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int64 min_int64
{
QualType QT = Type::Int64();
QT.addConst();
// NOTE: minimum should be -..808, but clang complains about it..
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, -9223372036854775807ll, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "min_int64", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// int64 max_int64
{
QualType QT = Type::Int64();
QT.addConst();
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 9223372036854775807ll, true));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_int64", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// uint64 min_uint64
{
QualType QT = Type::UInt64();
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_uint64", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
// uint64 max_uint64
{
QualType QT = Type::UInt64();
QT.addConst();
// NOTE: capped to -1 since APInt is always signed?
Expr* init = new (Context) IntegerLiteral(loc, llvm::APInt(64, 18446744073709551615llu, false));
init->setCTC(CTC_FULL);
init->setConstant();
init->setType(QT);
VarDecl* var = new (Context) VarDecl(VARDECL_GLOBAL, "max_uint64", loc, QT, init, true);
var->setType(QT);
ast->addVar(var);
c2Mod->addSymbol(var);
}
#if 0
// type c_char int8
{
QualType QT = Type::Int8();
static const char* name = "c_char";
AliasTypeDecl* T = new (Context) AliasTypeDecl(name, loc, QT, true);
QualType A = Context.getAliasType(T, QT);
A->setCanonicalType(QT);
T->setType(A);
c2Mod->addSymbol(T);
}
#endif
// create C types (depend on target)
// NOTE: all types are lower-cased!
for (unsigned i=0; i<sizeof(ctypes)/sizeof(ctypes[0]); i++) {
QualType QT = ctypes[i].type;
AliasTypeDecl* T = new (Context) AliasTypeDecl(ctypes[i].name, loc, QT, true);
QualType A = Context.getAliasType(T, QT);
A->setCanonicalType(QT);
T->setType(A);
ast->addType(T);
c2Mod->addSymbol(T);
}
}