This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd22f050e15cb: Remove redundant .c_str() and .get() calls 
(authored by gAlfonso-bit, committed by MaskRay).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D139485?vs=481954&id=483789#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139485/new/

https://reviews.llvm.org/D139485

Files:
  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

Index: llvm/tools/obj2yaml/macho2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/macho2yaml.cpp
+++ llvm/tools/obj2yaml/macho2yaml.cpp
@@ -192,7 +192,7 @@
       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 @@
       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();
Index: llvm/tools/obj2yaml/elf2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -402,10 +402,10 @@
   }
 
   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 @@
     // 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 @@
       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;
 
Index: llvm/tools/llvm-cov/CodeCoverage.cpp
===================================================================
--- llvm/tools/llvm-cov/CodeCoverage.cpp
+++ llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -1076,7 +1076,7 @@
         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 @@
   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 @@
 
   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;
   }
 
Index: llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
===================================================================
--- llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
+++ llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
@@ -365,7 +365,7 @@
 
 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() {
Index: llvm/tools/dsymutil/BinaryHolder.cpp
===================================================================
--- llvm/tools/dsymutil/BinaryHolder.cpp
+++ llvm/tools/dsymutil/BinaryHolder.cpp
@@ -173,7 +173,7 @@
   // 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
Index: llvm/lib/Target/BPF/BTFDebug.cpp
===================================================================
--- llvm/lib/Target/BPF/BTFDebug.cpp
+++ llvm/lib/Target/BPF/BTFDebug.cpp
@@ -1356,7 +1356,7 @@
   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;
Index: llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -348,7 +348,7 @@
                              SecName.str().c_str());
 
   assert(FoundSec->get()->CanonicalName == (SegName + "," + SecName).str());
-  return *FoundSec->get();
+  return **FoundSec;
 }
 
 static Error updateSection(const NewSectionInfo &NewSection, Object &O) {
Index: llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
===================================================================
--- llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
+++ llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
@@ -404,7 +404,7 @@
       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);
Index: llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
===================================================================
--- llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
+++ llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
@@ -503,7 +503,7 @@
       // 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 @@
   Name.append(")");
 
   // Update the scope name, to reflect the encoded parameters.
-  setName(Name.c_str());
+  setName(Name);
 }
 
 //===----------------------------------------------------------------------===//
Index: llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
===================================================================
--- llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
+++ llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
@@ -332,7 +332,7 @@
          "Extra double spaces in name.");
 
   LLVM_DEBUG({ dbgs() << "Fullname = '" << Fullname << "'\n"; });
-  setName(Fullname.c_str());
+  setName(Fullname);
 }
 
 void LVElement::setFile(LVElement *Reference) {
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -591,7 +591,7 @@
 bool DWARFUnit::parseDWO(StringRef DWOAlternativeLocation) {
   if (IsDWO)
     return false;
-  if (DWO.get())
+  if (DWO)
     return false;
   DWARFDie UnitDie = getUnitDIE();
   if (!UnitDie)
Index: llvm/include/llvm/Support/YAMLParser.h
===================================================================
--- llvm/include/llvm/Support/YAMLParser.h
+++ llvm/include/llvm/Support/YAMLParser.h
@@ -611,7 +611,7 @@
     return *this;
   }
 
-  Document &operator*() { return *Doc->get(); }
+  Document &operator*() { return **Doc; }
 
   std::unique_ptr<Document> &operator->() { return *Doc; }
 
Index: llvm/include/llvm/ProfileData/InstrProfReader.h
===================================================================
--- llvm/include/llvm/ProfileData/InstrProfReader.h
+++ llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -256,8 +256,8 @@
   Error readNextRecord(NamedInstrProfRecord &Record) override;
 
   InstrProfSymtab &getSymtab() override {
-    assert(Symtab.get());
-    return *Symtab.get();
+    assert(Symtab);
+    return *Symtab;
   }
 };
 
@@ -700,10 +700,10 @@
   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;
     }
   }
 };
Index: llvm/include/llvm/MC/MCContext.h
===================================================================
--- llvm/include/llvm/MC/MCContext.h
+++ llvm/include/llvm/MC/MCContext.h
@@ -190,8 +190,7 @@
   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;
Index: llvm/include/llvm/Analysis/RegionInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -778,12 +778,12 @@
 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>
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -1031,8 +1031,8 @@
     // 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;
   }
 
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -150,9 +150,9 @@
 }
 
 const XRayArgs& ToolChain::getXRayArgs() const {
-  if (!XRayArguments.get())
+  if (!XRayArguments)
     XRayArguments.reset(new XRayArgs(*this, Args));
-  return *XRayArguments.get();
+  return *XRayArguments;
 }
 
 namespace {
Index: clang/lib/Driver/OffloadBundler.cpp
===================================================================
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -1183,7 +1183,7 @@
     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 @@
                                              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 @@
         }
       }
 
-      if (Error Err = FileHandler.get()->ReadBundleEnd(*CodeObjectBuffer))
+      if (Error Err = FileHandler->ReadBundleEnd(*CodeObjectBuffer))
         return Err;
 
       Expected<std::optional<StringRef>> NextTripleOrErr =
Index: clang-tools-extra/modularize/ModuleAssistant.cpp
===================================================================
--- clang-tools-extra/modularize/ModuleAssistant.cpp
+++ clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -305,7 +305,7 @@
     loadModuleDescriptions(
       RootModuleName, HeaderFileNames, ProblemFileNames, Dependencies,
       HeaderPrefix));
-  if (!RootModule.get())
+  if (!RootModule)
     return false;
 
   // Write module map file.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to