2323#include " llvm/ADT/StringExtras.h"
2424#include " llvm/ADT/StringMap.h"
2525#include " llvm/ADT/StringRef.h"
26+ #include " llvm/ADT/iterator_range.h"
2627#include " llvm/IR/ConstantRange.h"
2728#include " llvm/IR/GlobalValue.h"
2829#include " llvm/IR/Module.h"
@@ -1293,8 +1294,26 @@ class CfiFunctionIndex {
12931294 std::set<std::string, std::less<>> Index;
12941295
12951296public:
1296- CfiFunctionIndex () = default ;
1297+ class GUIDIterator
1298+ : public iterator_adaptor_base<
1299+ GUIDIterator, std::set<std::string, std::less<>>::const_iterator,
1300+ std::forward_iterator_tag, GlobalValue::GUID> {
1301+ using base = iterator_adaptor_base<
1302+ GUIDIterator, std::set<std::string, std::less<>>::const_iterator,
1303+ std::forward_iterator_tag, GlobalValue::GUID>;
1304+
1305+ public:
1306+ GUIDIterator () = default ;
1307+ explicit GUIDIterator (std::set<std::string, std::less<>>::const_iterator I)
1308+ : base(std::move(I)) {}
1309+
1310+ GlobalValue::GUID operator *() const {
1311+ return GlobalValue::getGUID (
1312+ GlobalValue::dropLLVMManglingEscape (*this ->wrapped ()));
1313+ }
1314+ };
12971315
1316+ CfiFunctionIndex () = default ;
12981317 template <typename It> CfiFunctionIndex (It B, It E) : Index(B, E) {}
12991318
13001319 std::set<std::string, std::less<>>::const_iterator begin () const {
@@ -1305,6 +1324,12 @@ class CfiFunctionIndex {
13051324 return Index.end ();
13061325 }
13071326
1327+ GUIDIterator guid_begin () const { return GUIDIterator (Index.begin ()); }
1328+ GUIDIterator guid_end () const { return GUIDIterator (Index.end ()); }
1329+ iterator_range<GUIDIterator> guids () const {
1330+ return make_range (guid_begin (), guid_end ());
1331+ }
1332+
13081333 template <typename ... Args> void emplace (Args &&...A) {
13091334 Index.emplace (std::forward<Args>(A)...);
13101335 }
0 commit comments