本文整理汇总了C++中Exp::IncRef方法的典型用法代码示例。如果您正苦于以下问题:C++ Exp::IncRef方法的具体用法?C++ Exp::IncRef怎么用?C++ Exp::IncRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exp
的用法示例。
在下文中一共展示了Exp::IncRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Visit
void Visit(Exp *exp)
{
if (ExpFld *nexp = exp->IfFld()) {
// pick up any type invariants from the host type.
String *csu_name = nexp->GetField()->GetCSUType()->GetCSUName();
Vector<BlockCFG*> *annot_list = CompAnnotCache.Lookup(csu_name);
for (size_t ind = 0; annot_list && ind < annot_list->Size(); ind++) {
BlockCFG *annot_cfg = annot_list->At(ind);
Assert(annot_cfg->GetAnnotationKind() == AK_Invariant ||
annot_cfg->GetAnnotationKind() == AK_InvariantAssume);
BlockId *id = annot_cfg->GetId();
Bit *bit = BlockMemory::GetAnnotationBit(annot_cfg);
if (!bit) continue;
// get the *this expression. we'll replace this with the actual CSU
// lvalue to get the assumed bit.
id->IncRef();
Variable *this_var = Variable::Make(id, VK_This, NULL, 0, NULL);
Exp *this_exp = Exp::MakeVar(this_var);
Exp *this_drf = Exp::MakeDrf(this_exp);
Exp *target = nexp->GetTarget();
GuardExpVector lval_res;
if (mcfg) {
mcfg->TranslateExp(TRK_Point, point, target, &lval_res);
}
else {
target->IncRef();
lval_res.PushBack(GuardExp(target, Bit::MakeConstant(true)));
}
for (size_t lind = 0; lind < lval_res.Size(); lind++) {
// ignore the guard component of the result here. this means that
// accessing a field of a value means related invariants hold for
// the value along all paths. which is normally right, except when
// the value is the result of a cast, and could have a different type
// along other paths. TODO: sort this out.
const GuardExp &gs = lval_res[lind];
Bit *new_bit = BitReplaceExp(bit, this_drf, gs.exp);
new_bit->MoveRef(NULL, assume_list);
annot_cfg->IncRef(assume_list);
AssumeInfo info;
info.annot = annot_cfg;
info.point = 0;
info.bit = new_bit;
assume_list->PushBack(info);
}
this_drf->DecRef();
}
CompAnnotCache.Release(csu_name);
}
if (ExpVar *nexp = exp->IfVar()) {
if (nexp->GetVariable()->Kind() == VK_Glob) {
String *var_name = nexp->GetVariable()->GetName();
Vector<BlockCFG*> *annot_list = InitAnnotCache.Lookup(var_name);
for (size_t ind = 0; annot_list && ind < annot_list->Size(); ind++) {
BlockCFG *annot_cfg = annot_list->At(ind);
Assert(annot_cfg->GetAnnotationKind() == AK_Invariant ||
annot_cfg->GetAnnotationKind() == AK_InvariantAssume);
Bit *bit = BlockMemory::GetAnnotationBit(annot_cfg);
if (!bit) continue;
bit->IncRef(assume_list);
annot_cfg->IncRef(assume_list);
AssumeInfo info;
info.annot = annot_cfg;
info.point = 0;
info.bit = bit;
assume_list->PushBack(info);
}
InitAnnotCache.Release(var_name);
}
}
}
示例2: FillBakedSummary
void FillBakedSummary(BlockSummary *sum)
{
Variable *name = sum->GetId()->BaseVar();
// primitive memory allocator.
Exp *object;
Exp *size;
if (GetAllocationFunction(name, &object, &size)) {
Exp *bound = GetByteUpperBound(object);
// the upper bound is greater or equal to zero.
bound->IncRef();
Exp *zero = Exp::MakeInt(0);
Bit *bound_nonneg = Exp::MakeCompareBit(B_GreaterEqual, bound, zero);
sum->AddAssume(bound_nonneg);
// the upper bound of the object is exactly equal to size.
Bit *bound_equal = Exp::MakeCompareBit(B_Equal, bound, size);
sum->AddAssume(bound_equal);
// TODO: it would be nice to assert the offset is exactly equal
// to zero for the UI; however, this can lead to spurious contradiction
// if unaligned pointers are in use.
}
// return value bears some relation with an argument.
ReturnCompareFunctionInfo *cur_return = g_return_compare_functions;
while (cur_return->name) {
if (TextNameMatch(name, cur_return->name)) {
Exp *ret_exp = GetReturnedValue();
Exp *arg_exp = GetArgumentValue(cur_return->compare_arg);
Type *type = NULL;
if (IsPointerBinop(cur_return->binop))
type = Type::MakeInt(1, true);
Bit *bit = Exp::MakeCompareBit(cur_return->binop,
ret_exp, arg_exp, type);
sum->AddAssume(bit);
}
cur_return++;
}
// return value is NULL terminated.
const char **cur_ret_term = g_return_terminated_functions;
while (*cur_ret_term) {
if (TextNameMatch(name, *cur_ret_term)) {
Exp *ret_exp = GetReturnedValue();
Exp *terminate = GetNullTerminate(ret_exp);
Exp *zero = Exp::MakeInt(0);
Bit *bit = Exp::MakeCompareBit(B_GreaterEqual, terminate, zero);
sum->AddAssume(bit);
}
cur_ret_term++;
}
// an argument is NULL terminated.
TerminateFunctionInfo *cur_term = g_terminate_functions;
while (cur_term->name) {
if (TextNameMatch(name, cur_term->name) && cur_term->terminates) {
Exp *arg_exp = GetArgumentValue(cur_term->terminate_arg);
Exp *kind = GetNullTerminate(NULL);
Exp *exit_term = Exp::MakeExit(arg_exp, kind);
Exp *zero = Exp::MakeInt(0);
Bit *bit = Exp::MakeCompareBit(B_GreaterEqual, exit_term, zero);
sum->AddAssume(bit);
}
cur_term++;
}
// strchr constraint: char_arg != 0 => zterm(ret) > 0.
StrchrFunctionInfo *cur_strchr = g_strchr_functions;
while (cur_strchr->name) {
if (TextNameMatch(name, cur_strchr->name)) {
Exp *arg_exp = GetArgumentValue(cur_strchr->char_arg);
Exp *ret_exp = GetReturnedValue();
Exp *terminate = GetNullTerminate(ret_exp);
Exp *zero = Exp::MakeInt(0);
zero->IncRef();
Bit *left = Exp::MakeCompareBit(B_NotEqual, arg_exp, zero);
Bit *right = Exp::MakeCompareBit(B_GreaterThan, terminate, zero);
Bit *bit = Bit::MakeImply(left, right);
sum->AddAssume(bit);
}
cur_strchr++;
}
//.........这里部分代码省略.........