本文整理汇总了C++中StringSet::count方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSet::count方法的具体用法?C++ StringSet::count怎么用?C++ StringSet::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet::count方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mustPreserve
static bool mustPreserve(const claimed_file &F, int i) {
if (F.syms[i].resolution == LDPR_PREVAILING_DEF)
return true;
if (F.syms[i].resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
return CannotBeHidden.count(F.syms[i].name);
return false;
}
示例2: match
bool match(StringRef Query) const {
if (Strings.count(Query))
return true;
if (Trigrams.isDefinitelyOut(Query))
return false;
return RegEx && RegEx->match(Query);
}
示例3: filterByName
/// Print only DIEs that have a certain name.
static void filterByName(const StringSet<> &Names,
DWARFContext::cu_iterator_range CUs, raw_ostream &OS) {
for (const auto &CU : CUs)
for (const auto &Entry : CU->dies()) {
DWARFDie Die = {CU.get(), &Entry};
if (const char *NamePtr = Die.getName(DINameKind::ShortName)) {
std::string Name =
(IgnoreCase && !UseRegex) ? StringRef(NamePtr).lower() : NamePtr;
// Match regular expression.
if (UseRegex)
for (auto Pattern : Names.keys()) {
Regex RE(Pattern, IgnoreCase ? Regex::IgnoreCase : Regex::NoFlags);
std::string Error;
if (!RE.isValid(Error)) {
errs() << "error in regular expression: " << Error << "\n";
exit(1);
}
if (RE.match(Name))
Die.dump(OS, 0, getDumpOpts());
}
// Match full text.
else if (Names.count(Name))
Die.dump(OS, 0, getDumpOpts());
}
}
}
示例4: mustPreserve
static bool mustPreserve(ld_plugin_symbol &Sym) {
if (Sym.resolution == LDPR_PREVAILING_DEF)
return true;
if (Sym.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
return CannotBeHidden.count(Sym.name);
return false;
}
示例5: isSubset
static bool isSubset(const StringSet& subset, const StringSet& superset)
{
for (auto e : subset) {
if (superset.count(e) == 0) {
return false;
}
}
return true;
}
示例6: thinLTOInternalizeModule
/// Run internalization on \p TheModule based on symmary analysis.
void llvm::thinLTOInternalizeModule(Module &TheModule,
const GVSummaryMapTy &DefinedGlobals) {
// Parse inline ASM and collect the list of symbols that are not defined in
// the current module.
StringSet<> AsmUndefinedRefs;
ModuleSymbolTable::CollectAsmSymbols(
Triple(TheModule.getTargetTriple()), TheModule.getModuleInlineAsm(),
[&AsmUndefinedRefs](StringRef Name, object::BasicSymbolRef::Flags Flags) {
if (Flags & object::BasicSymbolRef::SF_Undefined)
AsmUndefinedRefs.insert(Name);
});
// Declare a callback for the internalize pass that will ask for every
// candidate GlobalValue if it can be internalized or not.
auto MustPreserveGV = [&](const GlobalValue &GV) -> bool {
// Can't be internalized if referenced in inline asm.
if (AsmUndefinedRefs.count(GV.getName()))
return true;
// Lookup the linkage recorded in the summaries during global analysis.
const auto &GS = DefinedGlobals.find(GV.getGUID());
GlobalValue::LinkageTypes Linkage;
if (GS == DefinedGlobals.end()) {
// Must have been promoted (possibly conservatively). Find original
// name so that we can access the correct summary and see if it can
// be internalized again.
// FIXME: Eventually we should control promotion instead of promoting
// and internalizing again.
StringRef OrigName =
ModuleSummaryIndex::getOriginalNameBeforePromote(GV.getName());
std::string OrigId = GlobalValue::getGlobalIdentifier(
OrigName, GlobalValue::InternalLinkage,
TheModule.getSourceFileName());
const auto &GS = DefinedGlobals.find(GlobalValue::getGUID(OrigId));
if (GS == DefinedGlobals.end()) {
// Also check the original non-promoted non-globalized name. In some
// cases a preempted weak value is linked in as a local copy because
// it is referenced by an alias (IRLinker::linkGlobalValueProto).
// In that case, since it was originally not a local value, it was
// recorded in the index using the original name.
// FIXME: This may not be needed once PR27866 is fixed.
const auto &GS = DefinedGlobals.find(GlobalValue::getGUID(OrigName));
assert(GS != DefinedGlobals.end());
Linkage = GS->second->linkage();
} else {
Linkage = GS->second->linkage();
}
} else
Linkage = GS->second->linkage();
return !GlobalValue::isLocalLinkage(Linkage);
};
// FIXME: See if we can just internalize directly here via linkage changes
// based on the index, rather than invoking internalizeModule.
llvm::internalizeModule(TheModule, MustPreserveGV);
}
示例7: TestNamedMDs
bool ReduceCrashingNamedMD::TestNamedMDs(std::vector<std::string> &NamedMDs) {
ValueToValueMapTy VMap;
Module *M = CloneModule(BD.getProgram(), VMap).release();
outs() << "Checking for crash with only these named metadata nodes:";
unsigned NumPrint = std::min<size_t>(NamedMDs.size(), 10);
for (unsigned i = 0, e = NumPrint; i != e; ++i)
outs() << " " << NamedMDs[i];
if (NumPrint < NamedMDs.size())
outs() << "... <" << NamedMDs.size() << " total>";
outs() << ": ";
// Make a StringMap for faster lookup
StringSet<> Names;
for (const std::string &Name : NamedMDs)
Names.insert(Name);
// First collect all the metadata to delete in a vector, then
// delete them all at once to avoid invalidating the iterator
std::vector<NamedMDNode *> ToDelete;
ToDelete.reserve(M->named_metadata_size() - Names.size());
for (auto &NamedMD : M->named_metadata())
// Always keep a nonempty llvm.dbg.cu because the Verifier would complain.
if (!Names.count(NamedMD.getName()) &&
(!(NamedMD.getName() == "llvm.dbg.cu" && NamedMD.getNumOperands() > 0)))
ToDelete.push_back(&NamedMD);
for (auto *NamedMD : ToDelete)
NamedMD->eraseFromParent();
// Verify that this is still valid.
legacy::PassManager Passes;
Passes.add(createVerifierPass(/*FatalErrors=*/false));
Passes.run(*M);
// Try running on the hacked up program...
if (TestFn(BD, M)) {
BD.setNewProgram(M); // It crashed, keep the trimmed version...
return true;
}
delete M; // It didn't crash, try something else.
return false;
}
示例8: diff
void DifferenceEngine::diff(Module *L, Module *R) {
StringSet<> LNames;
SmallVector<std::pair<Function*,Function*>, 20> Queue;
for (Module::iterator I = L->begin(), E = L->end(); I != E; ++I) {
Function *LFn = &*I;
LNames.insert(LFn->getName());
if (Function *RFn = R->getFunction(LFn->getName()))
Queue.push_back(std::make_pair(LFn, RFn));
else
logf("function %l exists only in left module") << LFn;
}
for (Module::iterator I = R->begin(), E = R->end(); I != E; ++I) {
Function *RFn = &*I;
if (!LNames.count(RFn->getName()))
logf("function %r exists only in right module") << RFn;
}
for (SmallVectorImpl<std::pair<Function*,Function*> >::iterator
I = Queue.begin(), E = Queue.end(); I != E; ++I)
diff(I->first, I->second);
}
示例9: match
bool match(StringRef Query) const {
return Strings.count(Query) || (RegEx && RegEx->match(Query));
}
示例10: isEnabled
bool isEnabled(const std::string& logName) const
{
return enableAll || (enabledLogs.count(logName) != 0);
}
示例11: Parse
//.........这里部分代码省略.........
}
}
else
{
WARN_LOG("Invalid 'slaveof' config.");
}
}
std::string include_dbs, exclude_dbs;
repl_includes.clear();
repl_excludes.clear();
conf_get_string(props, "replicate-include-db", include_dbs);
conf_get_string(props, "replicate-exclude-db", exclude_dbs);
if (0 != split_uint32_array(include_dbs, "|", repl_includes))
{
ERROR_LOG("Invalid 'replicate-include-db' config.");
repl_includes.clear();
}
if (0 != split_uint32_array(exclude_dbs, "|", repl_excludes))
{
ERROR_LOG("Invalid 'replicate-exclude-db' config.");
repl_excludes.clear();
}
if (data_base_path.empty())
{
data_base_path = ".";
}
make_dir(data_base_path);
err = real_path(data_base_path, data_base_path);
if (0 != err)
{
ERROR_LOG("Invalid 'data-dir' config:%s for reason:%s", data_base_path.c_str(), strerror(err));
return false;
}
conf_get_string(props, "additional-misc-info", additional_misc_info);
conf_get_string(props, "requirepass", requirepass);
Properties::const_iterator fit = props.find("rename-command");
if (fit != props.end())
{
rename_commands.clear();
StringSet newcmdset;
const ConfItemsArray& cs = fit->second;
ConfItemsArray::const_iterator cit = cs.begin();
while (cit != cs.end())
{
if (cit->size() != 2 || newcmdset.count(cit->at(1)) > 0)
{
ERROR_LOG("Invalid 'rename-command' config.");
}
else
{
rename_commands[cit->at(0)] = cit->at(1);
newcmdset.insert(cit->at(1));
}
cit++;
}
}
conf_get_int64(props, "compact-min-interval", compact_min_interval);
conf_get_int64(props, "compact-max-interval", compact_max_interval);
conf_get_int64(props, "compact-after-write", compact_trigger_write_count);
conf_get_bool(props, "compact-enable", compact_enable);
conf_get_int64(props, "reply-pool-size", reply_pool_size);
conf_get_bool(props, "replace-all-for-multi-sadd", replace_for_multi_sadd);
conf_get_bool(props, "replace-all-for-hmset", replace_for_hmset);
conf_get_int64(props, "slave-client-output-buffer-limit", slave_client_output_buffer_limit);
conf_get_int64(props, "pubsub-client-output-buffer-limit", pubsub_client_output_buffer_limit);
conf_get_bool(props, "scan-redis-compatible", scan_redis_compatible);
conf_get_int64(props, "scan-cursor-expire-after", scan_cursor_expire_after);
conf_get_int64(props, "max-string-bitset-value", max_string_bitset_value);
conf_get_int64(props, "databases", maxdb);
conf_get_bool(props, "lua-exec-atomic", lua_exec_atomic);
trusted_ip.clear();
Properties::const_iterator ip_it = props.find("trusted-ip");
if (ip_it != props.end())
{
const ConfItemsArray& cs = ip_it->second;
for (uint32 i = 0; i < cs.size(); i++)
{
trusted_ip.insert(cs[i][0]);
}
}
if (!verify_config(*this))
{
return false;
}
ArdbLogger::SetLogLevel(loglevel);
return true;
}
示例12: convertParametersToRegisters
static void convertParametersToRegisters(
const BasicBlockMap& newBlocks, ir::IRKernel& kernel,
ir::ControlFlowGraph::instruction_iterator callIterator,
const ir::IRKernel& calledKernel)
{
typedef std::unordered_map<std::string, ir::PTXOperand> OperandMap;
typedef std::unordered_set<std::string> StringSet;
reportE(REPORT_DETAILS, " Converting parameters to registers...");
// Get a map from argument name to register in the calling function
OperandMap argumentMap;
StringSet bitBucketArguments;
auto argument = calledKernel.arguments.begin();
ir::PTXInstruction& call = static_cast<ir::PTXInstruction&>(**callIterator);
for(auto parameter = call.d.array.begin();
parameter != call.d.array.end(); ++parameter, ++argument)
{
if(parameter->addressMode == ir::PTXOperand::BitBucket)
{
bitBucketArguments.insert(argument->name);
continue;
}
assert(argument != calledKernel.arguments.end());
assert(parameter->addressMode == ir::PTXOperand::Register ||
parameter->addressMode == ir::PTXOperand::Immediate);
assert(argumentMap.count(argument->name) == 0);
assert(argument->returnArgument);
argumentMap.insert(std::make_pair(argument->name, *parameter));
}
for(auto parameter = call.b.array.begin();
parameter != call.b.array.end(); ++parameter, ++argument)
{
if(parameter->addressMode == ir::PTXOperand::BitBucket)
{
bitBucketArguments.insert(argument->name);
continue;
}
assert(argument != calledKernel.arguments.end());
assert(parameter->addressMode == ir::PTXOperand::Register ||
parameter->addressMode == ir::PTXOperand::Immediate);
assert(argumentMap.count(argument->name) == 0);
assert(!argument->returnArgument);
argumentMap.insert(std::make_pair(argument->name, *parameter));
}
// Convert all stores to that parameter to moves to the associated register
for(auto block = newBlocks.begin(); block != newBlocks.end(); ++block)
{
for(auto instruction = block->second->instructions.begin();
instruction != block->second->instructions.end(); ++instruction)
{
ir::PTXInstruction& ptx = static_cast<ir::PTXInstruction&>(
**instruction);
if(ptx.opcode != ir::PTXInstruction::St) continue;
if(ptx.addressSpace != ir::PTXInstruction::Param) continue;
if(ptx.d.addressMode != ir::PTXOperand::Address) continue;
if(bitBucketArguments.count(ptx.d.identifier))
{
delete *instruction;
instruction = --block->second->instructions.erase(instruction);
continue;
}
auto argument = argumentMap.find(ptx.d.identifier);
if(argument == argumentMap.end()) continue;
ptx.type = argument->second.type;
ptx.pg = call.pg;
ptx.d = argument->second;
if(argument->second.addressMode == ir::PTXOperand::Register)
{
// If the types match, it is a move
if(argument->second.type == ptx.d.type)
{
ptx.opcode = ir::PTXInstruction::Mov;
}
else
{
// otherwise, we need a cast
ptx.opcode = ir::PTXInstruction::Cvt;
ptx.modifier = ir::PTXInstruction::Modifier_invalid;
}
}
else
{
assert(argument->second.addressMode ==
//.........这里部分代码省略.........
示例13: initializeSharedMemory
void ATIExecutableKernel::initializeSharedMemory()
{
report("Allocating shared memory");
typedef std::unordered_map<std::string, size_t> AllocationMap;
typedef std::unordered_set<std::string> StringSet;
typedef std::deque<ir::PTXOperand*> OperandVector;
typedef std::unordered_map<std::string,
ir::Module::GlobalMap::const_iterator> GlobalMap;
AllocationMap map;
GlobalMap sharedGlobals;
StringSet external;
OperandVector externalOperands;
unsigned int externalAlignment = 1;
size_t sharedSize = 0;
assert(module != 0);
// global shared variables
ir::Module::GlobalMap globals = module->globals();
ir::Module::GlobalMap::const_iterator global;
for (global = globals.begin() ; global != globals.end() ; global++)
{
ir::PTXStatement statement = global->second.statement;
if (statement.directive == ir::PTXStatement::Shared)
{
if (statement.attribute == ir::PTXStatement::Extern)
{
report("Found global external shared variable \""
<< statement.name << "\"");
assertM(external.count(statement.name) == 0,
"External global \"" << statement.name
<< "\" declared more than once.");
external.insert(statement.name);
externalAlignment = std::max(externalAlignment,
(unsigned int)statement.alignment);
externalAlignment = std::max(externalAlignment,
ir::PTXOperand::bytes(statement.type));
} else {
report("Found global shared variable \""
<< statement.name << "\"");
sharedGlobals.insert(
std::make_pair(statement.name, global));
}
}
}
// local shared variables
LocalMap::const_iterator local;
for (local = locals.begin() ; local != locals.end() ; local++)
{
if (local->second.space == ir::PTXInstruction::Shared)
{
if (local->second.attribute == ir::PTXStatement::Extern)
{
report("Found local external shared variable \""
<< local->second.name << "\"");
assertM(external.count(local->second.name) == 0,
"External local \"" << local->second.name
<< "\" declared more than once.");
external.insert(local->second.name);
externalAlignment = std::max(externalAlignment,
(unsigned int)local->second.alignment);
externalAlignment = std::max(externalAlignment,
ir::PTXOperand::bytes(local->second.type));
} else
{
report("Allocating local shared variable \""
<< local->second.name << "\" of size "
<< local->second.getSize());
_pad(sharedSize, local->second.alignment);
map.insert(std::make_pair(local->second.name, sharedSize));
sharedSize += local->second.getSize();
}
}
}
ir::ControlFlowGraph::iterator block;
for (block = cfg()->begin() ; block != cfg()->end() ; block++)
{
ir::ControlFlowGraph::InstructionList insts = block->instructions;
ir::ControlFlowGraph::InstructionList::iterator inst;
for (inst = insts.begin() ; inst != insts.end() ; inst++)
{
ir::PTXInstruction& ptx =
static_cast<ir::PTXInstruction&>(**inst);
if (ptx.opcode == ir::PTXInstruction::Mov ||
ptx.opcode == ir::PTXInstruction::Ld ||
ptx.opcode == ir::PTXInstruction::St)
{
ir::PTXOperand* operands[] = {&ptx.d, &ptx.a, &ptx.b,
&ptx.c};
//.........这里部分代码省略.........