本文整理汇总了C++中INT_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ INT_ASSERT函数的具体用法?C++ INT_ASSERT怎么用?C++ INT_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INT_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertLocalTemp
//
// The argument expr is a use of a wide reference. Insert a check to ensure
// that it is on the current locale, then drop its wideness by moving the
// addr field into a non-wide of otherwise the same type. Then, replace its
// use with the non-wide version.
//
static void insertLocalTemp(Expr* expr) {
SymExpr* se = toSymExpr(expr);
Expr* stmt = expr->getStmtExpr();
INT_ASSERT(se && stmt);
SET_LINENO(se);
VarSymbol* var = newTemp(astr("local_", se->var->name),
se->var->type->getField("addr")->type);
if (!fNoLocalChecks) {
stmt->insertBefore(new CallExpr(PRIM_LOCAL_CHECK, se->copy()));
}
stmt->insertBefore(new DefExpr(var));
stmt->insertBefore(new CallExpr(PRIM_MOVE, var, se->copy()));
se->replace(new SymExpr(var));
}
示例2: checkErrorHandling
static void checkErrorHandling(FnSymbol* fn, implicitThrowsReasons_t* reasons)
{
if (strcmp(fn->name, "deinit") == 0) {
if (fn->throwsError())
USR_FATAL_CONT(fn, "deinit is not permitted to throw");
}
error_checking_mode_t mode = computeErrorCheckingMode(fn);
INT_ASSERT(mode != ERROR_MODE_UNKNOWN);
ErrorCheckingVisitor visit(fn->throwsError(), mode, reasons);
fn->body->accept(&visit);
}
示例3: fnHasNoSideEffects
/*
* Returns true if `e` has no side effects. Checked side effects are:
* - Read/write to a global
* - Is/contains essential primitive
* - If it's a call to functions with ref arguments
* - If the LHS of a PRIM_MOVE appears in the exprToMove
*
* For now, this is a very conservative analysis. A more precise analysis
* could distinguish between reads and writes to memory and to take into
* account alias analysis.
*/
bool SafeExprAnalysis::exprHasNoSideEffects(Expr* e, Expr* exprToMove) {
if(safeExprCache.count(e) > 0) {
return safeExprCache[e];
}
if(CallExpr* ce = toCallExpr(e)) {
if(!ce->isPrimitive()) {
FnSymbol* fnSym = ce->theFnSymbol();
const bool cachedSafeFn = safeFnCache.count(fnSym);
if(!cachedSafeFn) {
const bool retval = fnHasNoSideEffects(fnSym);
safeFnCache[fnSym] = retval;
return retval;
}
return safeFnCache[fnSym];
}
else {
//primitive
if(! isSafePrimitive(ce)){
safeExprCache[e] = false;
return false;
}
else if (exprToMove != NULL) {
//
// Exposed by AST pattern like this:
// |---|------- `exprToMove`
// (move T (+ A B))
// (move A B) -------- `ce`
// (move B T)
//
// Without this check could turn into:
//
// (move A B)
// (move B (+ A B))
//
// Which is incorrect.
//
if (ce->isPrimitive(PRIM_MOVE)) {
INT_ASSERT(isSymExpr(ce->get(1)));
std::vector<SymExpr*> syms;
collectSymExprs(exprToMove, syms);
for_vector(SymExpr, s, syms) {
if (s->symbol() == toSymExpr(ce->get(1))->symbol()) {
safeExprCache[e] = false;
return false;
}
}
}
}
}
}
示例4: canRHSBeConstRef
//
// Assumes 'parent' is a PRIM_MOVE or PRIM_ASSIGN
//
// Returns false if the LHS of the move/assign indicates that the rhs cannot
// be a const-ref. For example, if we have a case like this:
//
// (move A, (set-reference B))
//
// where 'A' and 'B' are references, B cannot be a const-ref if A is not a
// const-ref.
//
// In the case of a dereference, (move A, (deref B)), this function will return
// true because we're simply reading B.
//
static bool canRHSBeConstRef(CallExpr* parent, SymExpr* use) {
INT_ASSERT(isMoveOrAssign(parent));
SymExpr* LHS = toSymExpr(parent->get(1));
CallExpr* rhs = toCallExpr(parent->get(2));
INT_ASSERT(rhs);
switch (rhs->primitive->tag) {
case PRIM_GET_MEMBER_VALUE:
case PRIM_GET_SVEC_MEMBER_VALUE:
if (LHS->isRef() == false &&
isClass(LHS->typeInfo()) == false) {
return true;
}
// fallthrough
case PRIM_GET_MEMBER:
case PRIM_GET_SVEC_MEMBER:
case PRIM_GET_REAL:
case PRIM_GET_IMAG:
case PRIM_ADDR_OF:
case PRIM_SET_REFERENCE: {
// If LHS is a reference and is not a const-ref, the reference in 'rhs'
// should not be considered a const-ref either.
//
// For the get-member primitives, I intend this to be a safe approach
// until we know what const-ref means for fields. Basically, if any field
// might be modified I do not consider the base object to be const-ref.
//
// Note that the get-*-value primitives may return a reference if the
// field is a reference.
if (LHS->isRef()) {
return inferConstRef(LHS->symbol());
}
}
default:
break;
}
return isSafeRefPrimitive(use);
}
示例5: storeBool
void IpeEnv::storeFoo(LcnSymbol* sym, IpeValue value)
{
#if 0
if (sym->type == dtBools[BOOL_SIZE_SYS])
{
storeBool(sym, value.boolGet());
}
else if (sym->type == dtInt[INT_SIZE_64])
{
storeInteger(sym, value.integerGet());
}
else if (sym->type == dtReal[FLOAT_SIZE_64])
{
storeReal(sym, value.realGet());
}
else
{
AstDumpToNode logger(stdout, 3);
printf("\n\n");
printf(" IpeEnv::store(LcnSymbol*) Unsupported\n");
printf(" ");
sym->accept(&logger);
printf("\n\n");
INT_ASSERT(false);
}
#endif
INT_ASSERT(false);
}
示例6: onlyUsedForRetarg
//
// ref: The reference symbol we will test to see if it is only used as an
// actual where the corresponding formal has FLAG_RETARG.
//
// defCall: The CallExpr where 'ref' is set from a PRIM_ADDR_OF or
// PRIM_SET_REFERENCE. This call will be ignored while considering uses of
// the 'ref' Symbol.
//
static bool onlyUsedForRetarg(Symbol* ref, CallExpr* defCall) {
bool isRetArgOnly = true;
INT_ASSERT(ref->isRef());
INT_ASSERT(defCall != NULL);
for_SymbolSymExprs(use, ref) {
if (use->parentExpr == defCall) {
continue;
}
CallExpr* call = toCallExpr(use->parentExpr);
if (call->isResolved()) {
ArgSymbol* form = actual_to_formal(use);
if (form->hasFlag(FLAG_RETARG) == false) {
isRetArgOnly = false;
}
} else {
isRetArgOnly = false;
}
}
return isRetArgOnly;
}
示例7: handleLocalBlocks
//
// Do a breadth first search starting from functions generated for local blocks
// for all function calls in each level of the search, if they directly cause
// communication, add a local temp that isn't wide. If it is a resolved call,
// meaning that it isn't a primitive or external function, clone it and add it
// to the queue of functions to handle at the next iteration of the BFS.
//
static void handleLocalBlocks() {
Map<FnSymbol*,FnSymbol*> cache; // cache of localized functions
Vec<BlockStmt*> queue; // queue of blocks to localize
forv_Vec(BlockStmt, block, gBlockStmts) {
if (block->parentSymbol) {
// NOAKES 2014/11/25 Transitional. Avoid calling blockInfoGet()
if (block->isLoopStmt() == true) {
} else if (block->blockInfoGet()) {
if (block->blockInfoGet()->isPrimitive(PRIM_BLOCK_LOCAL)) {
queue.add(block);
}
}
}
}
forv_Vec(BlockStmt, block, queue) {
std::vector<CallExpr*> calls;
collectCallExprs(block, calls);
for_vector(CallExpr, call, calls) {
localizeCall(call);
if (FnSymbol* fn = call->isResolved()) {
SET_LINENO(fn);
if (FnSymbol* alreadyLocal = cache.get(fn)) {
call->baseExpr->replace(new SymExpr(alreadyLocal));
} else {
if (!fn->hasFlag(FLAG_EXTERN)) {
FnSymbol* local = fn->copy();
local->addFlag(FLAG_LOCAL_FN);
local->name = astr("_local_", fn->name);
local->cname = astr("_local_", fn->cname);
fn->defPoint->insertBefore(new DefExpr(local));
call->baseExpr->replace(new SymExpr(local));
queue.add(local->body);
cache.put(fn, local);
cache.put(local, local); // to handle recursion
if (local->retType->symbol->hasFlag(FLAG_WIDE_REF)) {
CallExpr* ret = toCallExpr(local->body->body.tail);
INT_ASSERT(ret && ret->isPrimitive(PRIM_RETURN));
// Capture the return expression in a local temp.
insertLocalTemp(ret->get(1));
local->retType = ret->get(1)->typeInfo();
}
}
}
}
}
示例8: lowerErrorHandling
static void lowerErrorHandling(FnSymbol* fn)
{
ArgSymbol* outError = NULL;
LabelSymbol* epilogue = NULL;
if (fn->throwsError()) {
SET_LINENO(fn);
outError = addOutErrorArg(fn);
epilogue = fn->getOrCreateEpilogueLabel();
INT_ASSERT(epilogue); // throws requires an epilogue
}
ErrorHandlingVisitor visitor = ErrorHandlingVisitor(outError, epilogue);
fn->accept(&visitor);
}
示例9: INT_ASSERT
// This is intended to mimick Expr::remove(), without 'this' being an Expr.
void ForallIntents::removeFI(Expr* parentB) {
// If this fails need to use trace_remove() instead of remove_help()
// - see Expr::remove().
INT_ASSERT(parentB->parentSymbol);
// "Remove" all ASTs that 'this' contains.
#define REMOVE(dest) if (dest) remove_help(dest, 'r')
for_vector(Expr, var, fiVars) REMOVE(var);
for_riSpecs_vector(ri, this) REMOVE(ri);
REMOVE(iterRec);
REMOVE(leadIdx);
REMOVE(leadIdxCopy);
#undef REMOVE
}
示例10: genMakefileEnvCache
std::string genMakefileEnvCache(void) {
std::string result;
std::map<std::string, const char*>::iterator env;
for (env = envMap.begin(); env != envMap.end(); ++env) {
const std::string& key = env->first;
const char* oldPrefix = "CHPL_";
const char* newPrefix = "CHPL_MAKE_";
INT_ASSERT(key.substr(0, strlen(oldPrefix)) == oldPrefix);
std::string keySuffix = key.substr(strlen(oldPrefix), std::string::npos);
std::string chpl_make_key = newPrefix + keySuffix;
result += chpl_make_key + "=" + std::string(env->second) + "|";
}
return result;
}
示例11: INT_ASSERT
// This is a placeholder
void IpeModule::initialize()
{
if (mState == kLoaded || mState == kResolving)
INT_ASSERT(false);
else if (mState == kInitializing || mState == kInitialized)
;
else
{
mState = kInitializing;
mEnv->initializeUsedModules();
mState = kInitialized;
}
}
示例12: returnInfoArrayIndexValue
static Type*
returnInfoArrayIndexValue(CallExpr* call) {
SymExpr* sym = toSymExpr(call->get(1));
INT_ASSERT(sym);
Type* type = sym->var->type;
if (type->symbol->hasFlag(FLAG_WIDE_CLASS))
type = type->getField("addr")->type;
if (!type->substitutions.n)
INT_FATAL(call, "bad primitive");
// Is this conditional necessary? Can just assume condition is true?
if (type->symbol->hasFlag(FLAG_DATA_CLASS)) {
return toTypeSymbol(getDataClassType(type->symbol))->type;
}
else {
return toTypeSymbol(type->substitutions.v[0].value)->type;
}
}
示例13: isSafeRefPrimitive
//
// Returns true if 'use' appears in a non-side-effecting primitive.
//
static bool isSafeRefPrimitive(SymExpr* use) {
CallExpr* call = toCallExpr(use->parentExpr);
INT_ASSERT(call);
switch (call->primitive->tag) {
case PRIM_ADDR_OF:
case PRIM_SET_REFERENCE:
case PRIM_DEREF:
case PRIM_WIDE_GET_LOCALE:
case PRIM_NOOP:
case PRIM_UNARY_MINUS:
case PRIM_UNARY_PLUS:
case PRIM_UNARY_NOT:
case PRIM_UNARY_LNOT:
case PRIM_ADD:
case PRIM_SUBTRACT:
case PRIM_MULT:
case PRIM_DIV:
case PRIM_MOD:
case PRIM_LSH:
case PRIM_RSH:
case PRIM_EQUAL:
case PRIM_NOTEQUAL:
case PRIM_LESSOREQUAL:
case PRIM_GREATEROREQUAL:
case PRIM_LESS:
case PRIM_GREATER:
case PRIM_AND:
case PRIM_OR:
case PRIM_XOR:
case PRIM_POW:
case PRIM_MIN:
case PRIM_MAX:
case PRIM_CHECK_NIL:
case PRIM_LOCAL_CHECK:
case PRIM_PTR_EQUAL:
case PRIM_PTR_NOTEQUAL:
case PRIM_SIZEOF_BUNDLE:
case PRIM_SIZEOF_DDATA_ELEMENT:
case PRIM_WIDE_GET_NODE:
return true;
default:
return false;
}
}
示例14: createDeclaration
IpeModuleRoot* IpeModuleRoot::allocate()
{
if (sRootModule == 0)
{
ModuleSymbol* modSym = createDeclaration();
sRootModule = new IpeModuleRoot(modSym);
sRootModule->init();
}
else
{
printf("Fatal error:: IpeModuleRoot:allocate has already been executed\n");
INT_ASSERT(false);
}
return sRootModule;
}
示例15: findBlockForTarget
// Find the block stmt that encloses the target of this gotoStmt
static BlockStmt* findBlockForTarget(GotoStmt* stmt) {
BlockStmt* retval = NULL;
if (stmt != NULL && stmt->isGotoReturn() == false) {
SymExpr* labelSymExpr = toSymExpr(stmt->label);
Expr* ptr = labelSymExpr->symbol()->defPoint;
while (ptr != NULL && isBlockStmt(ptr) == false) {
ptr = ptr->parentExpr;
}
retval = toBlockStmt(ptr);
INT_ASSERT(retval);
}
return retval;
}