[BOLT][NFC] Use std::optional in RI
authorAmir Ayupov <aaupov@fb.com>
Sun, 11 Dec 2022 20:28:08 +0000 (12:28 -0800)
committerAmir Ayupov <aaupov@fb.com>
Mon, 12 Dec 2022 06:13:46 +0000 (22:13 -0800)
bolt/include/bolt/Rewrite/RewriteInstance.h
bolt/lib/Rewrite/RewriteInstance.cpp

index 1abad87..91cc41f 100644 (file)
@@ -81,7 +81,7 @@ public:
   /// The build-id is typically a stream of 20 bytes. Return these bytes in
   /// printable hexadecimal form if they are available, or std::nullopt
   /// otherwise.
-  Optional<std::string> getPrintableBuildID() const;
+  std::optional<std::string> getPrintableBuildID() const;
 
   /// If this instance uses a profile, return appropriate profile reader.
   const ProfileReaderBase *getProfileReader() const {
@@ -475,12 +475,12 @@ private:
   uint64_t NextAvailableAddress{0};
 
   /// Location and size of dynamic relocations.
-  Optional<uint64_t> DynamicRelocationsAddress;
+  std::optional<uint64_t> DynamicRelocationsAddress;
   uint64_t DynamicRelocationsSize{0};
   uint64_t DynamicRelativeRelocationsCount{0};
 
   /// PLT relocations are special kind of dynamic relocations stored separately.
-  Optional<uint64_t> PLTRelocationsAddress;
+  std::optional<uint64_t> PLTRelocationsAddress;
   uint64_t PLTRelocationsSize{0};
 
   /// True if relocation of specified type came from .rela.plt
index 774a4d3..f5542c9 100644 (file)
@@ -30,7 +30,6 @@
 #include "bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h"
 #include "bolt/Utils/CommandLineOpts.h"
 #include "bolt/Utils/Utils.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h"
@@ -679,7 +678,7 @@ void RewriteInstance::parseBuildID() {
   BuildID = Buf.slice(Offset, Offset + DescSz);
 }
 
-Optional<std::string> RewriteInstance::getPrintableBuildID() const {
+std::optional<std::string> RewriteInstance::getPrintableBuildID() const {
   if (BuildID.empty())
     return std::nullopt;
 
@@ -1683,7 +1682,7 @@ Error RewriteInstance::readSpecialSections() {
 
   // Parse build-id
   parseBuildID();
-  if (Optional<std::string> FileBuildID = getPrintableBuildID())
+  if (std::optional<std::string> FileBuildID = getPrintableBuildID())
     BC->setFileBuildID(*FileBuildID);
 
   parseSDTNotes();