| 1 |
//===- EntityIdTable.cpp ----------------------------------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "clang/Analysis/Scalable/Model/EntityIdTable.h" |
| 10 |
#include <cassert> |
| 11 |
|
| 12 |
namespace clang::ssaf { |
| 13 |
|
| 14 |
EntityId EntityIdTable::getId(const EntityName &Name) { |
| 15 |
EntityId Id(Entities.size()); |
| 16 |
const auto Res = Entities.try_emplace(Name, Id); |
| 17 |
return Res.first->second; |
| 18 |
} |
| 19 |
|
| 20 |
bool EntityIdTable::contains(const EntityName &Name) const { |
| 21 |
return Entities.find(Name) != Entities.end(); |
| 22 |
} |
| 23 |
|
| 24 |
void EntityIdTable::forEach( |
| 25 |
llvm::function_ref<void(const EntityName &, EntityId)> Callback) const { |
| 26 |
for (const auto &NameIdPair : Entities) { |
| 27 |
Callback(NameIdPair.first, NameIdPair.second); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
} // namespace clang::ssaf |