Skip to content

Commit 47c4ce4

Browse files
committed
[DWARFYAML] Use override instead of virtual for better safety.
Functions in DWARFYML::FixupVisitor are declared as virtual functions in its base class DWARFYAML::Visitor. We should use the mordern "override" keyword instead of "virtual" for virtual functions in subclasses for better safety. Besides, the visibility is changed from private to protected to make it consistent with DWARFYAML::FixupVisitor class and DWARFYAML::Visitor class. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D83452
1 parent 6b40331 commit 47c4ce4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

llvm/lib/ObjectYAML/DWARFEmitter.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -440,36 +440,36 @@ class DIEFixupVisitor : public DWARFYAML::Visitor {
440440
public:
441441
DIEFixupVisitor(DWARFYAML::Data &DI) : DWARFYAML::Visitor(DI){};
442442

443-
private:
444-
virtual void onStartCompileUnit(DWARFYAML::Unit &CU) {
443+
protected:
444+
void onStartCompileUnit(DWARFYAML::Unit &CU) override {
445445
// Size of the unit header, excluding the length field itself.
446446
Length = CU.Version >= 5 ? 8 : 7;
447447
}
448448

449-
virtual void onEndCompileUnit(DWARFYAML::Unit &CU) { CU.Length = Length; }
449+
void onEndCompileUnit(DWARFYAML::Unit &CU) override { CU.Length = Length; }
450450

451-
virtual void onStartDIE(DWARFYAML::Unit &CU, DWARFYAML::Entry &DIE) {
451+
void onStartDIE(DWARFYAML::Unit &CU, DWARFYAML::Entry &DIE) override {
452452
Length += getULEB128Size(DIE.AbbrCode);
453453
}
454454

455-
virtual void onValue(const uint8_t U) { Length += 1; }
456-
virtual void onValue(const uint16_t U) { Length += 2; }
457-
virtual void onValue(const uint32_t U) { Length += 4; }
458-
virtual void onValue(const uint64_t U, const bool LEB = false) {
455+
void onValue(const uint8_t U) override { Length += 1; }
456+
void onValue(const uint16_t U) override { Length += 2; }
457+
void onValue(const uint32_t U) override { Length += 4; }
458+
void onValue(const uint64_t U, const bool LEB = false) override {
459459
if (LEB)
460460
Length += getULEB128Size(U);
461461
else
462462
Length += 8;
463463
}
464-
virtual void onValue(const int64_t S, const bool LEB = false) {
464+
void onValue(const int64_t S, const bool LEB = false) override {
465465
if (LEB)
466466
Length += getSLEB128Size(S);
467467
else
468468
Length += 8;
469469
}
470-
virtual void onValue(const StringRef String) { Length += String.size() + 1; }
470+
void onValue(const StringRef String) override { Length += String.size() + 1; }
471471

472-
virtual void onValue(const MemoryBufferRef MBR) {
472+
void onValue(const MemoryBufferRef MBR) override {
473473
Length += MBR.getBufferSize();
474474
}
475475
};

0 commit comments

Comments
 (0)