================ @@ -147,96 +148,111 @@ class ProcessInstanceInfo : public ProcessInfo { ProcessInstanceInfo() = default; ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) - : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX), - m_parent_pid(LLDB_INVALID_PROCESS_ID) {} + : ProcessInfo(name, arch, pid) {} void Clear() { ProcessInfo::Clear(); - m_euid = UINT32_MAX; - m_egid = UINT32_MAX; - m_parent_pid = LLDB_INVALID_PROCESS_ID; + m_euid = std::nullopt; + m_egid = std::nullopt; + m_parent_pid = std::nullopt; } - uint32_t GetEffectiveUserID() const { return m_euid; } + uint32_t GetEffectiveUserID() const { return m_euid.value(); } ---------------- clayborg wrote:
can we actually return `std::optional<uint32_t>` here? Otherwise if someone calls this and `m_euid` doesn't have a value, then it will throw a `std::bad_optional_access` exception. There is a `std::optional<T>::value_or(T)`, but that will defeat the reason for adding a std::optional in the first place. So I see two options: ``` uint32_t GetEffectiveUserID(uint32_t default_value = 0) const { return m_euid.value_or(default_value); } ``` or ``` std::optional<uint32_t> GetEffectiveUserID() const { return m_euid; } ``` I would prefer the latter, but now sure now many locations this will affect. https://github.com/llvm/llvm-project/pull/91544 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits