bool SimpleUnaryOperation::keyPressedOnPosition(Position const& _p, KeyEvent const* _e) { if (!_p.exists()) return false; bool pre; if (!Operator(_e->text(), Operator::UnaryPrefix).isNull() && (_p->isPlaceholder()/* || _e->isInserting()*/)) pre = true; else if (!Operator(_e->text(), Operator::UnaryPostfix).isNull() && (!Operator(_e->text(), Operator::UnaryPrefix).isNull() || !_p->isPlaceholder())) pre = false; else return false; Operator o(_e->text(), pre ? Operator::UnaryPrefix : Operator::UnaryPostfix); Position p = slideOnPrecedence(_p, o.precedence(), o.associativity(), _e->nearestBracket(_p)); bool b = findOperators(o, p->isKind<Typed>() ? p->asKind<Typed>()->apparentType() : Type()).size(); if (b && !isTemporary(p.concept())) { SimpleUnaryOperation* n = new SimpleUnaryOperation(o, p->isKind<Typed>() ? p->asKind<Typed>()->apparentType() : Type()); _e->noteStrobeCreation(n, &*p); p->insert(n, TheOperand); n->validifyChildren(); _e->codeScene()->dropCursor(n); return true; } return false; }
QSharedPointer<Food> Meal::getCanonicalSharedPointer() const { if (isTemporary()) { return DataCache<TemporaryMeal>::getInstance().get(getTemporaryId()); } else { return DataCache<Meal>::getInstance().get(getMealIdTuple()); } }
SqlLob::~SqlLob() { // According to the Oracle 10g documentation we should try to free // implicit created temporary LOBs as soon as possible. if (isTemporary()) { sword res = OCICALL(OCILobFreeTemporary(_conn._svc_ctx, _conn._env._errh, _loc)); oci_check_error(__TROTL_HERE__, _conn._env._errh, res); } sword res = OCICALL(OCIDescriptorFree(_loc, OCI_DTYPE_LOB)); oci_check_error(__TROTL_HERE__, _conn._env, res); };
bool CalendarPage::setupData(const QNdefMessage message) { QOrganizerItem o = Util::organizerItemFromNdef(message); if (o.isEmpty() == true) { setCalendarItem(QOrganizerItem()); return false; } setCalendarItem(o); if (isTemporary() == true) { setDefaultName(m_info.displayLabel()); } return true; }
void DanglingOnTemporaryChecker::registerMatchers(MatchFinder *AstMatcher) { //////////////////////////////////////// // Quick annotation conflict checkers // //////////////////////////////////////// AstMatcher->addMatcher( // This is a matcher on a method declaration, cxxMethodDecl( // which is marked as no dangling on temporaries, noDanglingOnTemporaries(), // and which is && ref-qualified. isRValueRefQualified(), decl().bind("invalidMethodRefQualified")), this); AstMatcher->addMatcher( // This is a matcher on a method declaration, cxxMethodDecl( // which is marked as no dangling on temporaries, noDanglingOnTemporaries(), // which returns a primitive type, returns(builtinType()), // and which doesn't return a pointer. unless(returns(pointerType())), decl().bind("invalidMethodPointer")), this); ////////////////// // Main checker // ////////////////// auto hasParentCall = hasParent(expr(anyOf( cxxOperatorCallExpr( // If we're in a lamda, we may have an operator call expression // ancestor in the AST, but the temporary we're matching // against is not going to have the same lifetime as the // constructor call. unless(has(expr(ignoreTrivials(lambdaExpr())))), expr().bind("parentOperatorCallExpr")), callExpr( // If we're in a lamda, we may have a call expression // ancestor in the AST, but the temporary we're matching // against is not going to have the same lifetime as the // function call. unless(has(expr(ignoreTrivials(lambdaExpr())))), expr().bind("parentCallExpr")), objcMessageExpr( // If we're in a lamda, we may have an objc message expression // ancestor in the AST, but the temporary we're matching // against is not going to have the same lifetime as the // function call. unless(has(expr(ignoreTrivials(lambdaExpr())))), expr().bind("parentObjCMessageExpr")), cxxConstructExpr( // If we're in a lamda, we may have a construct expression // ancestor in the AST, but the temporary we're matching // against is not going to have the same lifetime as the // constructor call. unless(has(expr(ignoreTrivials(lambdaExpr())))), expr().bind("parentConstructExpr"))))); AstMatcher->addMatcher( // This is a matcher on a method call, cxxMemberCallExpr( // which is in first party code, isFirstParty(), // and which is performed on a temporary, on(allOf( unless(hasType(pointerType())), isTemporary(), // but which is not `this`. unless(cxxThisExpr()))), // and which is marked as no dangling on temporaries. callee(cxxMethodDecl(noDanglingOnTemporaries())), expr().bind("memberCallExpr"), // We optionally match a parent call expression or a parent construct // expression because using a temporary inside a call is fine as long // as the pointer doesn't escape the function call. anyOf( // This is the case where the call is the direct parent, so we // know that the member call expression is the argument. allOf(hasParentCall, expr().bind("parentCallArg")), // This is the case where the call is not the direct parent, so we // get its child to know in which argument tree we are. hasAncestor(expr( hasParentCall, expr().bind("parentCallArg"))), // To make it optional. anything())), this); }