本文整理汇总了C++中std::set::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ set::insert方法的具体用法?C++ set::insert怎么用?C++ set::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::set
的用法示例。
在下文中一共展示了set::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maybeKillChain
void AArch64A57FPLoadBalancing::
scanInstruction(MachineInstr *MI, unsigned Idx,
std::map<unsigned, Chain*> &ActiveChains,
std::set<std::unique_ptr<Chain>> &AllChains) {
// Inspect "MI", updating ActiveChains and AllChains.
if (isMul(MI)) {
for (auto &I : MI->uses())
maybeKillChain(I, Idx, ActiveChains);
for (auto &I : MI->defs())
maybeKillChain(I, Idx, ActiveChains);
// Create a new chain. Multiplies don't require forwarding so can go on any
// unit.
unsigned DestReg = MI->getOperand(0).getReg();
DEBUG(dbgs() << "New chain started for register "
<< TRI->getName(DestReg) << " at " << *MI);
auto G = llvm::make_unique<Chain>(MI, Idx, getColor(DestReg));
ActiveChains[DestReg] = G.get();
AllChains.insert(std::move(G));
} else if (isMla(MI)) {
// It is beneficial to keep MLAs on the same functional unit as their
// accumulator operand.
unsigned DestReg = MI->getOperand(0).getReg();
unsigned AccumReg = MI->getOperand(3).getReg();
maybeKillChain(MI->getOperand(1), Idx, ActiveChains);
maybeKillChain(MI->getOperand(2), Idx, ActiveChains);
if (DestReg != AccumReg)
maybeKillChain(MI->getOperand(0), Idx, ActiveChains);
if (ActiveChains.find(AccumReg) != ActiveChains.end()) {
DEBUG(dbgs() << "Chain found for accumulator register "
<< TRI->getName(AccumReg) << " in MI " << *MI);
// For simplicity we only chain together sequences of MULs/MLAs where the
// accumulator register is killed on each instruction. This means we don't
// need to track other uses of the registers we want to rewrite.
//
// FIXME: We could extend to handle the non-kill cases for more coverage.
if (MI->getOperand(3).isKill()) {
// Add to chain.
DEBUG(dbgs() << "Instruction was successfully added to chain.\n");
ActiveChains[AccumReg]->add(MI, Idx, getColor(DestReg));
// Handle cases where the destination is not the same as the accumulator.
if (DestReg != AccumReg) {
ActiveChains[DestReg] = ActiveChains[AccumReg];
ActiveChains.erase(AccumReg);
}
return;
}
DEBUG(dbgs() << "Cannot add to chain because accumulator operand wasn't "
<< "marked <kill>!\n");
maybeKillChain(MI->getOperand(3), Idx, ActiveChains);
}
DEBUG(dbgs() << "Creating new chain for dest register "
<< TRI->getName(DestReg) << "\n");
auto G = llvm::make_unique<Chain>(MI, Idx, getColor(DestReg));
ActiveChains[DestReg] = G.get();
AllChains.insert(std::move(G));
} else {
// Non-MUL or MLA instruction. Invalidate any chain in the uses or defs
// lists.
for (auto &I : MI->uses())
maybeKillChain(I, Idx, ActiveChains);
for (auto &I : MI->defs())
maybeKillChain(I, Idx, ActiveChains);
}
}
示例2: GetExtensionList
// ------------------------------------------------------------------------------------------------
// List all extensions handled by this loader
void BlenderImporter::GetExtensionList(std::set<std::string>& app)
{
app.insert("blend");
}
示例3: predicate
//.........这里部分代码省略.........
// Map: reg -> bitmask of subregs
ReferenceMap Uses, Defs;
MachineBasicBlock::iterator DefIt = DefI, TfrIt = TfrI;
// Check if the predicate register is valid between DefI and TfrI.
// If it is, we can then ignore instructions predicated on the negated
// conditions when collecting def and use information.
bool PredValid = true;
for (MachineBasicBlock::iterator I = std::next(DefIt); I != TfrIt; ++I) {
if (!I->modifiesRegister(PredR, nullptr))
continue;
PredValid = false;
break;
}
for (MachineBasicBlock::iterator I = std::next(DefIt); I != TfrIt; ++I) {
MachineInstr *MI = &*I;
// If this instruction is predicated on the same register, it could
// potentially be ignored.
// By default assume that the instruction executes on the same condition
// as TfrI (Exec_Then), and also on the opposite one (Exec_Else).
unsigned Exec = Exec_Then | Exec_Else;
if (PredValid && HII->isPredicated(*MI) && MI->readsRegister(PredR))
Exec = (Cond == HII->isPredicatedTrue(*MI)) ? Exec_Then : Exec_Else;
for (auto &Op : MI->operands()) {
if (!Op.isReg())
continue;
// We don't want to deal with physical registers. The reason is that
// they can be aliased with other physical registers. Aliased virtual
// registers must share the same register number, and can only differ
// in the subregisters, which we are keeping track of. Physical
// registers ters no longer have subregisters---their super- and
// subregisters are other physical registers, and we are not checking
// that.
RegisterRef RR = Op;
if (!TargetRegisterInfo::isVirtualRegister(RR.Reg))
return false;
ReferenceMap &Map = Op.isDef() ? Defs : Uses;
if (Op.isDef() && Op.isUndef()) {
assert(RR.Sub && "Expecting a subregister on <def,read-undef>");
// If this is a <def,read-undef>, then it invalidates the non-written
// part of the register. For the purpose of checking the validity of
// the move, assume that it modifies the whole register.
RR.Sub = 0;
}
addRefToMap(RR, Map, Exec);
}
}
// The situation:
// RT = DefI
// ...
// RD = TfrI ..., RT
// If the register-in-the-middle (RT) is used or redefined between
// DefI and TfrI, we may not be able proceed with this transformation.
// We can ignore a def that will not execute together with TfrI, and a
// use that will. If there is such a use (that does execute together with
// TfrI), we will not be able to move DefI down. If there is a use that
// executed if TfrI's condition is false, then RT must be available
// unconditionally (cannot be predicated).
// Essentially, we need to be able to rename RT to RD in this segment.
if (isRefInMap(RT, Defs, Exec_Then) || isRefInMap(RT, Uses, Exec_Else))
return false;
RegisterRef RD = MD;
// If the predicate register is defined between DefI and TfrI, the only
// potential thing to do would be to move the DefI down to TfrI, and then
// predicate. The reaching def (DefI) must be movable down to the location
// of the TfrI.
// If the target register of the TfrI (RD) is not used or defined between
// DefI and TfrI, consider moving TfrI up to DefI.
bool CanUp = canMoveOver(TfrI, Defs, Uses);
bool CanDown = canMoveOver(*DefI, Defs, Uses);
// The TfrI does not access memory, but DefI could. Check if it's safe
// to move DefI down to TfrI.
if (DefI->mayLoad() || DefI->mayStore())
if (!canMoveMemTo(*DefI, TfrI, true))
CanDown = false;
DEBUG(dbgs() << "Can move up: " << (CanUp ? "yes" : "no")
<< ", can move down: " << (CanDown ? "yes\n" : "no\n"));
MachineBasicBlock::iterator PastDefIt = std::next(DefIt);
if (CanUp)
predicateAt(MD, *DefI, PastDefIt, MP, Cond, UpdRegs);
else if (CanDown)
predicateAt(MD, *DefI, TfrIt, MP, Cond, UpdRegs);
else
return false;
if (RT != RD) {
renameInRange(RT, RD, PredR, Cond, PastDefIt, TfrIt);
UpdRegs.insert(RT.Reg);
}
removeInstr(TfrI);
removeInstr(*DefI);
return true;
}
示例4: scanDirectory
void PluginCache::scanDirectory(std::set<std::string> &foundBinFiles, const std::string &dir, bool recurse)
{
#ifdef CACHE_DEBUG
printf("looking in %s for plugins\n", dir.c_str());
#endif
#if defined (WINDOWS)
WIN32_FIND_DATA findData;
HANDLE findHandle;
#else
DIR *d = opendir(dir.c_str());
if (!d) {
return;
}
#endif
_pluginDirs.push_back(dir.c_str());
#if defined (UNIX)
while (dirent *de = readdir(d))
#elif defined (WINDOWS)
findHandle = FindFirstFile((dir + "\\*").c_str(), &findData);
if (findHandle == INVALID_HANDLE_VALUE)
{
return;
}
while (1)
#endif
{
#if defined (UNIX)
std::string name = de->d_name;
bool isdir = true;
#else
std::string name = findData.cFileName;
bool isdir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
#endif
if (name.find(".ofx.bundle") != std::string::npos) {
std::string barename = name.substr(0, name.length() - strlen(".bundle"));
std::string bundlename = dir + DIRSEP + name;
std::string binpath = dir + DIRSEP + name + DIRSEP "Contents" DIRSEP + ARCHSTR + DIRSEP + barename;
foundBinFiles.insert(binpath);
if (_knownBinFiles.find(binpath) == _knownBinFiles.end()) {
#ifdef CACHE_DEBUG
printf("found non-cached binary %s\n", binpath.c_str());
#endif
_dirty = true;
// the binary was not in the cache
PluginBinary *pb = new PluginBinary(binpath, bundlename, this);
_binaries.push_back(pb);
_knownBinFiles.insert(binpath);
for (int j=0;j<pb->getNPlugins();j++) {
Plugin *plug = &pb->getPlugin(j);
const APICache::PluginAPICacheI &api = plug->getApiHandler();
api.loadFromPlugin(plug);
}
} else {
#ifdef CACHE_DEBUG
printf("found cached binary %s\n", binpath.c_str());
#endif
}
} else {
if (isdir && (recurse && name[0] != '@' && name != "." && name != "..")) {
scanDirectory(foundBinFiles, dir + DIRSEP + name, recurse);
}
}
#if defined(WINDOWS)
int rval = FindNextFile(findHandle, &findData);
if (rval == 0) {
break;
}
#endif
}
#if defined(UNIX)
closedir(d);
#else
FindClose(findHandle);
#endif
}
示例5: collapse_edge
IGL_INLINE bool igl::collapse_edge(
const std::function<void(
const int,
const Eigen::MatrixXd &,
const Eigen::MatrixXi &,
const Eigen::MatrixXi &,
const Eigen::VectorXi &,
const Eigen::MatrixXi &,
const Eigen::MatrixXi &,
double &,
Eigen::RowVectorXd &)> & cost_and_placement,
Eigen::MatrixXd & V,
Eigen::MatrixXi & F,
Eigen::MatrixXi & E,
Eigen::VectorXi & EMAP,
Eigen::MatrixXi & EF,
Eigen::MatrixXi & EI,
std::set<std::pair<double,int> > & Q,
std::vector<std::set<std::pair<double,int> >::iterator > & Qit,
Eigen::MatrixXd & C,
int & e,
int & e1,
int & e2,
int & f1,
int & f2)
{
using namespace Eigen;
if(Q.empty())
{
// no edges to collapse
return false;
}
std::pair<double,int> p = *(Q.begin());
if(p.first == std::numeric_limits<double>::infinity())
{
// min cost edge is infinite cost
return false;
}
Q.erase(Q.begin());
e = p.second;
Qit[e] = Q.end();
std::vector<int> N = circulation(e, true,F,E,EMAP,EF,EI);
std::vector<int> Nd = circulation(e,false,F,E,EMAP,EF,EI);
N.insert(N.begin(),Nd.begin(),Nd.end());
const bool collapsed =
collapse_edge(e,C.row(e),V,F,E,EMAP,EF,EI,e1,e2,f1,f2);
if(collapsed)
{
// Erase the two, other collapsed edges
Q.erase(Qit[e1]);
Qit[e1] = Q.end();
Q.erase(Qit[e2]);
Qit[e2] = Q.end();
// update local neighbors
// loop over original face neighbors
for(auto n : N)
{
if(F(n,0) != IGL_COLLAPSE_EDGE_NULL ||
F(n,1) != IGL_COLLAPSE_EDGE_NULL ||
F(n,2) != IGL_COLLAPSE_EDGE_NULL)
{
for(int v = 0; v<3; v++)
{
// get edge id
const int ei = EMAP(v*F.rows()+n);
// erase old entry
Q.erase(Qit[ei]);
// compute cost and potential placement
double cost;
RowVectorXd place;
cost_and_placement(ei,V,F,E,EMAP,EF,EI,cost,place);
// Replace in queue
Qit[ei] = Q.insert(std::pair<double,int>(cost,ei)).first;
C.row(ei) = place;
}
}
}
} else
{
// reinsert with infinite weight (the provided cost function must **not**
// have given this un-collapsable edge inf cost already)
p.first = std::numeric_limits<double>::infinity();
Qit[e] = Q.insert(p).first;
}
return collapsed;
}
示例6: modules_provided
void jsil_languaget::modules_provided(std::set<std::string> &modules)
{
modules.insert(get_base_name(parse_path, true));
}
示例7: updateBucketOpacities
void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>& seenCrossTileIDs) {
if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear();
if (bucket.hasCollisionCircleData()) bucket.collisionCircle.dynamicVertices.clear();
JointOpacityState duplicateOpacityState(false, false, true);
const bool textAllowOverlap = bucket.layout.get<style::TextAllowOverlap>();
const bool iconAllowOverlap = bucket.layout.get<style::IconAllowOverlap>();
// If allow-overlap is true, we can show symbols before placement runs on them
// But we have to wait for placement if we potentially depend on a paired icon/text
// with allow-overlap: false.
// See https://github.com/mapbox/mapbox-gl-native/issues/12483
JointOpacityState defaultOpacityState(
textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || bucket.layout.get<style::IconOptional>()),
iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout.get<style::TextOptional>()),
true);
for (SymbolInstance& symbolInstance : bucket.symbolInstances) {
bool isDuplicate = seenCrossTileIDs.count(symbolInstance.crossTileID) > 0;
auto it = opacities.find(symbolInstance.crossTileID);
auto opacityState = defaultOpacityState;
if (isDuplicate) {
opacityState = duplicateOpacityState;
} else if (it != opacities.end()) {
opacityState = it->second;
}
if (it == opacities.end()) {
opacities.emplace(symbolInstance.crossTileID, defaultOpacityState);
}
seenCrossTileIDs.insert(symbolInstance.crossTileID);
if (symbolInstance.hasText) {
auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.text.placed, opacityState.text.opacity);
for (size_t i = 0; i < symbolInstance.horizontalGlyphQuads.size() * 4; i++) {
bucket.text.opacityVertices.emplace_back(opacityVertex);
}
for (size_t i = 0; i < symbolInstance.verticalGlyphQuads.size() * 4; i++) {
bucket.text.opacityVertices.emplace_back(opacityVertex);
}
if (symbolInstance.placedTextIndex) {
bucket.text.placedSymbols[*symbolInstance.placedTextIndex].hidden = opacityState.isHidden();
}
if (symbolInstance.placedVerticalTextIndex) {
bucket.text.placedSymbols[*symbolInstance.placedVerticalTextIndex].hidden = opacityState.isHidden();
}
}
if (symbolInstance.hasIcon) {
auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.icon.placed, opacityState.icon.opacity);
if (symbolInstance.iconQuad) {
bucket.icon.opacityVertices.emplace_back(opacityVertex);
bucket.icon.opacityVertices.emplace_back(opacityVertex);
bucket.icon.opacityVertices.emplace_back(opacityVertex);
bucket.icon.opacityVertices.emplace_back(opacityVertex);
}
if (symbolInstance.placedIconIndex) {
bucket.icon.placedSymbols[*symbolInstance.placedIconIndex].hidden = opacityState.isHidden();
}
}
auto updateCollisionBox = [&](const auto& feature, const bool placed) {
if (feature.alongLine) {
return;
}
auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, false);
for (size_t i = 0; i < feature.boxes.size() * 4; i++) {
bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
}
};
auto updateCollisionCircles = [&](const auto& feature, const bool placed) {
if (!feature.alongLine) {
return;
}
for (const CollisionBox& box : feature.boxes) {
auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, !box.used);
bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
}
};
if (bucket.hasCollisionBoxData()) {
updateCollisionBox(symbolInstance.textCollisionFeature, opacityState.text.placed);
updateCollisionBox(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
}
if (bucket.hasCollisionCircleData()) {
updateCollisionCircles(symbolInstance.textCollisionFeature, opacityState.text.placed);
updateCollisionCircles(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
}
}
bucket.updateOpacity();
bucket.sortFeatures(state.getAngle());
//.........这里部分代码省略.........
示例8: GetExtensionList
// ------------------------------------------------------------------------------------------------
// Get a list of all file extensions which are handled by this class
void IRRMeshImporter::GetExtensionList(std::set<std::string>& extensions)
{
extensions.insert("xml");
extensions.insert("irrmesh");
}
示例9: addElements
void addElements(const std::set<DataKeyElement>& elements) {
std::unique_lock<std::mutex> lock(m_mutex);
m_elements.insert(elements.begin(), elements.end());
lock.unlock();
}
示例10: RegisterMouseSubscriber
void RegisterMouseSubscriber(MouseListener* actor)
{
_mouseSubscribers.insert(actor);
}
示例11: addElement
void addElement(const DataKeyElement& element) {
std::unique_lock<std::mutex> lock(m_mutex);
m_elements.insert(element);
lock.unlock();
}
示例12: GenerateWaypoints
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
{
if (pathid >= sTaxiPathNodesByPath.size())
return false;
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid];
if (path.empty())
return false;
std::vector<keyFrame> keyFrames;
int mapChange = 0;
mapids.clear();
for (size_t i = 1; i < path.size() - 1; ++i)
{
if (mapChange == 0)
{
if ((path[i].mapid == path[i+1].mapid))
{
keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[i].delay);
keyFrames.push_back(k);
mapids.insert(k.mapid);
}
else
{
mapChange = 1;
}
}
else
{
--mapChange;
}
}
int lastStop = -1;
int firstStop = -1;
// first cell is arrived at by teleportation :S
keyFrames[0].distFromPrev = 0;
if (keyFrames[0].actionflag == 2)
{
lastStop = 0;
}
// find the rest of the distances between key points
for (size_t i = 1; i < keyFrames.size(); ++i)
{
if ((keyFrames[i].actionflag == 1) || (keyFrames[i].mapid != keyFrames[i-1].mapid))
{
keyFrames[i].distFromPrev = 0;
}
else
{
keyFrames[i].distFromPrev =
sqrt(pow(keyFrames[i].x - keyFrames[i - 1].x, 2) +
pow(keyFrames[i].y - keyFrames[i - 1].y, 2) +
pow(keyFrames[i].z - keyFrames[i - 1].z, 2));
}
if (keyFrames[i].actionflag == 2)
{
// remember first stop frame
if (firstStop == -1)
firstStop = i;
lastStop = i;
}
}
float tmpDist = 0;
for (size_t i = 0; i < keyFrames.size(); ++i)
{
int j = (i + lastStop) % keyFrames.size();
if (keyFrames[j].actionflag == 2)
tmpDist = 0;
else
tmpDist += keyFrames[j].distFromPrev;
keyFrames[j].distSinceStop = tmpDist;
}
for (int i = int(keyFrames.size()) - 1; i >= 0; i--)
{
int j = (i + (firstStop+1)) % keyFrames.size();
tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev;
keyFrames[j].distUntilStop = tmpDist;
if (keyFrames[j].actionflag == 2)
tmpDist = 0;
}
for (size_t i = 0; i < keyFrames.size(); ++i)
{
if (keyFrames[i].distSinceStop < (30 * 30 * 0.5f))
keyFrames[i].tFrom = sqrt(2 * keyFrames[i].distSinceStop);
else
keyFrames[i].tFrom = ((keyFrames[i].distSinceStop - (30 * 30 * 0.5f)) / 30) + 30;
if (keyFrames[i].distUntilStop < (30 * 30 * 0.5f))
keyFrames[i].tTo = sqrt(2 * keyFrames[i].distUntilStop);
else
keyFrames[i].tTo = ((keyFrames[i].distUntilStop - (30 * 30 * 0.5f)) / 30) + 30;
keyFrames[i].tFrom *= 1000;
//.........这里部分代码省略.........
示例13: set_insert
void set_insert(std::set<K,C,A>& x, const T& a) {
x.insert(a);
}
示例14: parseFunctionCall
/**
* @brief parse a function call and extract information about variable usage
* @param tok first token
* @param var variables that the function read / write.
* @param value 0 => invalid with null pointers as parameter.
* 1-.. => invalid with uninitialized data.
*/
void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token *> &var, unsigned char value)
{
// standard functions that dereference first parameter..
static std::set<std::string> functionNames1_all;
static std::set<std::string> functionNames1_nullptr;
static std::set<std::string> functionNames1_uninit;
if (functionNames1_all.empty()) {
// cstdlib
functionNames1_all.insert("atoi");
functionNames1_all.insert("atof");
functionNames1_all.insert("atol");
functionNames1_all.insert("qsort");
functionNames1_all.insert("strtod");
functionNames1_all.insert("strtol");
functionNames1_all.insert("strtoul");
// cstring
functionNames1_all.insert("memchr");
functionNames1_all.insert("memcmp");
functionNames1_all.insert("strcat");
functionNames1_all.insert("strncat");
functionNames1_all.insert("strcoll");
functionNames1_all.insert("strchr");
functionNames1_all.insert("strrchr");
functionNames1_all.insert("strcmp");
functionNames1_all.insert("strncmp");
functionNames1_all.insert("strcspn");
functionNames1_all.insert("strdup");
functionNames1_all.insert("strndup");
functionNames1_all.insert("strpbrk");
functionNames1_all.insert("strlen");
functionNames1_all.insert("strspn");
functionNames1_all.insert("strstr");
// cstdio
functionNames1_all.insert("fclose");
functionNames1_all.insert("feof");
functionNames1_all.insert("fwrite");
functionNames1_all.insert("fseek");
functionNames1_all.insert("ftell");
functionNames1_all.insert("fputs");
functionNames1_all.insert("ferror");
functionNames1_all.insert("fgetc");
functionNames1_all.insert("fgetpos");
functionNames1_all.insert("fsetpos");
functionNames1_all.insert("freopen");
functionNames1_all.insert("fscanf");
functionNames1_all.insert("fprintf");
functionNames1_all.insert("fopen");
functionNames1_all.insert("rewind");
functionNames1_all.insert("printf");
functionNames1_all.insert("scanf");
functionNames1_all.insert("fscanf");
functionNames1_all.insert("sscanf");
functionNames1_all.insert("setbuf");
functionNames1_all.insert("setvbuf");
functionNames1_all.insert("rename");
functionNames1_all.insert("remove");
functionNames1_all.insert("puts");
functionNames1_all.insert("getc");
functionNames1_all.insert("clearerr");
// ctime
functionNames1_all.insert("asctime");
functionNames1_all.insert("ctime");
functionNames1_all.insert("mktime");
functionNames1_nullptr.insert("itoa");
functionNames1_nullptr.insert("memcpy");
functionNames1_nullptr.insert("memmove");
functionNames1_nullptr.insert("memset");
functionNames1_nullptr.insert("strcpy");
functionNames1_nullptr.insert("sprintf");
functionNames1_nullptr.insert("vsprintf");
functionNames1_nullptr.insert("vprintf");
functionNames1_nullptr.insert("fprintf");
functionNames1_nullptr.insert("vfprintf");
functionNames1_nullptr.insert("fread");
functionNames1_nullptr.insert("gets");
functionNames1_nullptr.insert("gmtime");
functionNames1_nullptr.insert("localtime");
functionNames1_nullptr.insert("strftime");
functionNames1_uninit.insert("perror");
functionNames1_uninit.insert("fflush");
}
// standard functions that dereference second parameter..
static std::set<std::string> functionNames2_all;
static std::set<std::string> functionNames2_nullptr;
if (functionNames2_all.empty()) {
functionNames2_all.insert("mbstowcs");
functionNames2_all.insert("wcstombs");
functionNames2_all.insert("memcmp");
functionNames2_all.insert("memcpy");
functionNames2_all.insert("memmove");
//.........这里部分代码省略.........
示例15: while
// Look up multiple symbols in the symbol table and return a set of
// Modules that define those symbols.
bool
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
std::set<Module*>& result,
std::string* error) {
if (!mapfile || !base) {
if (error)
*error = "Empty archive invalid for finding modules defining symbols";
return false;
}
if (symTab.empty()) {
// We don't have a symbol table, so we must build it now but lets also
// make sure that we populate the modules table as we do this to ensure
// that we don't load them twice when findModuleDefiningSymbol is called
// below.
// Get a pointer to the first file
const char* At = base + firstFileOffset;
const char* End = mapfile->getBufferEnd();
while ( At < End) {
// Compute the offset to be put in the symbol table
unsigned offset = At - base - firstFileOffset;
// Parse the file's header
ArchiveMember* mbr = parseMemberHeader(At, End, error);
if (!mbr)
return false;
// If it contains symbols
if (mbr->isBitcode()) {
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.str() + "(" +
mbr->getPath().str() + ")";
Module* M =
GetBitcodeSymbols((const unsigned char*)At, mbr->getSize(),
FullMemberName, Context, symbols, error);
if (M) {
// Insert the module's symbols into the symbol table
for (std::vector<std::string>::iterator I = symbols.begin(),
E=symbols.end(); I != E; ++I ) {
symTab.insert(std::make_pair(*I, offset));
}
// Insert the Module and the ArchiveMember into the table of
// modules.
modules.insert(std::make_pair(offset, std::make_pair(M, mbr)));
} else {
if (error)
*error = "Can't parse bitcode member: " +
mbr->getPath().str() + ": " + *error;
delete mbr;
return false;
}
}
// Go to the next file location
At += mbr->getSize();
if ((intptr_t(At) & 1) == 1)
At++;
}
}
// At this point we have a valid symbol table (one way or another) so we
// just use it to quickly find the symbols requested.
for (std::set<std::string>::iterator I=symbols.begin(),
E=symbols.end(); I != E;) {
// See if this symbol exists
Module* m = findModuleDefiningSymbol(*I,error);
if (m) {
// The symbol exists, insert the Module into our result, duplicates will
// be ignored.
result.insert(m);
// Remove the symbol now that its been resolved, being careful to
// post-increment the iterator.
symbols.erase(I++);
} else {
++I;
}
}
return true;
}