本文整理汇总了C++中std::set::end方法的典型用法代码示例。如果您正苦于以下问题:C++ set::end方法的具体用法?C++ set::end怎么用?C++ set::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::set
的用法示例。
在下文中一共展示了set::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSameExpression
bool isSameExpression(bool cpp, const Token *tok1, const Token *tok2, const std::set<std::string> &constFunctions)
{
if (tok1 == nullptr && tok2 == nullptr)
return true;
if (tok1 == nullptr || tok2 == nullptr)
return false;
if (cpp) {
if (tok1->str() == "." && tok1->astOperand1() && tok1->astOperand1()->str() == "this")
tok1 = tok1->astOperand2();
if (tok2->str() == "." && tok2->astOperand1() && tok2->astOperand1()->str() == "this")
tok2 = tok2->astOperand2();
}
if (tok1->varId() != tok2->varId() || tok1->str() != tok2->str()) {
if ((Token::Match(tok1,"<|>") && Token::Match(tok2,"<|>")) ||
(Token::Match(tok1,"<=|>=") && Token::Match(tok2,"<=|>="))) {
return isSameExpression(cpp, tok1->astOperand1(), tok2->astOperand2(), constFunctions) &&
isSameExpression(cpp, tok1->astOperand2(), tok2->astOperand1(), constFunctions);
}
return false;
}
if (tok1->str() == "." && tok1->originalName() != tok2->originalName())
return false;
if (tok1->isExpandedMacro() || tok2->isExpandedMacro())
return false;
if (tok1->isName() && tok1->next()->str() == "(" && tok1->str() != "sizeof") {
if (!tok1->function() && !Token::Match(tok1->previous(), ".|::") && constFunctions.find(tok1->str()) == constFunctions.end() && !tok1->isAttributeConst() && !tok1->isAttributePure())
return false;
else if (tok1->function() && !tok1->function()->isConst() && !tok1->function()->isAttributeConst() && !tok1->function()->isAttributePure())
return false;
}
// templates/casts
if ((Token::Match(tok1, "%name% <") && tok1->next()->link()) ||
(Token::Match(tok2, "%name% <") && tok2->next()->link())) {
// non-const template function that is not a dynamic_cast => return false
if (Token::simpleMatch(tok1->next()->link(), "> (") &&
!(tok1->function() && tok1->function()->isConst()) &&
tok1->str() != "dynamic_cast")
return false;
// some template/cast stuff.. check that the template arguments are same
const Token *t1 = tok1->next();
const Token *t2 = tok2->next();
const Token *end1 = t1->link();
const Token *end2 = t2->link();
while (t1 && t2 && t1 != end1 && t2 != end2) {
if (t1->str() != t2->str())
return false;
t1 = t1->next();
t2 = t2->next();
}
if (t1 != end1 || t2 != end2)
return false;
}
if (tok1->tokType() == Token::eIncDecOp || tok1->isAssignmentOp())
return false;
// bailout when we see ({..})
if (tok1->str() == "{")
return false;
if (tok1->str() == "(" && tok1->previous() && !tok1->previous()->isName()) { // cast => assert that the casts are equal
const Token *t1 = tok1->next();
const Token *t2 = tok2->next();
while (t1 && t2 && t1->str() == t2->str() && (t1->isName() || t1->str() == "*")) {
t1 = t1->next();
t2 = t2->next();
}
if (!t1 || !t2 || t1->str() != ")" || t2->str() != ")")
return false;
}
bool noncommuative_equals =
isSameExpression(cpp, tok1->astOperand1(), tok2->astOperand1(), constFunctions);
noncommuative_equals = noncommuative_equals &&
isSameExpression(cpp, tok1->astOperand2(), tok2->astOperand2(), constFunctions);
if (noncommuative_equals)
return true;
const bool commutative = tok1->astOperand1() && tok1->astOperand2() && Token::Match(tok1, "%or%|%oror%|+|*|&|&&|^|==|!=");
bool commuative_equals = commutative &&
isSameExpression(cpp, tok1->astOperand2(), tok2->astOperand1(), constFunctions);
commuative_equals = commuative_equals &&
isSameExpression(cpp, tok1->astOperand1(), tok2->astOperand2(), constFunctions);
// in c++, "a"+b might be different to b+"a"
if (cpp && commuative_equals && tok1->str() == "+" &&
(tok1->astOperand1()->tokType() == Token::eString || tok1->astOperand2()->tokType() == Token::eString)) {
const Token * const other = tok1->astOperand1()->tokType() != Token::eString ? tok1->astOperand1() : tok1->astOperand2();
return other && astIsIntegral(other,false);
}
return commuative_equals;
}
示例2: generate_sql_makefile
bool generate_sql_makefile()
{
if (new_sql_updates.empty()) return true;
// find all files in the update dir
snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir);
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
char newname[MAX_PATH];
std::set<std::string> file_list;
sql_update_info info;
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if (buffer[strlen(buffer) - 1] != '/' &&
strncmp(buffer, "Makefile.am", MAX_BUF) != 0)
{
if (new_sql_updates.find(buffer) != new_sql_updates.end())
{
if (!get_sql_update_info(buffer, info)) return false;
snprintf(newname, MAX_PATH, REV_PRINT "_%s_%0*d_%s%s%s.sql", rev, info.parentRev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table);
file_list.insert(newname);
}
else
file_list.insert(buffer);
}
}
pclose(cmd_pipe);
// write the makefile
char file_name[MAX_PATH];
snprintf(file_name, MAX_PATH, "%s%s/Makefile.am", path_prefix, sql_update_dir);
FILE* fout = fopen(file_name, "w");
if (!fout) { pclose(cmd_pipe); return false; }
fprintf(fout,
"# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.\n"
"#\n"
"# This program is free software; you can redistribute it and/or modify\n"
"# it under the terms of the GNU General Public License as published by\n"
"# the Free Software Foundation; either version 2 of the License, or\n"
"# (at your option) any later version.\n"
"#\n"
"# This program is distributed in the hope that it will be useful,\n"
"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"# GNU General Public License for more details.\n"
"#\n"
"# You should have received a copy of the GNU General Public License\n"
"# along with this program; if not, write to the Free Software\n"
"# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
"\n"
"## Process this file with automake to produce Makefile.in\n"
"\n"
"## Sub-directories to parse\n"
"SUBDIRS = before_upgrade_to_0.13\n"
"\n"
"## Change installation location\n"
"# datadir = mangos/%s\n"
"pkgdatadir = $(datadir)/mangos/%s\n"
"\n"
"## Files to be installed\n"
"# Install basic SQL files to datadir\n"
"pkgdata_DATA = \\\n",
sql_update_dir, sql_update_dir
);
for(std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr)
{
next = itr; ++next;
fprintf(fout, "\t%s%s\n", itr->c_str(), next == file_list.end() ? "" : " \\");
}
fprintf(fout,
"\n## Additional files to include when running 'make dist'\n"
"# SQL update files, to upgrade database schema from older revisions\n"
"EXTRA_DIST = \\\n"
);
for (std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr)
{
next = itr; ++next;
fprintf(fout, "\t%s%s\n", itr->c_str(), next == file_list.end() ? "" : " \\");
}
fclose(fout);
snprintf(cmd, MAX_CMD, "git add %s%s/Makefile.am", path_prefix, sql_update_dir);
system_switch_index(cmd);
return true;
}
示例3: isBpFunction
bool isBpFunction(const char* nm) const {
std::set<string>::const_iterator i = enabledFunctions.find(string(nm));
return i != enabledFunctions.end();
}
示例4: SetData
void SetData(uint32 type, uint32 data)
{
switch (type)
{
case DATA_MAGTHERIDON_EVENT:
m_auiEncounter[0] = data;
if (data == NOT_STARTED)
RespawnTimer = 10000;
if (data != IN_PROGRESS)
HandleGameObject(DoorGUID, true);
break;
case DATA_CHANNELER_EVENT:
switch (data)
{
case NOT_STARTED: // Reset all channelers once one is reset.
if (m_auiEncounter[1] != NOT_STARTED)
{
m_auiEncounter[1] = NOT_STARTED;
for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
if (Creature* Channeler = instance->GetCreature(*i))
{
if (Channeler->IsAlive())
Channeler->AI()->EnterEvadeMode();
else
Channeler->Respawn();
}
}
CageTimer = 0;
HandleGameObject(DoorGUID, true);
}
break;
case IN_PROGRESS: // Event start.
if (m_auiEncounter[1] != IN_PROGRESS)
{
m_auiEncounter[1] = IN_PROGRESS;
// Let all five channelers aggro.
for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
Creature* Channeler = instance->GetCreature(*i);
if (Channeler && Channeler->IsAlive())
Channeler->AI()->AttackStart(Channeler->SelectNearestTarget(999));
}
// Release Magtheridon after two minutes.
Creature* Magtheridon = instance->GetCreature(MagtheridonGUID);
if (Magtheridon && Magtheridon->IsAlive())
{
Magtheridon->MonsterTextEmote(EMOTE_BONDS_WEAKEN, 0);
CageTimer = 120000;
}
HandleGameObject(DoorGUID, false);
}
break;
case DONE: // Add buff and check if all channelers are dead.
for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
Creature* Channeler = instance->GetCreature(*i);
if (Channeler && Channeler->IsAlive())
{
//Channeler->CastSpell(Channeler, SPELL_SOUL_TRANSFER, true);
data = IN_PROGRESS;
break;
}
}
break;
}
m_auiEncounter[1] = data;
break;
case DATA_COLLAPSE:
// true - collapse / false - reset
for (std::set<uint64>::const_iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
DoUseDoorOrButton(*i);
break;
default:
break;
}
}
示例5: find_sql_updates
bool find_sql_updates()
{
printf("+ finding new sql updates on HEAD\n");
// add all updates from HEAD
snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir);
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
sql_update_info info;
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if (!get_sql_update_info(buffer, info)) continue;
if (info.db_idx == NUM_DATABASES)
{
if (info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer);
continue;
}
new_sql_updates.insert(buffer);
}
pclose(cmd_pipe);
// Add last milestone's file information
last_sql_rev[0] = 11785;
last_sql_nr[0] = 2;
sscanf("11785_02_characters_instance", "%s", last_sql_update[0]);
last_sql_rev[2] = 10008;
last_sql_nr[2] = 1;
sscanf("10008_01_realmd_realmd_db_version", "%s", last_sql_update[2]);
// remove updates from the last commit also found on origin
snprintf(cmd, MAX_CMD, "git show %s:%s", origin_hash, sql_update_dir);
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if (!get_sql_update_info(buffer, info)) continue;
// find the old update with the highest rev for each database
// (will be the required version for the new update)
std::set<std::string>::iterator itr = new_sql_updates.find(buffer);
if (itr != new_sql_updates.end())
{
if (info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] ||
(info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx])))
{
last_sql_rev[info.db_idx] = info.rev;
last_sql_nr[info.db_idx] = info.nr;
if (db_sql_rev_parent[info.db_idx])
snprintf(last_sql_update[info.db_idx], MAX_PATH, "%s_%0*d_%s%s%s", info.parentRev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table);
else
sscanf(buffer, "%[^.]", last_sql_update[info.db_idx]);
}
new_sql_updates.erase(itr);
}
}
pclose(cmd_pipe);
if (!new_sql_updates.empty())
{
for (std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr)
printf("%s\n", itr->c_str());
}
else
printf("WARNING: no new sql updates found.\n");
return true;
}
示例6: isPresent
bool isPresent(const T *value, const std::set<const T *> &values) {
auto result = std::find(values.begin(), values.end(), value);
return result != values.end();
}
示例7: instrument_minimum_interference_inserter
void inline instrumentert::instrument_minimum_interference_inserter(
const std::set<event_grapht::critical_cyclet>& set_of_cycles)
{
/* Idea:
We solve this by a linear programming approach,
using for instance glpk lib.
Input: the edges to instrument E, the cycles C_j
Pb: min sum_{e_i in E} d(e_i).x_i
s.t. for all j, sum_{e_i in C_j} >= 1,
where e_i is a pair to potentially instrument,
x_i is a Boolean stating whether we instrument
e_i, and d() is the cost of an instrumentation.
Output: the x_i, saying which pairs to instrument
For this instrumentation, we propose:
d(poW*)=1
d(poRW)=d(rfe)=2
d(poRR)=3
This function can be refined with the actual times
we get in experimenting the different pairs in a
single IRIW.
*/
#ifdef HAVE_GLPK
/* first, identify all the unsafe pairs */
std::set<event_grapht::critical_cyclet::delayt> edges;
for(std::set<event_grapht::critical_cyclet>::iterator
C_j=set_of_cycles.begin();
C_j!=set_of_cycles.end();
++C_j)
for(std::set<event_grapht::critical_cyclet::delayt>::const_iterator e_i=
C_j->unsafe_pairs.begin();
e_i!=C_j->unsafe_pairs.end();
++e_i)
edges.insert(*e_i);
glp_prob* lp;
glp_iocp parm;
glp_init_iocp(&parm);
parm.msg_lev=GLP_MSG_OFF;
parm.presolve=GLP_ON;
lp=glp_create_prob();
glp_set_prob_name(lp, "instrumentation optimisation");
glp_set_obj_dir(lp, GLP_MIN);
message.debug() << "edges: "<<edges.size()<<" cycles:"<<set_of_cycles.size()
<< messaget::eom;
/* sets the variables and coefficients */
glp_add_cols(lp, edges.size());
std::size_t i=0;
for(std::set<event_grapht::critical_cyclet::delayt>::iterator
e_i=edges.begin();
e_i!=edges.end();
++e_i)
{
++i;
std::string name="e_"+std::to_string(i);
glp_set_col_name(lp, i, name.c_str());
glp_set_col_bnds(lp, i, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, i, cost(*e_i));
glp_set_col_kind(lp, i, GLP_BV);
}
/* sets the constraints (soundness): one per cycle */
glp_add_rows(lp, set_of_cycles.size());
i=0;
for(std::set<event_grapht::critical_cyclet>::iterator
C_j=set_of_cycles.begin();
C_j!=set_of_cycles.end();
++C_j)
{
++i;
std::string name="C_"+std::to_string(i);
glp_set_row_name(lp, i, name.c_str());
glp_set_row_bnds(lp, i, GLP_LO, 1.0, 0.0); /* >= 1*/
}
const std::size_t mat_size=set_of_cycles.size()*edges.size();
message.debug() << "size of the system: " << mat_size
<< messaget::eom;
int* imat=(int*)malloc(sizeof(int)*(mat_size+1));
int* jmat=(int*)malloc(sizeof(int)*(mat_size+1));
double* vmat=(double*)malloc(sizeof(double)*(mat_size+1));
/* fills the constraints coeff */
/* tables read from 1 in glpk -- first row/column ignored */
std::size_t col=1;
std::size_t row=1;
i=1;
for(std::set<event_grapht::critical_cyclet::delayt>::iterator
e_i=edges.begin();
e_i!=edges.end();
++e_i)
{
row=1;
for(std::set<event_grapht::critical_cyclet>::iterator
//.........这里部分代码省略.........
示例8: identifyOutSet
bool BlockFlow::identifyOutSet()
{
bool MadeChange = false;
std::vector<GlobalCheck*> outChecks;
if (!isEntry && !killAll) {
identifyInSet();
#if DEBUG_GLOBAL
errs() << "Generating Out-Set: " << blk->getName() << "\n";
#endif
// Identify checks from inSet that should be killed
for (std::vector<GlobalCheck*>::iterator i = inSet.checks.begin(), e = inSet.checks.end();
i != e; i++) {
// For each global check, see if it survives past block, or if we can tell how variable changes
GlobalCheck *chk = *i;
std::set<Value*>::iterator it = storeSet.find(chk->var);
if (it == storeSet.end()) {
outChecks.push_back(chk);
} else {
ConstraintGraph::CompareEnum change = cg->identifyMemoryChange(chk->var);
if (chk->isUpper) {
// Upper-bound check
switch (change) {
case ConstraintGraph::EQUALS:
case ConstraintGraph::LESS_THAN:
outChecks.push_back(chk);
break;
default:
break;
}
} else {
// Lower-bound check
switch (change) {
case ConstraintGraph::EQUALS:
case ConstraintGraph::GREATER_THAN:
outChecks.push_back(chk);
break;
default:
break;
}
}
}
}
}
#if DEBUG_GLOBAL
else {
errs() << "Generating Out-Set: " << blk->getName() << "\n";
}
#endif
// Just identify checks that are live at the end of set
for (std::vector<GlobalCheck*>::iterator i = globalChecks.begin(), e = globalChecks.end();
i != e; i++) {
GlobalCheck *chk = *i;
bool add = true;
for (unsigned int o = 0; o < outChecks.size(); o++) {
GlobalCheck *oCheck = outChecks.at(o);
ConstantInt *const1 = dyn_cast<ConstantInt>(chk->var);
ConstantInt *const2 = dyn_cast<ConstantInt>(oCheck->var);
if (chk->isUpper && oCheck->isUpper) {
// Both upper bounds checks
if (const1 != NULL && const2 != NULL) {
// If both constants, replace with the more strict version
if (const1->getSExtValue() > const2->getSExtValue()) {
outChecks.at(o) = chk;
}
add = false;
break;
} else if (const1 == NULL && const2 == NULL) {
if (chk->var == oCheck->var) {
ConstantInt *bound1 = dyn_cast<ConstantInt>(chk->bound);
ConstantInt *bound2 = dyn_cast<ConstantInt>(oCheck->bound);
if (bound1 != NULL && bound2 != NULL) {
if (bound1->getZExtValue() < bound2->getZExtValue()) {
outChecks.at(o) = chk;
}
add = false;
break;
} else if (bound1 == NULL && bound2 == NULL) {
if (bound1 == bound2) {
add = false;
break;
}
}
}
}
} else if (!chk->isUpper && !oCheck->isUpper) {
// Both lower bounds checks
if (const1 != NULL && const2 != NULL) {
// If both constants, replace with the more strict version
if (const1->getSExtValue() < const2->getSExtValue()) {
outChecks.at(o) = chk;
}
add = false;
break;
} else if (const1 == NULL && const2 == NULL) {
if (chk->var == oCheck->var) {
add = false;
break;
}
}
}
//.........这里部分代码省略.........
示例9: version
void
FindFilesOnVol(const std::string &verref,
const std::set<std::string> &volset,
SeenVers &seen,
RebuildVers &found,
RebuildNode::CurrentStack ¤tStack,
int &count, int interval)
{
if (seen.find(verref) != seen.end()) {
seen[verref]->AddUser(currentStack);
return;
}
AssetVersion version(verref);
if (!version) {
notify(NFY_WARN, "Unable to load asset version %s",
version.Ref().c_str());
}
RebuildNode *node = new RebuildNode(verref, currentStack);
CurrentStackGuard stackGuard(currentStack, node);
seen.insert(make_pair(verref, node));
if (interval && (++count % interval == 0)) {
fprintf(stderr, "\r%d", count);
}
if (version->IsLeaf() && (version->state == AssetDefs::Succeeded)) {
std::vector<std::string> outfiles;
version->GetOutputFilenames(outfiles);
for (std::vector<std::string>::const_iterator outfile =
outfiles.begin(); outfile != outfiles.end(); ++outfile) {
khFusionURI uri(theVolumeManager.DeduceURIFromPath(*outfile));
if (uri.Volume().empty()) {
// non-file outfile (GFS?). Do nothing.
} else if (volset.find(uri.Volume()) != volset.end()) {
// This outfile is on a volume we care about. Remember the
// versionref.
node->rebuild = true;
found.insert(node);
// once we find even one outfile, we're done. We'll have to run
// the whole command anyway. No sense checking other outfiles.
break;
} else {
// On a volume we don't care about. Do Nothing
}
}
}
for (std::vector<std::string>::const_iterator input =
version->inputs.begin();
input != version->inputs.end(); ++input) {
FindFilesOnVol(*input, volset, seen,
found, currentStack,
count, interval);
}
if (!version->IsLeaf()) {
for (std::vector<std::string>::const_iterator child =
version->children.begin();
child != version->children.end(); ++child) {
FindFilesOnVol(*child, volset, seen,
found, currentStack,
count, interval);
}
}
}
示例10: check_out
void check_out(void * const This)
{
BOOST_TEST(objs.find(This) != objs.end());
objs.erase(This);
}
示例11: free
static void free(char * const block)
{
BOOST_TEST(allocated_blocks.find(block) != allocated_blocks.end());
allocated_blocks.erase(block);
UserAllocator::free(block);
}
示例12: check_in
void check_in(void * const This)
{
BOOST_TEST(objs.find(This) == objs.end());
objs.insert(This);
}
示例13: SetData
void SetData(uint32 type, uint32 data)
{
switch (type)
{
case TYPE_MOGRAINE_AND_WHITE_EVENT:
if (data == IN_PROGRESS)
DoUseDoorOrButton(DoorHighInquisitorGUID);
if (data == FAIL)
DoUseDoorOrButton(DoorHighInquisitorGUID);
Encounter[0] = data;
break;
case GAMEOBJECT_PUMPKIN_SHRINE:
HandleGameObject(PumpkinShrineGUID, false);
break;
case DATA_HORSEMAN_EVENT:
Encounter[1] = data;
if (data == DONE)
{
for (std::set<uint64>::const_iterator itr = HorsemanAdds.begin(); itr != HorsemanAdds.end(); ++itr)
{
Creature* add = instance->GetCreature(*itr);
if (add && add->isAlive())
add->Kill(add);
}
HorsemanAdds.clear();
HandleGameObject(PumpkinShrineGUID, false);
}
break;
}
}
示例14: isConstExpression
bool isConstExpression(const Token *tok, const std::set<std::string> &constFunctions)
{
if (!tok)
return true;
if (tok->isName() && tok->next()->str() == "(") {
if (!tok->function() && !Token::Match(tok->previous(), ".|::") && constFunctions.find(tok->str()) == constFunctions.end())
return false;
else if (tok->function() && !tok->function()->isConst())
return false;
}
if (tok->tokType() == Token::eIncDecOp)
return false;
// bailout when we see ({..})
if (tok->str() == "{")
return false;
return isConstExpression(tok->astOperand1(),constFunctions) && isConstExpression(tok->astOperand2(),constFunctions);
}
示例15: if
/// Based on GetAllUndefinedSymbols() from LLVM3.2
///
/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
/// exist in an LLVM module. This is a bit tricky because there may be two
/// symbols with the same name but different LLVM types that will be resolved to
/// each other but aren't currently (thus we need to treat it as resolved).
///
/// Inputs:
/// M - The module in which to find undefined symbols.
///
/// Outputs:
/// UndefinedSymbols - A set of C++ strings containing the name of all
/// undefined symbols.
///
static void
GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
static const std::string llvmIntrinsicPrefix="llvm.";
std::set<std::string> DefinedSymbols;
UndefinedSymbols.clear();
KLEE_DEBUG_WITH_TYPE("klee_linker",
dbgs() << "*** Computing undefined symbols ***\n");
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (I->hasName()) {
if (I->isDeclaration())
UndefinedSymbols.insert(I->getName());
else if (!I->hasLocalLinkage()) {
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!");
#else
assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
#endif
DefinedSymbols.insert(I->getName());
}
}
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
if (I->hasName()) {
if (I->isDeclaration())
UndefinedSymbols.insert(I->getName());
else if (!I->hasLocalLinkage()) {
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!");
#else
assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
#endif
DefinedSymbols.insert(I->getName());
}
}
for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
I != E; ++I)
if (I->hasName())
DefinedSymbols.insert(I->getName());
// Prune out any defined symbols from the undefined symbols set
// and other symbols we don't want to treat as an undefined symbol
std::vector<std::string> SymbolsToRemove;
for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
I != UndefinedSymbols.end(); ++I )
{
if (DefinedSymbols.count(*I))
{
SymbolsToRemove.push_back(*I);
continue;
}
// Strip out llvm intrinsics
if ( (I->size() >= llvmIntrinsicPrefix.size() ) &&
(I->compare(0, llvmIntrinsicPrefix.size(), llvmIntrinsicPrefix) == 0) )
{
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "LLVM intrinsic " << *I <<
" has will be removed from undefined symbols"<< "\n");
SymbolsToRemove.push_back(*I);
continue;
}
// Symbol really is undefined
KLEE_DEBUG_WITH_TYPE("klee_linker",
dbgs() << "Symbol " << *I << " is undefined.\n");
}
// Remove KLEE intrinsics from set of undefined symbols
for (SpecialFunctionHandler::const_iterator sf = SpecialFunctionHandler::begin(),
se = SpecialFunctionHandler::end(); sf != se; ++sf)
{
if (UndefinedSymbols.find(sf->name) == UndefinedSymbols.end())
continue;
SymbolsToRemove.push_back(sf->name);
KLEE_DEBUG_WITH_TYPE("klee_linker",
dbgs() << "KLEE intrinsic " << sf->name <<
" has will be removed from undefined symbols"<< "\n");
}
// Now remove the symbols from undefined set.
for (size_t i = 0, j = SymbolsToRemove.size(); i < j; ++i )
UndefinedSymbols.erase(SymbolsToRemove[i]);
//.........这里部分代码省略.........