-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) #97778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_clang_tidy_readability_redundant_smartptr_get
Jul 6, 2024
Merged
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) #97778
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_clang_tidy_readability_redundant_smartptr_get
Jul 6, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-amdgpu Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/97778.diff 9 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 75cb17f357241d..5c7f6ddc948402 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -2214,7 +2214,7 @@ class TargetInstrInfo : public MCInstrInfo {
/// 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();
}
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
index 8a7313628b9926..0cb9cd5f9ea31d 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -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(
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index c060f8f4c1718b..84fd0806f07050 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -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.
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 84bb73cc9a796a..1e2b687854c77a 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -1384,7 +1384,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
getGenericInstructionUniformity(const MachineInstr &MI) const;
const MIRFormatter *getMIRFormatter() const override {
- if (!Formatter.get())
+ if (!Formatter)
Formatter = std::make_unique<AMDGPUMIRFormatter>();
return Formatter.get();
}
diff --git a/llvm/tools/bugpoint/BugDriver.cpp b/llvm/tools/bugpoint/BugDriver.cpp
index 32c747fdd51665..f9b8d09501672c 100644
--- a/llvm/tools/bugpoint/BugDriver.cpp
+++ b/llvm/tools/bugpoint/BugDriver.cpp
@@ -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";
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index 082565a9ef3d98..9b9af762676195 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -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;
}
diff --git a/llvm/tools/llvm-extract/llvm-extract.cpp b/llvm/tools/llvm-extract/llvm-extract.cpp
index 5915f92ea05c3b..4ee644f1e29060 100644
--- a/llvm/tools/llvm-extract/llvm-extract.cpp
+++ b/llvm/tools/llvm-extract/llvm-extract.cpp
@@ -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;
}
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 24ee02be7e9ee6..b311820ce58709 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -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;
diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index 84fc777e1fdff1..f316bff1e49a51 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -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;
}
|
MaskRay
approved these changes
Jul 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.