23
23
#include " llvm/ADT/StringExtras.h"
24
24
#include " llvm/ADT/StringMap.h"
25
25
#include " llvm/ADT/StringRef.h"
26
+ #include " llvm/ADT/iterator_range.h"
26
27
#include " llvm/IR/ConstantRange.h"
27
28
#include " llvm/IR/GlobalValue.h"
28
29
#include " llvm/IR/Module.h"
@@ -1293,8 +1294,26 @@ class CfiFunctionIndex {
1293
1294
std::set<std::string, std::less<>> Index;
1294
1295
1295
1296
public:
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
+ };
1297
1315
1316
+ CfiFunctionIndex () = default ;
1298
1317
template <typename It> CfiFunctionIndex (It B, It E) : Index(B, E) {}
1299
1318
1300
1319
std::set<std::string, std::less<>>::const_iterator begin () const {
@@ -1305,6 +1324,12 @@ class CfiFunctionIndex {
1305
1324
return Index.end ();
1306
1325
}
1307
1326
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
+
1308
1333
template <typename ... Args> void emplace (Args &&...A) {
1309
1334
Index.emplace (std::forward<Args>(A)...);
1310
1335
}
0 commit comments