本文整理汇总了C++中llvm::SmallPtrSetImpl::count方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallPtrSetImpl::count方法的具体用法?C++ SmallPtrSetImpl::count怎么用?C++ SmallPtrSetImpl::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::SmallPtrSetImpl
的用法示例。
在下文中一共展示了SmallPtrSetImpl::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: successorHasLiveIn
// Is any successor of BB in the LiveIn set?
static bool successorHasLiveIn(SILBasicBlock *BB,
llvm::SmallPtrSetImpl<SILBasicBlock *> &LiveIn) {
for (auto &Succ : BB->getSuccessors())
if (LiveIn.count(Succ))
return true;
return false;
}
示例2: removeModules
void ModuleManager::removeModules(
ModuleIterator first, ModuleIterator last,
llvm::SmallPtrSetImpl<ModuleFile *> &LoadedSuccessfully,
ModuleMap *modMap) {
if (first == last)
return;
// Collect the set of module file pointers that we'll be removing.
llvm::SmallPtrSet<ModuleFile *, 4> victimSet(first, last);
auto IsVictim = [&](ModuleFile *MF) {
return victimSet.count(MF);
};
// Remove any references to the now-destroyed modules.
for (unsigned i = 0, n = Chain.size(); i != n; ++i) {
Chain[i]->ImportedBy.remove_if(IsVictim);
}
Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim),
Roots.end());
// Delete the modules and erase them from the various structures.
for (ModuleIterator victim = first; victim != last; ++victim) {
Modules.erase((*victim)->File);
if (modMap) {
StringRef ModuleName = (*victim)->ModuleName;
if (Module *mod = modMap->findModule(ModuleName)) {
mod->setASTFile(nullptr);
}
}
// Files that didn't make it through ReadASTCore successfully will be
// rebuilt (or there was an error). Invalidate them so that we can load the
// new files that will be renamed over the old ones.
if (LoadedSuccessfully.count(*victim) == 0)
FileMgr.invalidateCache((*victim)->File);
delete *victim;
}
// Remove the modules from the chain.
Chain.erase(first, last);
}
示例3: diagnoseUnreachableBlock
/// \brief Issue an "unreachable code" diagnostic if the blocks contains or
/// leads to another block that contains user code.
///
/// Note, we rely on SILLocation information to determine if SILInstructions
/// correspond to user code.
static bool diagnoseUnreachableBlock(const SILBasicBlock &B,
SILModule &M,
const SILBasicBlockSet &Reachable,
UnreachableUserCodeReportingState *State,
const SILBasicBlock *TopLevelB,
llvm::SmallPtrSetImpl<const SILBasicBlock*> &Visited){
if (Visited.count(&B))
return false;
Visited.insert(&B);
assert(State);
for (auto I = B.begin(), E = B.end(); I != E; ++I) {
SILLocation Loc = I->getLoc();
// If we've reached an implicit return, we have not found any user code and
// can stop searching for it.
if (Loc.is<ImplicitReturnLocation>() || Loc.isAutoGenerated())
return false;
// Check if the instruction corresponds to user-written code, also make
// sure we don't report an error twice for the same instruction.
if (isUserCode(&*I) && !State->BlocksWithErrors.count(&B)) {
// Emit the diagnostic.
auto BrInfoIter = State->MetaMap.find(TopLevelB);
assert(BrInfoIter != State->MetaMap.end());
auto BrInfo = BrInfoIter->second;
switch (BrInfo.Kind) {
case (UnreachableKind::FoldedBranch):
// Emit the diagnostic on the unreachable block and emit the
// note on the branch responsible for the unreachable code.
diagnose(M.getASTContext(), Loc.getSourceLoc(), diag::unreachable_code);
diagnose(M.getASTContext(), BrInfo.Loc.getSourceLoc(),
diag::unreachable_code_branch, BrInfo.CondIsAlwaysTrue);
break;
case (UnreachableKind::FoldedSwitchEnum): {
// If we are warning about a switch condition being a constant, the main
// emphasis should be on the condition (to ensure we have a single
// message per switch).
const SwitchStmt *SS = BrInfo.Loc.getAsASTNode<SwitchStmt>();
if (!SS)
break;
assert(SS);
const Expr *SE = SS->getSubjectExpr();
diagnose(M.getASTContext(), SE->getLoc(), diag::switch_on_a_constant);
diagnose(M.getASTContext(), Loc.getSourceLoc(),
diag::unreachable_code_note);
break;
}
case (UnreachableKind::NoreturnCall): {
// Specialcase when we are warning about unreachable code after a call
// to a noreturn function.
if (!BrInfo.Loc.isASTNode<ExplicitCastExpr>()) {
assert(BrInfo.Loc.isASTNode<ApplyExpr>());
diagnose(M.getASTContext(), Loc.getSourceLoc(),
diag::unreachable_code);
diagnose(M.getASTContext(), BrInfo.Loc.getSourceLoc(),
diag::call_to_noreturn_note);
}
break;
}
}
// Record that we've reported this unreachable block to avoid duplicates
// in the future.
State->BlocksWithErrors.insert(&B);
return true;
}
}
// This block could be empty if it's terminator has been folded.
if (B.empty())
return false;
// If we have not found user code in this block, inspect it's successors.
// Check if at least one of the successors contains user code.
for (auto I = B.succ_begin(), E = B.succ_end(); I != E; ++I) {
SILBasicBlock *SB = *I;
bool HasReachablePred = false;
for (auto PI = SB->pred_begin(), PE = SB->pred_end(); PI != PE; ++PI) {
if (Reachable.count(*PI))
HasReachablePred = true;
}
// If all of the predecessors of this successor are unreachable, check if
// it contains user code.
if (!HasReachablePred && diagnoseUnreachableBlock(*SB, M, Reachable,
State, TopLevelB, Visited))
return true;
}
return false;
}