[llvm-branch-commits] [MC][profgen][NFC] Expand auto for MCDecodedPseudoProbe (PR #102788)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Aug 10 23:09:20 PDT 2024


================
@@ -657,7 +657,7 @@ MCPseudoProbeDecoder::getCallProbeForAddr(uint64_t Address) const {
   const auto &Probes = It->second;
 
   const MCDecodedPseudoProbe *CallProbe = nullptr;
-  for (const auto &Probe : Probes) {
----------------
aaupov wrote:

In #102789, `Probes` become `std::vector<std::reference_wrapper<MCDecodedPseudoProbe>>`.
`auto` would expand to a reference_wrapper, so to access the underlying pseudo probe, it would need explicit `get`. To avoid that, we can use `reference_wrapper::operator T&` which is functionally identical to `get`. This is achieved by providing `MCDecodedPseudoProbe &` as type of a range-based variable.

https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/get

https://github.com/llvm/llvm-project/pull/102788


More information about the llvm-branch-commits mailing list