Skip to content

Commit 4c28844

Browse files
[ProfileData] Use default member initialization (NFC) (#94817)
While we are at it, this patch changes the type of ValueCounts to std:array<double, ...> so that we can use std::array:fill. Identified with modernize-use-default-member-init.
1 parent 608fb46 commit 4c28844

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,14 @@ GlobalVariable *InstrProfSymtab::getGlobalVariable(uint64_t MD5Hash) {
737737
// To store the sums of profile count values, or the percentage of
738738
// the sums of the total count values.
739739
struct CountSumOrPercent {
740-
uint64_t NumEntries;
741-
double CountSum;
742-
double ValueCounts[IPVK_Last - IPVK_First + 1];
743-
CountSumOrPercent() : NumEntries(0), CountSum(0.0f), ValueCounts() {}
740+
uint64_t NumEntries = 0;
741+
double CountSum = 0.0f;
742+
std::array<double, IPVK_Last - IPVK_First + 1> ValueCounts = {};
743+
CountSumOrPercent() = default;
744744
void reset() {
745745
NumEntries = 0;
746746
CountSum = 0.0f;
747-
for (double &VC : ValueCounts)
748-
VC = 0.0f;
747+
ValueCounts.fill(0.0f);
749748
}
750749
};
751750

@@ -761,15 +760,13 @@ struct OverlapStats {
761760
CountSumOrPercent Mismatch;
762761
CountSumOrPercent Unique;
763762
OverlapStatsLevel Level;
764-
const std::string *BaseFilename;
765-
const std::string *TestFilename;
763+
const std::string *BaseFilename = nullptr;
764+
const std::string *TestFilename = nullptr;
766765
StringRef FuncName;
767-
uint64_t FuncHash;
768-
bool Valid;
766+
uint64_t FuncHash = 0;
767+
bool Valid = false;
769768

770-
OverlapStats(OverlapStatsLevel L = ProgramLevel)
771-
: Level(L), BaseFilename(nullptr), TestFilename(nullptr), FuncHash(0),
772-
Valid(false) {}
769+
OverlapStats(OverlapStatsLevel L = ProgramLevel) : Level(L) {}
773770

774771
void dump(raw_fd_ostream &OS) const;
775772

0 commit comments

Comments
 (0)