[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#97778)
This commit is contained in:
@@ -2214,7 +2214,7 @@ public:
|
||||
/// Return MIR formatter to format/parse MIR operands. Target can override
|
||||
/// this virtual function and return target specific MIR formatter.
|
||||
virtual const MIRFormatter *getMIRFormatter() const {
|
||||
if (!Formatter.get())
|
||||
if (!Formatter)
|
||||
Formatter = std::make_unique<MIRFormatter>();
|
||||
return Formatter.get();
|
||||
}
|
||||
|
||||
@@ -1833,7 +1833,7 @@ TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() {
|
||||
|
||||
bool CompileUnit::resolveDependenciesAndMarkLiveness(
|
||||
bool InterCUProcessingStarted, std::atomic<bool> &HasNewInterconnectedCUs) {
|
||||
if (!Dependencies.get())
|
||||
if (!Dependencies)
|
||||
Dependencies.reset(new DependencyTracker(*this));
|
||||
|
||||
return Dependencies->resolveDependenciesAndMarkLiveness(
|
||||
|
||||
@@ -107,7 +107,7 @@ Error DWARFLinkerImpl::link() {
|
||||
std::optional<uint16_t> Language;
|
||||
|
||||
for (std::unique_ptr<LinkContext> &Context : ObjectContexts) {
|
||||
if (Context->InputDWARFFile.Dwarf.get() == nullptr) {
|
||||
if (Context->InputDWARFFile.Dwarf == nullptr) {
|
||||
Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
|
||||
continue;
|
||||
}
|
||||
@@ -203,13 +203,13 @@ Error DWARFLinkerImpl::link() {
|
||||
Pool.wait();
|
||||
}
|
||||
|
||||
if (ArtificialTypeUnit.get() != nullptr && !ArtificialTypeUnit->getTypePool()
|
||||
.getRoot()
|
||||
->getValue()
|
||||
.load()
|
||||
->Children.empty()) {
|
||||
if (ArtificialTypeUnit != nullptr && !ArtificialTypeUnit->getTypePool()
|
||||
.getRoot()
|
||||
->getValue()
|
||||
.load()
|
||||
->Children.empty()) {
|
||||
if (GlobalData.getTargetTriple().has_value())
|
||||
if (Error Err = ArtificialTypeUnit.get()->finishCloningAndEmit(
|
||||
if (Error Err = ArtificialTypeUnit->finishCloningAndEmit(
|
||||
(*GlobalData.getTargetTriple()).get()))
|
||||
return Err;
|
||||
}
|
||||
@@ -732,7 +732,7 @@ Error DWARFLinkerImpl::LinkContext::cloneAndEmitDebugFrame() {
|
||||
if (!GlobalData.getTargetTriple().has_value())
|
||||
return Error::success();
|
||||
|
||||
if (InputDWARFFile.Dwarf.get() == nullptr)
|
||||
if (InputDWARFFile.Dwarf == nullptr)
|
||||
return Error::success();
|
||||
|
||||
const DWARFObject &InputDWARFObj = InputDWARFFile.Dwarf->getDWARFObj();
|
||||
@@ -865,7 +865,7 @@ void DWARFLinkerImpl::glueCompileUnitsAndWriteToTheOutput() {
|
||||
// units into the resulting file.
|
||||
emitCommonSectionsAndWriteCompileUnitsToTheOutput();
|
||||
|
||||
if (ArtificialTypeUnit.get() != nullptr)
|
||||
if (ArtificialTypeUnit != nullptr)
|
||||
ArtificialTypeUnit.reset();
|
||||
|
||||
// Write common debug sections into the resulting file.
|
||||
@@ -1018,7 +1018,7 @@ void DWARFLinkerImpl::forEachOutputString(
|
||||
});
|
||||
});
|
||||
|
||||
if (ArtificialTypeUnit.get() != nullptr) {
|
||||
if (ArtificialTypeUnit != nullptr) {
|
||||
ArtificialTypeUnit->forEach([&](SectionDescriptor &OutSection) {
|
||||
OutSection.ListDebugStrPatch.forEach([&](DebugStrPatch &Patch) {
|
||||
StringHandler(StringDestinationKind::DebugStr, Patch.String);
|
||||
@@ -1049,7 +1049,7 @@ void DWARFLinkerImpl::forEachOutputString(
|
||||
void DWARFLinkerImpl::forEachObjectSectionsSet(
|
||||
function_ref<void(OutputSections &)> SectionsSetHandler) {
|
||||
// Handle artificial type unit first.
|
||||
if (ArtificialTypeUnit.get() != nullptr)
|
||||
if (ArtificialTypeUnit != nullptr)
|
||||
SectionsSetHandler(*ArtificialTypeUnit);
|
||||
|
||||
// Then all modules(before regular compilation units).
|
||||
@@ -1072,7 +1072,7 @@ void DWARFLinkerImpl::forEachObjectSectionsSet(
|
||||
|
||||
void DWARFLinkerImpl::forEachCompileAndTypeUnit(
|
||||
function_ref<void(DwarfUnit *CU)> UnitHandler) {
|
||||
if (ArtificialTypeUnit.get() != nullptr)
|
||||
if (ArtificialTypeUnit != nullptr)
|
||||
UnitHandler(ArtificialTypeUnit.get());
|
||||
|
||||
// Enumerate module units.
|
||||
@@ -1348,7 +1348,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
|
||||
forEachCompileAndTypeUnit([&](DwarfUnit *CU) {
|
||||
bool HasRecords = false;
|
||||
CU->forEachAcceleratorRecord([&](const DwarfUnit::AccelInfo &Info) {
|
||||
if (DebugNames.get() == nullptr)
|
||||
if (DebugNames == nullptr)
|
||||
DebugNames = std::make_unique<DWARF5AccelTable>();
|
||||
|
||||
HasRecords = true;
|
||||
@@ -1375,7 +1375,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
|
||||
}
|
||||
});
|
||||
|
||||
if (DebugNames.get() != nullptr) {
|
||||
if (DebugNames != nullptr) {
|
||||
// FIXME: we use AsmPrinter to emit accelerator sections.
|
||||
// It might be beneficial to directly emit accelerator data
|
||||
// to the raw_svector_ostream.
|
||||
|
||||
@@ -1384,7 +1384,7 @@ public:
|
||||
getGenericInstructionUniformity(const MachineInstr &MI) const;
|
||||
|
||||
const MIRFormatter *getMIRFormatter() const override {
|
||||
if (!Formatter.get())
|
||||
if (!Formatter)
|
||||
Formatter = std::make_unique<AMDGPUMIRFormatter>();
|
||||
return Formatter.get();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
|
||||
|
||||
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
|
||||
std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context);
|
||||
if (!M.get())
|
||||
if (!M)
|
||||
return true;
|
||||
|
||||
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
|
||||
|
||||
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
|
||||
nullptr, SetDataLayout);
|
||||
}
|
||||
std::unique_ptr<Module> M = std::move(ModuleAndIndex.Mod);
|
||||
if (!M.get()) {
|
||||
if (!M) {
|
||||
Err.print(argv[0], errs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
|
||||
SMDiagnostic Err;
|
||||
std::unique_ptr<Module> M = getLazyIRFileModule(InputFilename, Err, Context);
|
||||
|
||||
if (!M.get()) {
|
||||
if (!M) {
|
||||
Err.print(argv[0], errs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ static std::unique_ptr<Module> loadArFile(const char *Argv0,
|
||||
M = getLazyIRModule(MemoryBuffer::getMemBuffer(MemBuf.get(), false),
|
||||
ParseErr, Context);
|
||||
|
||||
if (!M.get()) {
|
||||
if (!M) {
|
||||
errs() << Argv0 << ": ";
|
||||
WithColor::error() << " parsing member '" << ChildName
|
||||
<< "' of archive library failed'" << ArchiveName
|
||||
@@ -417,7 +417,7 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
|
||||
identify_magic(Buffer->getBuffer()) == file_magic::archive
|
||||
? loadArFile(argv0, std::move(Buffer), Context)
|
||||
: loadFile(argv0, std::move(Buffer), Context);
|
||||
if (!M.get()) {
|
||||
if (!M) {
|
||||
errs() << argv0 << ": ";
|
||||
WithColor::error() << " loading file '" << File << "'\n";
|
||||
return false;
|
||||
|
||||
@@ -176,7 +176,7 @@ std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const {
|
||||
LLVM_DEBUG(dbgs() << " - read assembly\n");
|
||||
SMDiagnostic Err;
|
||||
std::unique_ptr<Module> M = parseAssemblyFile(Filename, Err, Context);
|
||||
if (!M.get())
|
||||
if (!M)
|
||||
Err.print("verify-uselistorder", errs());
|
||||
return M;
|
||||
}
|
||||
@@ -555,7 +555,7 @@ int main(int argc, char **argv) {
|
||||
// Load the input module...
|
||||
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
|
||||
|
||||
if (!M.get()) {
|
||||
if (!M) {
|
||||
Err.print(argv[0], errs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user