Author: Gregory Alfonso Date: 2022-12-18T00:33:53Z New Revision: d22f050e15cb8c941d488d9674329db320ef1783
URL: https://github.com/llvm/llvm-project/commit/d22f050e15cb8c941d488d9674329db320ef1783 DIFF: https://github.com/llvm/llvm-project/commit/d22f050e15cb8c941d488d9674329db320ef1783.diff LOG: Remove redundant .c_str() and .get() calls Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D139485 Added: Modified: clang-tools-extra/modularize/ModuleAssistant.cpp clang/lib/Driver/OffloadBundler.cpp clang/lib/Driver/ToolChain.cpp lld/ELF/Writer.cpp llvm/include/llvm/Analysis/RegionInfoImpl.h llvm/include/llvm/MC/MCContext.h llvm/include/llvm/ProfileData/InstrProfReader.h llvm/include/llvm/Support/YAMLParser.h llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp llvm/lib/Target/BPF/BTFDebug.cpp llvm/tools/dsymutil/BinaryHolder.cpp llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp llvm/tools/llvm-cov/CodeCoverage.cpp llvm/tools/obj2yaml/elf2yaml.cpp llvm/tools/obj2yaml/macho2yaml.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp b/clang-tools-extra/modularize/ModuleAssistant.cpp index bdce90726e0a..0d4c09987eb1 100644 --- a/clang-tools-extra/modularize/ModuleAssistant.cpp +++ b/clang-tools-extra/modularize/ModuleAssistant.cpp @@ -305,7 +305,7 @@ bool createModuleMap(llvm::StringRef ModuleMapPath, loadModuleDescriptions( RootModuleName, HeaderFileNames, ProblemFileNames, Dependencies, HeaderPrefix)); - if (!RootModule.get()) + if (!RootModule) return false; // Write module map file. diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index 99f962bba7f5..bcc0c320fa47 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -1183,7 +1183,7 @@ Error OffloadBundler::UnbundleArchive() { assert(FileHandler && "FileHandle creation failed for file in the archive!"); - if (Error ReadErr = FileHandler.get()->ReadHeader(*CodeObjectBuffer)) + if (Error ReadErr = FileHandler->ReadHeader(*CodeObjectBuffer)) return ReadErr; Expected<std::optional<StringRef>> CurBundleIDOrErr = @@ -1208,8 +1208,7 @@ Error OffloadBundler::UnbundleArchive() { BundlerConfig)) { std::string BundleData; raw_string_ostream DataStream(BundleData); - if (Error Err = - FileHandler.get()->ReadBundle(DataStream, *CodeObjectBuffer)) + if (Error Err = FileHandler->ReadBundle(DataStream, *CodeObjectBuffer)) return Err; for (auto &CompatibleTarget : CompatibleTargets) { @@ -1248,7 +1247,7 @@ Error OffloadBundler::UnbundleArchive() { } } - if (Error Err = FileHandler.get()->ReadBundleEnd(*CodeObjectBuffer)) + if (Error Err = FileHandler->ReadBundleEnd(*CodeObjectBuffer)) return Err; Expected<std::optional<StringRef>> NextTripleOrErr = diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 22802b317eaa..7b6de09ee261 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -150,9 +150,9 @@ ToolChain::getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const { } const XRayArgs& ToolChain::getXRayArgs() const { - if (!XRayArguments.get()) + if (!XRayArguments) XRayArguments.reset(new XRayArgs(*this, Args)); - return *XRayArguments.get(); + return *XRayArguments; } namespace { diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index bde60e230ce8..5904a7b85eda 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1031,8 +1031,8 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() { // to the start of the .got or .got.plt section. InputSection *sec = in.gotPlt.get(); if (!target->gotBaseSymInGotPlt) - sec = in.mipsGot.get() ? cast<InputSection>(in.mipsGot.get()) - : cast<InputSection>(in.got.get()); + sec = in.mipsGot ? cast<InputSection>(in.mipsGot.get()) + : cast<InputSection>(in.got.get()); ElfSym::globalOffsetTable->section = sec; } diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h index 7fdfdd0efba8..74591ee25ae5 100644 --- a/llvm/include/llvm/Analysis/RegionInfoImpl.h +++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h @@ -778,12 +778,12 @@ template <class Tr> void RegionInfoBase<Tr>::dump() const { print(dbgs()); } #endif -template <class Tr> -void RegionInfoBase<Tr>::releaseMemory() { +template <class Tr> void RegionInfoBase<Tr>::releaseMemory() { BBtoRegion.clear(); - if (TopLevelRegion) + if (TopLevelRegion) { delete TopLevelRegion; - TopLevelRegion = nullptr; + TopLevelRegion = nullptr; + } } template <class Tr> diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 8b9cc11c7d10..981b3cd570c5 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -190,8 +190,7 @@ class MCContext { SmallString<128> CompilationDir; /// Prefix replacement map for source file information. - std::map<std::string, const std::string, std::greater<std::string>> - DebugPrefixMap; + std::map<std::string, const std::string, std::greater<>> DebugPrefixMap; /// The main file name if passed in explicitly. std::string MainFileName; diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index 527a15ed7d96..ad7ced931c6e 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -256,8 +256,8 @@ class TextInstrProfReader : public InstrProfReader { Error readNextRecord(NamedInstrProfRecord &Record) override; InstrProfSymtab &getSymtab() override { - assert(Symtab.get()); - return *Symtab.get(); + assert(Symtab); + return *Symtab; } }; @@ -700,10 +700,10 @@ class IndexedInstrProfReader : public InstrProfReader { ProfileSummary &getSummary(bool UseCS) { if (UseCS) { assert(CS_Summary && "No context sensitive summary"); - return *(CS_Summary.get()); + return *CS_Summary; } else { assert(Summary && "No profile summary"); - return *(Summary.get()); + return *Summary; } } }; diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index 8c5561e90550..f4767641647c 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -611,7 +611,7 @@ class document_iterator { return *this; } - Document &operator*() { return *Doc->get(); } + Document &operator*() { return **Doc; } std::unique_ptr<Document> &operator->() { return *Doc; } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 522357b7edc1..5e40509b2285 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -591,7 +591,7 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) { bool DWARFUnit::parseDWO(StringRef DWOAlternativeLocation) { if (IsDWO) return false; - if (DWO.get()) + if (DWO) return false; DWARFDie UnitDie = getUnitDIE(); if (!UnitDie) diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp index 8ef4df4beecb..a320752befc4 100644 --- a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp @@ -332,7 +332,7 @@ void LVElement::resolveFullname(LVElement *BaseType, StringRef Name) { "Extra double spaces in name."); LLVM_DEBUG({ dbgs() << "Fullname = '" << Fullname << "'\n"; }); - setName(Fullname.c_str()); + setName(Fullname); } void LVElement::setFile(LVElement *Reference) { diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp index f012bb471be2..fb503f3d3e7e 100644 --- a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp @@ -503,7 +503,7 @@ void LVScope::resolveTemplate() { // Encode the arguments as part of the template name and update the // template name, to reflect the encoded parameters. encodeTemplateArguments(EncodedArgs, &Params); - setEncodedArgs(EncodedArgs.c_str()); + setEncodedArgs(EncodedArgs); } } } @@ -1970,7 +1970,7 @@ void LVScopeFunctionType::resolveExtra() { Name.append(")"); // Update the scope name, to reflect the encoded parameters. - setName(Name.c_str()); + setName(Name); } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp index e41f4e3e3096..b654c624f57c 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp @@ -404,7 +404,7 @@ Error LVBinaryReader::createInstructions(LVScope *Scope, std::string Buffer; raw_string_ostream Stream(Buffer); StringRef AnnotationsStr = Annotations.str(); - MIP.get()->printInst(&Instruction, Address, AnnotationsStr, *STI, Stream); + MIP->printInst(&Instruction, Address, AnnotationsStr, *STI, Stream); LLVM_DEBUG({ std::string BufferCodes; raw_string_ostream StreamCodes(BufferCodes); diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp index bc595aefabc6..d37241682efe 100644 --- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp +++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp @@ -348,7 +348,7 @@ static Expected<Section &> findSection(StringRef SecName, Object &O) { SecName.str().c_str()); assert(FoundSec->get()->CanonicalName == (SegName + "," + SecName).str()); - return *FoundSec->get(); + return **FoundSec; } static Error updateSection(const NewSectionInfo &NewSection, Object &O) { diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp index a949e925eb60..5e00ea858329 100644 --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -1356,7 +1356,7 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) { OS.emitLabel(LineSym); // Construct the lineinfo. - auto SP = DL.get()->getScope()->getSubprogram(); + auto SP = DL->getScope()->getSubprogram(); constructLineInfo(SP, LineSym, DL.getLine(), DL.getCol()); LineInfoGenerated = true; diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp index d16e1d5de22a..d8293f7f354f 100644 --- a/llvm/tools/dsymutil/BinaryHolder.cpp +++ b/llvm/tools/dsymutil/BinaryHolder.cpp @@ -173,7 +173,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, // Try the cache first. std::lock_guard<std::mutex> Lock(MemberCacheMutex); if (MemberCache.count(Key)) - return *MemberCache[Key].get(); + return *MemberCache[Key]; // Create a new ObjectEntry, but don't add it to the cache yet. Loading of // the archive members might fail and we don't want to lock the whole archive diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp index e8990c3fdb0b..fbba8dbc9d02 100644 --- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp +++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp @@ -365,7 +365,7 @@ uint64_t FileAnalysis::indirectCFOperandClobber(const GraphResult &Graph) const void FileAnalysis::printInstruction(const Instr &InstrMeta, raw_ostream &OS) const { - Printer->printInst(&InstrMeta.Instruction, 0, "", *SubtargetInfo.get(), OS); + Printer->printInst(&InstrMeta.Instruction, 0, "", *SubtargetInfo, OS); } Error FileAnalysis::initialiseDisassemblyMembers() { diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 6010362e46ec..2b2eda5d8587 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -1076,7 +1076,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv, FilenameFunctionMap; for (const auto &SourceFile : SourceFiles) for (const auto &Function : Coverage->getCoveredFunctions(SourceFile)) - if (Filters.matches(*Coverage.get(), Function)) + if (Filters.matches(*Coverage, Function)) FilenameFunctionMap[SourceFile].push_back(&Function); // Only print filter matching functions for each file. @@ -1165,7 +1165,7 @@ int CodeCoverageTool::doReport(int argc, const char **argv, if (!Coverage) return 1; - CoverageReport Report(ViewOpts, *Coverage.get()); + CoverageReport Report(ViewOpts, *Coverage); if (!ShowFunctionSummaries) { if (SourceFiles.empty()) Report.renderFileReports(llvm::outs(), IgnoreFilenameFilters); @@ -1231,16 +1231,16 @@ int CodeCoverageTool::doExport(int argc, const char **argv, switch (ViewOpts.Format) { case CoverageViewOptions::OutputFormat::Text: - Exporter = std::make_unique<CoverageExporterJson>(*Coverage.get(), - ViewOpts, outs()); + Exporter = + std::make_unique<CoverageExporterJson>(*Coverage, ViewOpts, outs()); break; case CoverageViewOptions::OutputFormat::HTML: // Unreachable because we should have gracefully terminated with an error // above. llvm_unreachable("Export in HTML is not supported!"); case CoverageViewOptions::OutputFormat::Lcov: - Exporter = std::make_unique<CoverageExporterLcov>(*Coverage.get(), - ViewOpts, outs()); + Exporter = + std::make_unique<CoverageExporterLcov>(*Coverage, ViewOpts, outs()); break; } diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index 0c4e841c4746..efdf5448381a 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -402,10 +402,10 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() { } llvm::erase_if(Chunks, [this, &Y](const std::unique_ptr<ELFYAML::Chunk> &C) { - if (isa<ELFYAML::SectionHeaderTable>(*C.get())) + if (isa<ELFYAML::SectionHeaderTable>(*C)) return false; - const ELFYAML::Section &S = cast<ELFYAML::Section>(*C.get()); + const ELFYAML::Section &S = cast<ELFYAML::Section>(*C); return !shouldPrintSection(S, Sections[S.OriginalSecNdx], Y->DWARF); }); @@ -495,7 +495,7 @@ ELFDumper<ELFT>::dumpProgramHeaders( // It is not possible to have a non-Section chunk, because // obj2yaml does not create Fill chunks. for (const std::unique_ptr<ELFYAML::Chunk> &C : Chunks) { - ELFYAML::Section &S = cast<ELFYAML::Section>(*C.get()); + ELFYAML::Section &S = cast<ELFYAML::Section>(*C); if (isInSegment<ELFT>(S, Sections[S.OriginalSecNdx], Phdr)) { if (!PH.FirstSec) PH.FirstSec = S.Name; @@ -530,13 +530,13 @@ std::optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections( cantFail(std::move(Err)); if (RawSec->Name == ".debug_aranges") - Err = dumpDebugARanges(*DWARFCtx.get(), DWARF); + Err = dumpDebugARanges(*DWARFCtx, DWARF); else if (RawSec->Name == ".debug_str") - Err = dumpDebugStrings(*DWARFCtx.get(), DWARF); + Err = dumpDebugStrings(*DWARFCtx, DWARF); else if (RawSec->Name == ".debug_ranges") - Err = dumpDebugRanges(*DWARFCtx.get(), DWARF); + Err = dumpDebugRanges(*DWARFCtx, DWARF); else if (RawSec->Name == ".debug_addr") - Err = dumpDebugAddr(*DWARFCtx.get(), DWARF); + Err = dumpDebugAddr(*DWARFCtx, DWARF); else continue; diff --git a/llvm/tools/obj2yaml/macho2yaml.cpp b/llvm/tools/obj2yaml/macho2yaml.cpp index 4464f0c49fd1..c96b6cc3acce 100644 --- a/llvm/tools/obj2yaml/macho2yaml.cpp +++ b/llvm/tools/obj2yaml/macho2yaml.cpp @@ -192,7 +192,7 @@ Expected<const char *> MachODumper::extractSections( if (SecName.startswith("__debug_")) { // If the DWARF section cannot be successfully parsed, emit raw content // instead of an entry in the DWARF section of the YAML. - if (Error Err = dumpDebugSection(SecName, *DWARFCtx.get(), Y.DWARF)) + if (Error Err = dumpDebugSection(SecName, *DWARFCtx, Y.DWARF)) consumeError(std::move(Err)); else S->content.reset(); @@ -326,8 +326,7 @@ Error MachODumper::dumpLoadCommands(std::unique_ptr<MachOYAML::Object> &Y) { if (Obj.isLittleEndian() != sys::IsLittleEndianHost) MachO::swapStruct(LC.Data.load_command_data); if (Expected<const char *> ExpectedEndPtr = - processLoadCommandData<MachO::load_command>(LC, LoadCmd, - *Y.get())) + processLoadCommandData<MachO::load_command>(LC, LoadCmd, *Y)) EndPtr = *ExpectedEndPtr; else return ExpectedEndPtr.takeError(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits