本文整理汇总了C++中SmallDenseMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallDenseMap::insert方法的具体用法?C++ SmallDenseMap::insert怎么用?C++ SmallDenseMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallDenseMap
的用法示例。
在下文中一共展示了SmallDenseMap::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/// Sort local variables so that variables appearing inside of helper
/// expressions come first.
static SmallVector<DbgVariable *, 8>
sortLocalVars(SmallVectorImpl<DbgVariable *> &Input) {
SmallVector<DbgVariable *, 8> Result;
SmallVector<PointerIntPair<DbgVariable *, 1>, 8> WorkList;
// Map back from a DIVariable to its containing DbgVariable.
SmallDenseMap<const DILocalVariable *, DbgVariable *> DbgVar;
// Set of DbgVariables in Result.
SmallDenseSet<DbgVariable *, 8> Visited;
// For cycle detection.
SmallDenseSet<DbgVariable *, 8> Visiting;
// Initialize the worklist and the DIVariable lookup table.
for (auto Var : reverse(Input)) {
DbgVar.insert({Var->getVariable(), Var});
WorkList.push_back({Var, 0});
}
// Perform a stable topological sort by doing a DFS.
while (!WorkList.empty()) {
auto Item = WorkList.back();
DbgVariable *Var = Item.getPointer();
bool visitedAllDependencies = Item.getInt();
WorkList.pop_back();
// Dependency is in a different lexical scope or a global.
if (!Var)
continue;
// Already handled.
if (Visited.count(Var))
continue;
// Add to Result if all dependencies are visited.
if (visitedAllDependencies) {
Visited.insert(Var);
Result.push_back(Var);
continue;
}
// Detect cycles.
auto Res = Visiting.insert(Var);
if (!Res.second) {
assert(false && "dependency cycle in local variables");
return Result;
}
// Push dependencies and this node onto the worklist, so that this node is
// visited again after all of its dependencies are handled.
WorkList.push_back({Var, 1});
for (auto *Dependency : dependencies(Var)) {
auto Dep = dyn_cast_or_null<const DILocalVariable>(Dependency);
WorkList.push_back({DbgVar[Dep], 0});
}
}
return Result;
}