diff options
author | Kazu Hirata <kazu@google.com> | 2024-04-11 09:56:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 09:56:01 -0700 |
commit | db9a17a4075d2ba4cf9edfa90018da6c11908e2a (patch) | |
tree | 8effb6ee459663e50285014a5d32612db4438bc3 /llvm/unittests/ProfileData/InstrProfTest.cpp | |
parent | 3749e0d43fb56cf22cc72274c287b7bfdda9821d (diff) | |
download | llvm-db9a17a4075d2ba4cf9edfa90018da6c11908e2a.zip llvm-db9a17a4075d2ba4cf9edfa90018da6c11908e2a.tar.gz llvm-db9a17a4075d2ba4cf9edfa90018da6c11908e2a.tar.bz2 |
[memprof] Use std::optional (NFC) (#88366)
Diffstat (limited to 'llvm/unittests/ProfileData/InstrProfTest.cpp')
-rw-r--r-- | llvm/unittests/ProfileData/InstrProfTest.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index 732f8fd..82701c4 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -19,6 +19,7 @@ #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" #include <cstdarg> +#include <optional> using namespace llvm; using ::testing::EndsWith; @@ -433,21 +434,19 @@ TEST_F(InstrProfTest, test_memprof) { ASSERT_THAT_ERROR(RecordOr.takeError(), Succeeded()); const memprof::MemProfRecord &Record = RecordOr.get(); - memprof::FrameId LastUnmappedFrameId = 0; - bool HasFrameMappingError = false; + std::optional<memprof::FrameId> LastUnmappedFrameId; auto IdToFrameCallback = [&](const memprof::FrameId Id) { auto Iter = IdToFrameMap.find(Id); if (Iter == IdToFrameMap.end()) { LastUnmappedFrameId = Id; - HasFrameMappingError = true; return memprof::Frame(0, 0, 0, false); } return Iter->second; }; const memprof::MemProfRecord WantRecord(IndexedMR, IdToFrameCallback); - ASSERT_FALSE(HasFrameMappingError) - << "could not map frame id: " << LastUnmappedFrameId; + ASSERT_FALSE(LastUnmappedFrameId.has_value()) + << "could not map frame id: " << *LastUnmappedFrameId; EXPECT_THAT(WantRecord, EqualsRecord(Record)); } |