From 32f55b1ab3d0106c8065bdfea59e005f83e81533 Mon Sep 17 00:00:00 2001 From: Kazu Hirata 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 and OptionalStorage. --- 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 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 explicit MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args) @@ -168,11 +168,7 @@ class OptionalStorage clang::FileMgr::MapEntryOptionalStorage; public: - OptionalStorage() = default; - - template - explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) - : StorageImpl(std::in_place_t{}, std::forward(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::FileMgr::MapEntryOptionalStorage; public: - OptionalStorage() = default; - - template - explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) - : StorageImpl(std::in_place_t{}, std::forward(Args)...) {} + using StorageImpl::StorageImpl; OptionalStorage &operator=(clang::FileEntryRef Ref) { StorageImpl::operator=(Ref);