Skip to content

Commit acd7a68

Browse files
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#97778)
1 parent 9cb9a97 commit acd7a68

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ class TargetInstrInfo : public MCInstrInfo {
22142214
/// Return MIR formatter to format/parse MIR operands. Target can override
22152215
/// this virtual function and return target specific MIR formatter.
22162216
virtual const MIRFormatter *getMIRFormatter() const {
2217-
if (!Formatter.get())
2217+
if (!Formatter)
22182218
Formatter = std::make_unique<MIRFormatter>();
22192219
return Formatter.get();
22202220
}

llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() {
18331833

18341834
bool CompileUnit::resolveDependenciesAndMarkLiveness(
18351835
bool InterCUProcessingStarted, std::atomic<bool> &HasNewInterconnectedCUs) {
1836-
if (!Dependencies.get())
1836+
if (!Dependencies)
18371837
Dependencies.reset(new DependencyTracker(*this));
18381838

18391839
return Dependencies->resolveDependenciesAndMarkLiveness(

llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Error DWARFLinkerImpl::link() {
107107
std::optional<uint16_t> Language;
108108

109109
for (std::unique_ptr<LinkContext> &Context : ObjectContexts) {
110-
if (Context->InputDWARFFile.Dwarf.get() == nullptr) {
110+
if (Context->InputDWARFFile.Dwarf == nullptr) {
111111
Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
112112
continue;
113113
}
@@ -203,13 +203,13 @@ Error DWARFLinkerImpl::link() {
203203
Pool.wait();
204204
}
205205

206-
if (ArtificialTypeUnit.get() != nullptr && !ArtificialTypeUnit->getTypePool()
207-
.getRoot()
208-
->getValue()
209-
.load()
210-
->Children.empty()) {
206+
if (ArtificialTypeUnit != nullptr && !ArtificialTypeUnit->getTypePool()
207+
.getRoot()
208+
->getValue()
209+
.load()
210+
->Children.empty()) {
211211
if (GlobalData.getTargetTriple().has_value())
212-
if (Error Err = ArtificialTypeUnit.get()->finishCloningAndEmit(
212+
if (Error Err = ArtificialTypeUnit->finishCloningAndEmit(
213213
(*GlobalData.getTargetTriple()).get()))
214214
return Err;
215215
}
@@ -732,7 +732,7 @@ Error DWARFLinkerImpl::LinkContext::cloneAndEmitDebugFrame() {
732732
if (!GlobalData.getTargetTriple().has_value())
733733
return Error::success();
734734

735-
if (InputDWARFFile.Dwarf.get() == nullptr)
735+
if (InputDWARFFile.Dwarf == nullptr)
736736
return Error::success();
737737

738738
const DWARFObject &InputDWARFObj = InputDWARFFile.Dwarf->getDWARFObj();
@@ -865,7 +865,7 @@ void DWARFLinkerImpl::glueCompileUnitsAndWriteToTheOutput() {
865865
// units into the resulting file.
866866
emitCommonSectionsAndWriteCompileUnitsToTheOutput();
867867

868-
if (ArtificialTypeUnit.get() != nullptr)
868+
if (ArtificialTypeUnit != nullptr)
869869
ArtificialTypeUnit.reset();
870870

871871
// Write common debug sections into the resulting file.
@@ -1018,7 +1018,7 @@ void DWARFLinkerImpl::forEachOutputString(
10181018
});
10191019
});
10201020

1021-
if (ArtificialTypeUnit.get() != nullptr) {
1021+
if (ArtificialTypeUnit != nullptr) {
10221022
ArtificialTypeUnit->forEach([&](SectionDescriptor &OutSection) {
10231023
OutSection.ListDebugStrPatch.forEach([&](DebugStrPatch &Patch) {
10241024
StringHandler(StringDestinationKind::DebugStr, Patch.String);
@@ -1049,7 +1049,7 @@ void DWARFLinkerImpl::forEachOutputString(
10491049
void DWARFLinkerImpl::forEachObjectSectionsSet(
10501050
function_ref<void(OutputSections &)> SectionsSetHandler) {
10511051
// Handle artificial type unit first.
1052-
if (ArtificialTypeUnit.get() != nullptr)
1052+
if (ArtificialTypeUnit != nullptr)
10531053
SectionsSetHandler(*ArtificialTypeUnit);
10541054

10551055
// Then all modules(before regular compilation units).
@@ -1072,7 +1072,7 @@ void DWARFLinkerImpl::forEachObjectSectionsSet(
10721072

10731073
void DWARFLinkerImpl::forEachCompileAndTypeUnit(
10741074
function_ref<void(DwarfUnit *CU)> UnitHandler) {
1075-
if (ArtificialTypeUnit.get() != nullptr)
1075+
if (ArtificialTypeUnit != nullptr)
10761076
UnitHandler(ArtificialTypeUnit.get());
10771077

10781078
// Enumerate module units.
@@ -1348,7 +1348,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
13481348
forEachCompileAndTypeUnit([&](DwarfUnit *CU) {
13491349
bool HasRecords = false;
13501350
CU->forEachAcceleratorRecord([&](const DwarfUnit::AccelInfo &Info) {
1351-
if (DebugNames.get() == nullptr)
1351+
if (DebugNames == nullptr)
13521352
DebugNames = std::make_unique<DWARF5AccelTable>();
13531353

13541354
HasRecords = true;
@@ -1375,7 +1375,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
13751375
}
13761376
});
13771377

1378-
if (DebugNames.get() != nullptr) {
1378+
if (DebugNames != nullptr) {
13791379
// FIXME: we use AsmPrinter to emit accelerator sections.
13801380
// It might be beneficial to directly emit accelerator data
13811381
// to the raw_svector_ostream.

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
13841384
getGenericInstructionUniformity(const MachineInstr &MI) const;
13851385

13861386
const MIRFormatter *getMIRFormatter() const override {
1387-
if (!Formatter.get())
1387+
if (!Formatter)
13881388
Formatter = std::make_unique<AMDGPUMIRFormatter>();
13891389
return Formatter.get();
13901390
}

llvm/tools/bugpoint/BugDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
142142

143143
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
144144
std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context);
145-
if (!M.get())
145+
if (!M)
146146
return true;
147147

148148
outs() << "Linking in input file: '" << Filenames[i] << "'\n";

llvm/tools/llvm-as/llvm-as.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
137137
nullptr, SetDataLayout);
138138
}
139139
std::unique_ptr<Module> M = std::move(ModuleAndIndex.Mod);
140-
if (!M.get()) {
140+
if (!M) {
141141
Err.print(argv[0], errs());
142142
return 1;
143143
}

llvm/tools/llvm-extract/llvm-extract.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
147147
SMDiagnostic Err;
148148
std::unique_ptr<Module> M = getLazyIRFileModule(InputFilename, Err, Context);
149149

150-
if (!M.get()) {
150+
if (!M) {
151151
Err.print(argv[0], errs());
152152
return 1;
153153
}

llvm/tools/llvm-link/llvm-link.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static std::unique_ptr<Module> loadArFile(const char *Argv0,
231231
M = getLazyIRModule(MemoryBuffer::getMemBuffer(MemBuf.get(), false),
232232
ParseErr, Context);
233233

234-
if (!M.get()) {
234+
if (!M) {
235235
errs() << Argv0 << ": ";
236236
WithColor::error() << " parsing member '" << ChildName
237237
<< "' of archive library failed'" << ArchiveName
@@ -417,7 +417,7 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
417417
identify_magic(Buffer->getBuffer()) == file_magic::archive
418418
? loadArFile(argv0, std::move(Buffer), Context)
419419
: loadFile(argv0, std::move(Buffer), Context);
420-
if (!M.get()) {
420+
if (!M) {
421421
errs() << argv0 << ": ";
422422
WithColor::error() << " loading file '" << File << "'\n";
423423
return false;

llvm/tools/verify-uselistorder/verify-uselistorder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const {
176176
LLVM_DEBUG(dbgs() << " - read assembly\n");
177177
SMDiagnostic Err;
178178
std::unique_ptr<Module> M = parseAssemblyFile(Filename, Err, Context);
179-
if (!M.get())
179+
if (!M)
180180
Err.print("verify-uselistorder", errs());
181181
return M;
182182
}
@@ -555,7 +555,7 @@ int main(int argc, char **argv) {
555555
// Load the input module...
556556
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
557557

558-
if (!M.get()) {
558+
if (!M) {
559559
Err.print(argv[0], errs());
560560
return 1;
561561
}

0 commit comments

Comments
 (0)