Skip to content

Commit 8b1c084

Browse files
committed
Remove default constructor & noexcept
1 parent 4964eac commit 8b1c084

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

lldb/include/lldb/Utility/NonNullSharedPtr.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ namespace lldb_private {
1717
/// A non-nullable shared pointer that always holds a valid object.
1818
///
1919
/// NonNullSharedPtr is a smart pointer wrapper around std::shared_ptr that
20-
/// guarantees the pointer is never null. If default-constructed, it creates
21-
/// a default-constructed instance of T.
20+
/// guarantees the pointer is never null.
2221
///
2322
/// This class is used for enforcing invariants at the type level and
2423
/// eliminating entire classes of null pointer bugs.
@@ -28,8 +27,6 @@ template <typename T> class NonNullSharedPtr : private std::shared_ptr<T> {
2827
using Base = std::shared_ptr<T>;
2928

3029
public:
31-
NonNullSharedPtr() : Base(std::make_shared<T>()) {}
32-
3330
NonNullSharedPtr(const std::shared_ptr<T> &t)
3431
: Base(t ? t : std::make_shared<T>()) {
3532
assert(t && "NonNullSharedPtr initialized from NULL shared_ptr");
@@ -42,15 +39,14 @@ template <typename T> class NonNullSharedPtr : private std::shared_ptr<T> {
4239

4340
NonNullSharedPtr(const NonNullSharedPtr &other) : Base(other) {}
4441

45-
NonNullSharedPtr(NonNullSharedPtr &&other) noexcept
46-
: Base(std::move(other)) {}
42+
NonNullSharedPtr(NonNullSharedPtr &&other) : Base(std::move(other)) {}
4743

4844
NonNullSharedPtr &operator=(const NonNullSharedPtr &other) {
4945
Base::operator=(other);
5046
return *this;
5147
}
5248

53-
NonNullSharedPtr &operator=(NonNullSharedPtr &&other) noexcept {
49+
NonNullSharedPtr &operator=(NonNullSharedPtr &&other) {
5450
Base::operator=(std::move(other));
5551
return *this;
5652
}
@@ -62,7 +58,7 @@ template <typename T> class NonNullSharedPtr : private std::shared_ptr<T> {
6258
using Base::use_count;
6359
using Base::operator bool;
6460

65-
void swap(NonNullSharedPtr &other) noexcept { Base::swap(other); }
61+
void swap(NonNullSharedPtr &other) { Base::swap(other); }
6662

6763
/// Explicitly deleted operations that could introduce nullptr.
6864
/// @{
@@ -77,7 +73,7 @@ template <typename T> class NonNullSharedPtr : private std::shared_ptr<T> {
7773
/// lookup (ADL) and efficient swapping.
7874
template <typename T>
7975
void swap(lldb_private::NonNullSharedPtr<T> &lhs,
80-
lldb_private::NonNullSharedPtr<T> &rhs) noexcept {
76+
lldb_private::NonNullSharedPtr<T> &rhs) {
8177
lhs.swap(rhs);
8278
}
8379

lldb/source/Breakpoint/BreakpointResolverFileLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
139139
if (!sc.block)
140140
continue;
141141

142-
SupportFileSP file_sp;
142+
SupportFileSP file_sp = std::make_shared<SupportFile>();
143143
uint32_t line;
144144
const Block *inline_block = sc.block->GetContainingInlinedBlock();
145145
if (inline_block) {

lldb/source/Core/Disassembler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Disassembler::GetFunctionDeclLineEntry(const SymbolContext &sc) {
208208
return {};
209209

210210
LineEntry prologue_end_line = sc.line_entry;
211-
SupportFileSP func_decl_file_sp;
211+
SupportFileSP func_decl_file_sp = std::make_shared<SupportFile>();
212212
uint32_t func_decl_line;
213213
sc.function->GetStartLineSourceInfo(func_decl_file_sp, func_decl_line);
214214

@@ -539,7 +539,8 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
539539
LineEntry prologue_end_line = sc.line_entry;
540540
if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc,
541541
prologue_end_line)) {
542-
SupportFileSP func_decl_file_sp;
542+
SupportFileSP func_decl_file_sp =
543+
std::make_shared<SupportFile>();
543544
uint32_t func_decl_line;
544545
sc.function->GetStartLineSourceInfo(func_decl_file_sp,
545546
func_decl_line);

lldb/source/Symbol/Function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp,
302302

303303
llvm::Expected<std::pair<SupportFileSP, Function::SourceRange>>
304304
Function::GetSourceInfo() {
305-
SupportFileSP source_file_sp;
305+
SupportFileSP source_file_sp = std::make_shared<SupportFile>();
306306
uint32_t start_line;
307307
GetStartLineSourceInfo(source_file_sp, start_line);
308308
LineTable *line_table = m_comp_unit->GetLineTable();

lldb/source/Symbol/LineTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void LineTable::Dump(Stream *s, Target *target, Address::DumpStyle style,
327327
Address::DumpStyle fallback_style, bool show_line_ranges) {
328328
const size_t count = m_entries.size();
329329
LineEntry line_entry;
330-
SupportFileSP prev_file;
330+
SupportFileSP prev_file = std::make_shared<SupportFile>();
331331
for (size_t idx = 0; idx < count; ++idx) {
332332
ConvertEntryAtIndexToLineEntry(idx, line_entry);
333333
line_entry.Dump(s, target, !prev_file->Equal(*line_entry.original_file_sp),

lldb/source/Utility/FileSpecList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const FileSpec &SupportFileList::GetFileSpecAtIndex(size_t idx) const {
216216
SupportFileSP SupportFileList::GetSupportFileAtIndex(size_t idx) const {
217217
if (idx < m_files.size())
218218
return m_files[idx];
219-
return {};
219+
return std::make_shared<SupportFile>();
220220
}
221221

222222
// Return the size in bytes that this object takes in memory. This returns the

0 commit comments

Comments
 (0)