[llvm] [Support] Add "override" where appropriate (NFC) (PR #164190)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 19 16:24:22 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/164190
Note that "override" makes "virtual" redundant.
Identified with modernize-use-override.
>From c40baa003b02465e913dfb387f6a2b1e44f98593 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 18 Oct 2025 23:22:51 -0700
Subject: [PATCH] [Support] Add "override" where appropriate (NFC)
Note that "override" makes "virtual" redundant.
Identified with modernize-use-override.
---
llvm/include/llvm/Support/DebugLog.h | 2 +-
llvm/include/llvm/Support/ELFAttrParserCompact.h | 2 +-
llvm/include/llvm/Support/ELFAttrParserExtended.h | 2 +-
llvm/include/llvm/Support/FormatAdapters.h | 2 +-
llvm/include/llvm/Support/ScopedPrinter.h | 4 ++--
llvm/include/llvm/Support/SuffixTreeNode.h | 4 ++--
llvm/include/llvm/Support/VirtualFileSystem.h | 4 ++--
llvm/include/llvm/Support/VirtualOutputFile.h | 2 +-
llvm/include/llvm/Support/raw_socket_stream.h | 2 +-
9 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/llvm/include/llvm/Support/DebugLog.h b/llvm/include/llvm/Support/DebugLog.h
index fd67d7aba85f0..e9bd2d83c46ba 100644
--- a/llvm/include/llvm/Support/DebugLog.h
+++ b/llvm/include/llvm/Support/DebugLog.h
@@ -293,7 +293,7 @@ class RAIINewLineStream final : public raw_ostream {
public:
RAIINewLineStream(raw_ostream &Os) : Os(Os) { SetUnbuffered(); }
- ~RAIINewLineStream() { Os << '\n'; }
+ ~RAIINewLineStream() override { Os << '\n'; }
void write_impl(const char *Ptr, size_t Size) final { Os.write(Ptr, Size); }
uint64_t current_pos() const final { return Os.tell(); }
RAIINewLineStream &asLvalue() { return *this; }
diff --git a/llvm/include/llvm/Support/ELFAttrParserCompact.h b/llvm/include/llvm/Support/ELFAttrParserCompact.h
index e687483b21a8c..9bed36fdacd8b 100644
--- a/llvm/include/llvm/Support/ELFAttrParserCompact.h
+++ b/llvm/include/llvm/Support/ELFAttrParserCompact.h
@@ -49,7 +49,7 @@ class LLVM_ABI ELFCompactAttrParser : public ELFAttributeParser {
}
public:
- virtual ~ELFCompactAttrParser() { static_cast<void>(!cursor.takeError()); }
+ ~ELFCompactAttrParser() override { static_cast<void>(!cursor.takeError()); }
Error integerAttribute(unsigned tag);
Error stringAttribute(unsigned tag);
diff --git a/llvm/include/llvm/Support/ELFAttrParserExtended.h b/llvm/include/llvm/Support/ELFAttrParserExtended.h
index 1da666595cd01..d3dc74263d2b0 100644
--- a/llvm/include/llvm/Support/ELFAttrParserExtended.h
+++ b/llvm/include/llvm/Support/ELFAttrParserExtended.h
@@ -36,7 +36,7 @@ class LLVM_ABI ELFExtendedAttrParser : public ELFAttributeParser {
const unsigned Tag);
public:
- virtual ~ELFExtendedAttrParser() { static_cast<void>(!Cursor.takeError()); }
+ ~ELFExtendedAttrParser() override { static_cast<void>(!Cursor.takeError()); }
Error parse(ArrayRef<uint8_t> Section, llvm::endianness Endian) override;
std::optional<unsigned> getAttributeValue(unsigned Tag) const override;
diff --git a/llvm/include/llvm/Support/FormatAdapters.h b/llvm/include/llvm/Support/FormatAdapters.h
index 4131e956873e9..91e9c41d8a395 100644
--- a/llvm/include/llvm/Support/FormatAdapters.h
+++ b/llvm/include/llvm/Support/FormatAdapters.h
@@ -77,7 +77,7 @@ class ErrorAdapter : public FormatAdapter<Error> {
public:
ErrorAdapter(Error &&Item) : FormatAdapter(std::move(Item)) {}
ErrorAdapter(ErrorAdapter &&) = default;
- ~ErrorAdapter() { consumeError(std::move(Item)); }
+ ~ErrorAdapter() override { consumeError(std::move(Item)); }
void format(llvm::raw_ostream &Stream, StringRef Style) override {
Stream << Item;
}
diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index 7b87fdafd68ac..e9e9903b2482a 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -870,7 +870,7 @@ struct DictScope : DelimitedScope {
W.objectBegin();
}
- ~DictScope() {
+ ~DictScope() override {
if (W)
W->objectEnd();
}
@@ -889,7 +889,7 @@ struct ListScope : DelimitedScope {
W.arrayBegin();
}
- ~ListScope() {
+ ~ListScope() override {
if (W)
W->arrayEnd();
}
diff --git a/llvm/include/llvm/Support/SuffixTreeNode.h b/llvm/include/llvm/Support/SuffixTreeNode.h
index b49febf16e01e..c3c0bf5d14926 100644
--- a/llvm/include/llvm/Support/SuffixTreeNode.h
+++ b/llvm/include/llvm/Support/SuffixTreeNode.h
@@ -155,7 +155,7 @@ struct LLVM_ABI SuffixTreeInternalNode : SuffixTreeNode {
: SuffixTreeNode(NodeKind::ST_Internal, StartIdx), EndIdx(EndIdx),
Link(Link) {}
- virtual ~SuffixTreeInternalNode() = default;
+ ~SuffixTreeInternalNode() override = default;
};
// A node representing a suffix.
@@ -189,7 +189,7 @@ struct LLVM_ABI SuffixTreeLeafNode : SuffixTreeNode {
SuffixTreeLeafNode(unsigned StartIdx, unsigned *EndIdx)
: SuffixTreeNode(NodeKind::ST_Leaf, StartIdx), EndIdx(EndIdx) {}
- virtual ~SuffixTreeLeafNode() = default;
+ ~SuffixTreeLeafNode() override = default;
};
} // namespace llvm
#endif // LLVM_SUPPORT_SUFFIXTREE_NODE_H
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h
index 8007f3c853f20..c8911a0225f86 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -268,7 +268,7 @@ class LLVM_ABI FileSystem : public llvm::ThreadSafeRefCountedBase<FileSystem>,
public RTTIExtends<FileSystem, RTTIRoot> {
public:
static const char ID;
- virtual ~FileSystem();
+ ~FileSystem() override;
/// Get the status of the entry at \p Path, if one exists.
virtual llvm::ErrorOr<Status> status(const Twine &Path) = 0;
@@ -495,7 +495,7 @@ class LLVM_ABI ProxyFileSystem
private:
IntrusiveRefCntPtr<FileSystem> FS;
- virtual void anchor() override;
+ void anchor() override;
};
namespace detail {
diff --git a/llvm/include/llvm/Support/VirtualOutputFile.h b/llvm/include/llvm/Support/VirtualOutputFile.h
index cb6d1c3d78139..dd50437605deb 100644
--- a/llvm/include/llvm/Support/VirtualOutputFile.h
+++ b/llvm/include/llvm/Support/VirtualOutputFile.h
@@ -31,7 +31,7 @@ class OutputFileImpl : public RTTIExtends<OutputFileImpl, RTTIRoot> {
public:
static char ID;
- virtual ~OutputFileImpl() = default;
+ ~OutputFileImpl() override = default;
virtual Error keep() = 0;
virtual Error discard() = 0;
diff --git a/llvm/include/llvm/Support/raw_socket_stream.h b/llvm/include/llvm/Support/raw_socket_stream.h
index 47352e3c04220..2abff25920d16 100644
--- a/llvm/include/llvm/Support/raw_socket_stream.h
+++ b/llvm/include/llvm/Support/raw_socket_stream.h
@@ -126,7 +126,7 @@ class LLVM_ABI raw_socket_stream : public raw_fd_stream {
public:
raw_socket_stream(int SocketFD);
- ~raw_socket_stream();
+ ~raw_socket_stream() override;
/// Create a \p raw_socket_stream connected to the UNIX domain socket at \p
/// SocketPath.
More information about the llvm-commits
mailing list