https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/164189
This patch modernizes a couple of things: - Use in-class member initializers in MapEntryOptionalStorage. - Inherit constructors in OptionalStorage<clang::DirectoryEntryRef> and OptionalStorage<clang::FileEntryRef>. >From 32f55b1ab3d0106c8065bdfea59e005f83e81533 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <[email protected]> Date: Sun, 19 Oct 2025 01:21:18 -0700 Subject: [PATCH] [Basic] clean up MapEntryOptionalStorage and its derived classes (NFC) This patch modernizes a couple of things: - Use in-class member initializers in MapEntryOptionalStorage. - Inherit constructors in OptionalStorage<clang::DirectoryEntryRef> and OptionalStorage<clang::FileEntryRef>. --- clang/include/clang/Basic/DirectoryEntry.h | 10 +++------- clang/include/clang/Basic/FileEntry.h | 6 +----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index 35fe529ba79df..69656125e422a 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -119,10 +119,10 @@ namespace FileMgr { /// the private optional_none_tag to keep it to the size of a single pointer. template <class RefTy> class MapEntryOptionalStorage { using optional_none_tag = typename RefTy::optional_none_tag; - RefTy MaybeRef; + RefTy MaybeRef = optional_none_tag(); public: - MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {} + MapEntryOptionalStorage() = default; template <class... ArgTypes> explicit MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args) @@ -168,11 +168,7 @@ class OptionalStorage<clang::DirectoryEntryRef> clang::FileMgr::MapEntryOptionalStorage<clang::DirectoryEntryRef>; public: - OptionalStorage() = default; - - template <class... ArgTypes> - explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) - : StorageImpl(std::in_place_t{}, std::forward<ArgTypes>(Args)...) {} + using StorageImpl::StorageImpl; OptionalStorage &operator=(clang::DirectoryEntryRef Ref) { StorageImpl::operator=(Ref); diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index c973ba38bdf7e..e7091fd1def59 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -218,11 +218,7 @@ class OptionalStorage<clang::FileEntryRef> clang::FileMgr::MapEntryOptionalStorage<clang::FileEntryRef>; public: - OptionalStorage() = default; - - template <class... ArgTypes> - explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) - : StorageImpl(std::in_place_t{}, std::forward<ArgTypes>(Args)...) {} + using StorageImpl::StorageImpl; OptionalStorage &operator=(clang::FileEntryRef Ref) { StorageImpl::operator=(Ref); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
