- Notifications
You must be signed in to change notification settings - Fork 14.9k
[Support] Add "override" where appropriate (NFC) #164190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata merged 1 commit into llvm:main from kazutakahirata:cleanup_20251019_tidy_modernize_use_override Oct 20, 2025
Merged
[Support] Add "override" where appropriate (NFC) #164190
kazutakahirata merged 1 commit into llvm:main from kazutakahirata:cleanup_20251019_tidy_modernize_use_override Oct 20, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Note that "override" makes "virtual" redundant. Identified with modernize-use-override.
@llvm/pr-subscribers-llvm-support Author: Kazu Hirata (kazutakahirata) ChangesNote that "override" makes "virtual" redundant. Identified with modernize-use-override. Full diff: https://github.com/llvm/llvm-project/pull/164190.diff 9 Files Affected:
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. |
arsenm approved these changes Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Note that "override" makes "virtual" redundant.
Identified with modernize-use-override.