MCPcopy Create free account
hub / github.com/avast/retdec / insert

Method insert

src/common/object.cpp:203–236  ·  view source on GitHub ↗

* Besides calling the underlying container's insert which checks (and replaces) * for existing elements with the same unique ID (name), this method also check * for elements with the same global address. Such elements are also removed * before adding the new element, since container is not allowed to hold two * ebjects with the same global address. Moreover, @c _addr2global is also * updated.

Source from the content-addressed store, hash-verified

201 * updated.
202 */
203std::pair<GlobalVarContainer::iterator,bool> GlobalVarContainer::insert(
204 const Object& e)
205{
206 assert(e.getStorage().isMemory());
207 if (!e.getStorage().isMemory())
208 {
209 return {end(), false};
210 }
211
212 auto existing = getObjectByAddress(e.getStorage().getAddress());
213 if (existing)
214 {
215 erase(*existing);
216 }
217 auto fit = find(e.getName());
218 if (fit != end())
219 {
220 ObjectSetContainer::erase(fit);
221 }
222
223 auto retPair = ObjectSetContainer::insert(e);
224
225 const Object* obj = &(*retPair.first);
226 const auto& addr = e.getStorage().getAddress();
227 auto res = _addr2global.emplace(addr,obj);
228 if (!res.second)
229 {
230 // There is already an object on this address, so overwrite it
231 // to ensure that it is updated.
232 res.first->second = obj;
233 }
234
235 return retPair;
236}
237
238std::pair<GlobalVarContainer::iterator,bool> GlobalVarContainer::insert(
239 GlobalVarContainer::iterator,

Callers 15

loadResourcesMethod · 0.45
emitFileHeaderMethod · 0.45
getAPICallFuncNamesFunction · 0.45
renameIntrinsicFuncMethod · 0.45
markLabelAsUsedMethod · 0.45
convertFuncBodyMethod · 0.45
replaceGotoMethod · 0.45
inspectCFGNodeMethod · 0.45

Calls 3

isMemoryMethod · 0.80
getAddressMethod · 0.45
getNameMethod · 0.45

Tested by 15

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36