/*-----------------------------------------------------------------*/ void computeLiveRanges (eBBlock **ebbs, int count, bool emitWarnings) { /* first look through all blocks and adjust the sch and ech pointers */ adjustIChain (ebbs, count); /* sequence the code the live ranges are computed in terms of this sequence additionally the routine will also create a hashtable of instructions */ iCodeSeq = 0; setToNull ((void *) &iCodehTab); iCodehTab = newHashTable (iCodeKey); hashiCodeKeys (ebbs, count); setToNull ((void *) &iCodeSeqhTab); iCodeSeqhTab = newHashTable (iCodeKey); sequenceiCode (ebbs, count); /* mark the ranges live for each point */ setToNull ((void *) &liveRanges); rlivePoint (ebbs, count, emitWarnings); /* mark the from & to live ranges for variables used */ markLiveRanges (ebbs, count); /* compute which overlaps with what */ computeClash(ebbs, count); }
/*-----------------------------------------------------------------*/ void computeControlFlow (ebbIndex * ebbi) { eBBlock ** ebbs = ebbi->bbOrder; int dfCount = ebbi->count; int i; /* initialise some things */ for (i = 0; i < ebbi->count; i++) { setToNull ((void *) &ebbs[i]->predList); setToNull ((void *) &ebbs[i]->domVect); setToNull ((void *) &ebbs[i]->succList); setToNull ((void *) &ebbs[i]->succVect); ebbs[i]->visited = 0; ebbs[i]->dfnum = 0; } setToNull ((void *) &graphEdges); /* this will put in the */ /* successor information for each blk */ eBBSuccessors (ebbi); /* compute the depth first ordering */ computeDFOrdering (ebbi->bbOrder[0], &dfCount); /* mark blocks with no paths to them */ markNoPath (ebbi); /* with the depth first info in place */ /* add the predecessors for the blocks */ eBBPredecessors (ebbi); /* compute the dominance graph */ computeDominance (ebbi); /* sort it by dfnumber */ if (!ebbi->dfOrder) ebbi->dfOrder = Safe_alloc ((ebbi->count+1) * sizeof (eBBlock *)); for (i = 0; i < (ebbi->count+1); i++) { ebbi->dfOrder[i] = ebbi->bbOrder[i]; } qsort (ebbi->dfOrder, ebbi->count, sizeof (eBBlock *), dfNumCompare); }
triagens::basics::Json DocumentAccessor::toJson () { if (_current == nullptr) { // we're still pointing to the original document auto shaper = _document->getShaper(); // fetch document from mptr TRI_shaped_json_t shaped; TRI_EXTRACT_SHAPED_JSON_MARKER(shaped, _mptr->getDataPtr()); triagens::basics::Json json(shaper->memoryZone(), TRI_JsonShapedJson(shaper, &shaped)); // add internal attributes // _id, _key, _rev char const* key = TRI_EXTRACT_MARKER_KEY(_mptr); std::string id(_resolver->getCollectionName(_document->_info._cid)); id.push_back('/'); id.append(key); json(TRI_VOC_ATTRIBUTE_ID, triagens::basics::Json(id)); json(TRI_VOC_ATTRIBUTE_REV, triagens::basics::Json(std::to_string(TRI_EXTRACT_MARKER_RID(_mptr)))); json(TRI_VOC_ATTRIBUTE_KEY, triagens::basics::Json(key)); if (TRI_IS_EDGE_MARKER(_mptr)) { // _from std::string from(_resolver->getCollectionNameCluster(TRI_EXTRACT_MARKER_FROM_CID(_mptr))); from.push_back('/'); from.append(TRI_EXTRACT_MARKER_FROM_KEY(_mptr)); json(TRI_VOC_ATTRIBUTE_FROM, triagens::basics::Json(from)); // _to std::string to(_resolver->getCollectionNameCluster(TRI_EXTRACT_MARKER_TO_CID(_mptr))); to.push_back('/'); to.append(TRI_EXTRACT_MARKER_TO_KEY(_mptr)); json(TRI_VOC_ATTRIBUTE_TO, triagens::basics::Json(to)); } return json; } if (_current == _json.get()) { // _current points at the JSON that we own // steal the JSON TRI_json_t* value = _json.release(); setToNull(); return triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, value); } TRI_json_t* copy = TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, _current); if (copy != nullptr) { _json.release(); return triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, copy); } // fall-through intentional return triagens::basics::Json(triagens::basics::Json::Null); }
/*! Intersects this box with \a box. \sa intersected(), intersects(), unite() */ void QBox3D::intersect(const QBox3D& box) { // Handle the simple cases first. if (boxtype == Null) { // Null intersected with anything is null. return; } else if (boxtype == Infinite) { // Infinity intersected with a box is that box. *this = box; return; } else if (box.boxtype == Null) { // Anything intersected with null is null. setToNull(); return; } else if (box.boxtype == Infinite) { // Box intersected with infinity is the box. return; } // Intersect two finite boxes. QVector3D min1 = mincorner; QVector3D max1 = maxcorner; QVector3D min2 = box.mincorner; QVector3D max2 = box.maxcorner; if (min2.x() > min1.x()) min1.setX(min2.x()); if (min2.y() > min1.y()) min1.setY(min2.y()); if (min2.z() > min1.z()) min1.setZ(min2.z()); if (max2.x() < max1.x()) max1.setX(max2.x()); if (max2.y() < max1.y()) max1.setY(max2.y()); if (max2.z() < max1.z()) max1.setZ(max2.z()); if (min1.x() > max1.x() || min1.y() > max1.y() || min1.z() > max1.z()) { setToNull(); } else { mincorner = min1; maxcorner = max1; } }
void DocumentAccessor::lookupJsonAttribute (char const* name, size_t nameLength) { TRI_ASSERT(_current != nullptr); if (! isObject()) { setToNull(); return; } TRI_json_t const* value = TRI_LookupObjectJson(_current, name); if (value == nullptr) { // attribute not found setToNull(); } else { // found _current = value; } }
/*public*/ void Envelope::expandBy(double deltaX, double deltaY) { if (isNull()) return; minx -= deltaX; maxx += deltaX; miny -= deltaY; maxy += deltaY; // check for envelope disappearing if (minx > maxx || miny > maxy) setToNull(); }
/*-----------------------------------------------------------------*/ void overlay2data () { symbol *sym; for (sym = setFirstItem (overlay->syms); sym; sym = setNextItem (overlay->syms)) { SPEC_OCLS (sym->etype) = data; allocIntoSeg (sym); } setToNull ((void *) &overlay->syms); }
/*-----------------------------------------------------------------*/ void overlay2Set () { symbol *sym; set *oset = NULL; for (sym = setFirstItem (overlay->syms); sym; sym = setNextItem (overlay->syms)) { addSet (&oset, sym); } setToNull ((void *) &overlay->syms); addSet (&ovrSetSets, oset); }
/*-----------------------------------------------------------------*/ eBBlock * immedDom (ebbIndex * ebbi, eBBlock * ebp) { /* first delete self from the list */ set *iset = domSetFromVect (ebbi, ebp->domVect); eBBlock *loop; eBBlock *idom = NULL; deleteSetItem (&iset, ebp); /* then just return the one with the greatest */ /* depthfirst number, this will be the immed dominator */ if ((loop = setFirstItem (iset))) idom = loop; for (; loop; loop = setNextItem (iset)) if (loop->dfnum > idom->dfnum) idom = loop; setToNull ((void *) &iset); return idom; }
DocumentAccessor& DocumentAccessor::at (int64_t index) { if (isArray()) { size_t length = TRI_LengthArrayJson(_current); if (index < 0) { // a negative position is allowed index = static_cast<int64_t>(length) + index; } if (index >= 0 && index < static_cast<int64_t>(length)) { // only look up the value if it is within array bounds TRI_json_t const* found = TRI_LookupArrayJson(_current, static_cast<size_t>(index)); if (found != nullptr) { _current = found; return *this; } } // fall-through intentional } setToNull(); return *this; }
/*-----------------------------------------------------------------*/ void computeDataFlow (eBBlock ** ebbs, int count) { int i; int change = 1; while (change) { change = 0; /* for all blocks */ for (i = 0; i < count; i++) { set *pred; set *oldOut; int firstTime; eBBlock *pBlock; /* if this is the entry block then continue */ /* since entry block can never have any inExprs */ if (ebbs[i]->noPath) continue; /* get blocks that can come to this block */ pred = edgesTo (ebbs[i]); /* make a copy of the outExpressions : to be */ /* used for iteration */ oldOut = setFromSet (ebbs[i]->outExprs); setToNull ((void **) &ebbs[i]->inDefs); /* indefitions are easy just merge them by union */ /* these are the definitions that can possibly */ /* reach this block */ firstTime = 1; applyToSet (pred, mergeInDefs, ebbs[i], &firstTime); /* if none of the edges coming to this block */ /* dominate this block then add the immediate dominator */ /* of this block to the list of predecessors */ for (pBlock = setFirstItem (pred); pBlock; pBlock = setNextItem (pred)) { if (bitVectBitValue (ebbs[i]->domVect, pBlock->bbnum)) break; } /* get the immediate dominator and put it there */ if (!pBlock) { eBBlock *idom = immedDom (ebbs, ebbs[i]); if (idom) addSetHead (&pred, idom); } /* figure out the incoming expressions */ /* this is a little more complex */ setToNull ((void **) &ebbs[i]->inExprs); if (optimize.global_cse) { firstTime = 1; applyToSet (pred, mergeInExprs, ebbs[i], &firstTime); } setToNull ((void **) &pred); /* do cse with computeOnly flag set to TRUE */ /* this by far the quickest way of computing */ cseBBlock (ebbs[i], TRUE, ebbs, count); /* if it change we will need to iterate */ change += !isSetsEqualWith (ebbs[i]->outExprs, oldOut, isCseDefEqual); } if (!change) /* iterate till no change */ break; } return; }
void setToNullAndPrint(int **vptr, const char *str) { setToNull(vptr); print(str); }
void macroArgContainsLParenRParenTest() { int *a; CALL_FUNCTION(setToNull(&a)); *a = 5; // expected-warning{{Dereference of null pointer}} }
/*public*/ void Envelope::init() { setToNull(); }
void DocumentAccessor::lookupDocumentAttribute (char const* name, size_t nameLength) { if (*name == '_' && name[1] != '\0') { if (name[1] == 'k' && nameLength == 4 && memcmp(name, TRI_VOC_ATTRIBUTE_KEY, nameLength) == 0) { // _key value is copied into JSON char const* key = TRI_EXTRACT_MARKER_KEY(_mptr); if (key == nullptr) { setToNull(); return; } _json.reset(TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, key, strlen(key))); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } if (name[1] == 'i' && nameLength == 3 && memcmp(name, TRI_VOC_ATTRIBUTE_ID, nameLength) == 0) { // _id char buffer[512]; // big enough for max key length + max collection name length size_t pos = _resolver->getCollectionName(&buffer[0], _document->_info._cid); buffer[pos++] = '/'; char const* key = TRI_EXTRACT_MARKER_KEY(_mptr); if (key == nullptr) { setToNull(); return; } size_t len = strlen(key); memcpy(&buffer[pos], key, len); buffer[pos + len] = '\0'; _json.reset(TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, &buffer[0], pos + len)); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } if (name[1] == 'r' && nameLength == 4 && memcmp(name, TRI_VOC_ATTRIBUTE_REV, nameLength) == 0) { // _rev char buffer[21]; TRI_voc_rid_t rid = TRI_EXTRACT_MARKER_RID(_mptr); size_t len = TRI_StringUInt64InPlace(rid, &buffer[0]); _json.reset(TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, &buffer[0], len)); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } if (TRI_IS_EDGE_MARKER(_mptr)) { if (name[1] == 'f' && nameLength == 5 && memcmp(name, TRI_VOC_ATTRIBUTE_FROM, nameLength) == 0) { // _from char buffer[512]; // big enough for max key length + max collection name length size_t pos = _resolver->getCollectionNameCluster(&buffer[0], TRI_EXTRACT_MARKER_FROM_CID(_mptr)); buffer[pos++] = '/'; char const* key = TRI_EXTRACT_MARKER_FROM_KEY(_mptr); if (key == nullptr) { setToNull(); return; } size_t len = strlen(key); memcpy(&buffer[pos], key, len); buffer[pos + len] = '\0'; _json.reset(TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, &buffer[0], pos + len)); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } if (name[1] == 't' && nameLength == 3 && memcmp(name, TRI_VOC_ATTRIBUTE_TO, nameLength) == 0) { // to char buffer[512]; // big enough for max key length + max collection name length size_t pos = _resolver->getCollectionNameCluster(&buffer[0], TRI_EXTRACT_MARKER_TO_CID(_mptr)); buffer[pos++] = '/'; char const* key = TRI_EXTRACT_MARKER_TO_KEY(_mptr); if (key == nullptr) { setToNull(); return; } size_t len = strlen(key); memcpy(&buffer[pos], key, len); buffer[pos + len] = '\0'; _json.reset(TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, &buffer[0], pos + len)); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } } // fall-through intentional } auto shaper = _document->getShaper(); TRI_shape_pid_t pid = shaper->lookupAttributePathByName(name); if (pid == 0) { // attribute does not exist setToNull(); return; } // attribute exists TRI_shaped_json_t document; TRI_EXTRACT_SHAPED_JSON_MARKER(document, _mptr->getDataPtr()); TRI_shaped_json_t json; TRI_shape_t const* shape; bool ok = shaper->extractShapedJson(&document, 0, pid, &json, &shape); if (ok && shape != nullptr) { _json.reset(TRI_JsonShapedJson(shaper, &json)); if (_json.get() == nullptr) { THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); } _current = _json.get(); return; } // not found setToNull(); }
void SerializerBase::invokeRead(Archive &ar) { Node node( "", "", 0, false ); Node * pNode = NULL; if (ar.isFlagSet(Archive::NODE_ALREADY_READ)) { LocalStorage & localStorage = ar.getIstream()->getLocalStorage(); pNode = reinterpret_cast<Node *>(localStorage.getNode()); } else { if ( ! ar.getIstream()->begin(node) ) return; pNode = &node; } // Detect polymorphism, either through pointers or through references if (!ar.isFlagSet(Archive::POLYMORPHIC)) { if ( ar.isFlagSet(Archive::POINTER) || (!ar.isFlagSet(Archive::PARENT) && isDerived())) { if (pNode->type.length() > 0) { ar.setFlag(Archive::POLYMORPHIC, true ); std::string derivedTypeName = pNode->type.cpp_str(); getSerializerPolymorphic(derivedTypeName); ar.getIstream()->getLocalStorage().setNode(pNode); ar.setFlag(Archive::NODE_ALREADY_READ); invokeSerializerPolymorphic(ar); return; } } } // May now assume that the object is not polymorphic UInt32 nid = pNode->id; bool bId = pNode->id ? true : false; bool bNode = pNode->ref ? false : true; bool bPointer = ar.isFlagSet(Archive::POINTER); ar.clearState(); if (bId && bNode && bPointer) { newObject(ar); addToInputContext(ar.getIstream(), nid); serializeContents(ar); } else if ( !bId && bNode && bPointer ) { newObject(ar); serializeContents(ar); } else if (bId && !bNode && bPointer) { queryInputContext(ar.getIstream(), nid); setFromId(); } else if (bId && bNode && !bPointer) { addToInputContext(ar.getIstream(), nid); serializeContents(ar); } else if (!bId && bNode && !bPointer ) { serializeContents(ar); } else if (!bId && !bNode && bPointer) { setToNull(); } else if (!bId && !bNode && !bPointer) { RCF::Exception e(RCF::_RcfError_DeserializationNullPointer()); RCF_THROW(e); } else if (bId && !bNode && !bPointer) { RCF::Exception e(RCF::_SfError_RefMismatch()); RCF_THROW(e); } ar.getIstream()->end(); }