Skip to content

Commit db07120

Browse files
Address comments.
1 parent 69dc534 commit db07120

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,10 @@ template <> struct ScalarTraits<memprof::GUIDHex64> {
11771177
Out << format("0x%016" PRIx64, (uint64_t)Val);
11781178
}
11791179
static StringRef input(StringRef Scalar, void *, memprof::GUIDHex64 &Val) {
1180+
// Reject decimal GUIDs.
1181+
if (all_of(Scalar, [](char C) { return std::isdigit(C); }))
1182+
return "use a hexadecimal GUID or a function instead";
1183+
11801184
uint64_t Num;
11811185
if (Scalar.starts_with_insensitive("0x")) {
11821186
// Accept hexadecimal numbers starting with 0x or 0X.

llvm/unittests/ProfileData/MemProfTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ TEST(MemProf, YAMLParserGUID) {
791791

792792
// Verify the entire contents of MemProfData.Records.
793793
ASSERT_THAT(MemProfData.Records, SizeIs(1));
794-
const auto &[GUID, Record] = *MemProfData.Records.begin();
794+
const auto &[GUID, Record] = MemProfData.Records.front();
795795
EXPECT_EQ(GUID, IndexedMemProfRecord::getGUID("_Z3fooi"));
796796
ASSERT_THAT(Record.AllocSites, SizeIs(1));
797797
EXPECT_EQ(Record.AllocSites[0].CSId, hashCallStack(CS1));

0 commit comments

Comments
 (0)