[BOLT][NFC] Rename {MachO,}RewriteInstance::create methods
authorAmir Ayupov <aaupov@fb.com>
Wed, 4 May 2022 03:29:13 +0000 (20:29 -0700)
committerAmir Ayupov <aaupov@fb.com>
Thu, 2 Feb 2023 20:30:45 +0000 (12:30 -0800)
Follow the code style of fallible constructors in [LLVM Programmer's Manual]
(https://llvm.org/docs/ProgrammersManual.html#fallible-constructors)
and rename `RewriteInstance::createRewriteInstance` to `RewriteInstance::create`

Reviewed By: #bolt, rafauler

Differential Revision: https://reviews.llvm.org/D143119

bolt/include/bolt/Rewrite/MachORewriteInstance.h
bolt/include/bolt/Rewrite/RewriteInstance.h
bolt/lib/Rewrite/MachORewriteInstance.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
bolt/tools/driver/llvm-bolt.cpp
bolt/tools/heatmap/heatmap.cpp
bolt/tools/llvm-bolt-fuzzer/llvm-bolt-fuzzer.cpp

index 27ca6ff..6071c89 100644 (file)
@@ -68,13 +68,12 @@ class MachORewriteInstance {
 public:
   // This constructor has complex initialization that can fail during
   // construction. Constructors can’t return errors, so clients must test \p Err
-  // after the object is constructed. Use createMachORewriteInstance instead.
+  // after the object is constructed. Use `create` method instead.
   MachORewriteInstance(object::MachOObjectFile *InputFile, StringRef ToolPath,
                        Error &Err);
 
   static Expected<std::unique_ptr<MachORewriteInstance>>
-  createMachORewriteInstance(object::MachOObjectFile *InputFile,
-                             StringRef ToolPath);
+  create(object::MachOObjectFile *InputFile, StringRef ToolPath);
   ~MachORewriteInstance();
 
   Error setProfile(StringRef FileName);
index 7cfdb57..a0ce545 100644 (file)
@@ -43,13 +43,13 @@ class RewriteInstance {
 public:
   // This constructor has complex initialization that can fail during
   // construction. Constructors can’t return errors, so clients must test \p Err
-  // after the object is constructed. Use createRewriteInstance instead.
+  // after the object is constructed. Use `create` method instead.
   RewriteInstance(llvm::object::ELFObjectFileBase *File, const int Argc,
                   const char *const *Argv, StringRef ToolPath, Error &Err);
 
   static Expected<std::unique_ptr<RewriteInstance>>
-  createRewriteInstance(llvm::object::ELFObjectFileBase *File, const int Argc,
-                        const char *const *Argv, StringRef ToolPath);
+  create(llvm::object::ELFObjectFileBase *File, const int Argc,
+         const char *const *Argv, StringRef ToolPath);
   ~RewriteInstance();
 
   /// Assign profile from \p Filename to this instance.
index cdc064c..f1f20f2 100644 (file)
@@ -85,8 +85,8 @@ MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
 #define DEBUG_TYPE "bolt"
 
 Expected<std::unique_ptr<MachORewriteInstance>>
-MachORewriteInstance::createMachORewriteInstance(
-    object::MachOObjectFile *InputFile, StringRef ToolPath) {
+MachORewriteInstance::create(object::MachOObjectFile *InputFile,
+                             StringRef ToolPath) {
   Error Err = Error::success();
   auto MachORI =
       std::make_unique<MachORewriteInstance>(InputFile, ToolPath, Err);
index 52043d0..b7d9593 100644 (file)
@@ -311,9 +311,8 @@ bool refersToReorderedSection(ErrorOr<BinarySection &> Section) {
 } // anonymous namespace
 
 Expected<std::unique_ptr<RewriteInstance>>
-RewriteInstance::createRewriteInstance(ELFObjectFileBase *File, const int Argc,
-                                       const char *const *Argv,
-                                       StringRef ToolPath) {
+RewriteInstance::create(ELFObjectFileBase *File, const int Argc,
+                        const char *const *Argv, StringRef ToolPath) {
   Error Err = Error::success();
   auto RI = std::make_unique<RewriteInstance>(File, Argc, Argv, ToolPath, Err);
   if (Err)
index e7517d1..5a3af6a 100644 (file)
@@ -216,8 +216,7 @@ int main(int argc, char **argv) {
     Binary &Binary = *BinaryOrErr.get().getBinary();
 
     if (auto *e = dyn_cast<ELFObjectFileBase>(&Binary)) {
-      auto RIOrErr =
-          RewriteInstance::createRewriteInstance(e, argc, argv, ToolPath);
+      auto RIOrErr = RewriteInstance::create(e, argc, argv, ToolPath);
       if (Error E = RIOrErr.takeError())
         report_error(opts::InputFilename, std::move(E));
       RewriteInstance &RI = *RIOrErr.get();
@@ -244,8 +243,7 @@ int main(int argc, char **argv) {
       if (Error E = RI.run())
         report_error(opts::InputFilename, std::move(E));
     } else if (auto *O = dyn_cast<MachOObjectFile>(&Binary)) {
-      auto MachORIOrErr =
-          MachORewriteInstance::createMachORewriteInstance(O, ToolPath);
+      auto MachORIOrErr = MachORewriteInstance::create(O, ToolPath);
       if (Error E = MachORIOrErr.takeError())
         report_error(opts::InputFilename, std::move(E));
       MachORewriteInstance &MachORI = *MachORIOrErr.get();
@@ -275,15 +273,13 @@ int main(int argc, char **argv) {
   Binary &Binary2 = *BinaryOrErr2.get().getBinary();
   if (auto *ELFObj1 = dyn_cast<ELFObjectFileBase>(&Binary1)) {
     if (auto *ELFObj2 = dyn_cast<ELFObjectFileBase>(&Binary2)) {
-      auto RI1OrErr =
-          RewriteInstance::createRewriteInstance(ELFObj1, argc, argv, ToolPath);
+      auto RI1OrErr = RewriteInstance::create(ELFObj1, argc, argv, ToolPath);
       if (Error E = RI1OrErr.takeError())
         report_error(opts::InputFilename, std::move(E));
       RewriteInstance &RI1 = *RI1OrErr.get();
       if (Error E = RI1.setProfile(opts::InputDataFilename))
         report_error(opts::InputDataFilename, std::move(E));
-      auto RI2OrErr =
-          RewriteInstance::createRewriteInstance(ELFObj2, argc, argv, ToolPath);
+      auto RI2OrErr = RewriteInstance::create(ELFObj2, argc, argv, ToolPath);
       if (Error E = RI2OrErr.takeError())
         report_error(opts::InputFilename2, std::move(E));
       RewriteInstance &RI2 = *RI2OrErr.get();
index b49245e..f5204fa 100644 (file)
@@ -85,8 +85,7 @@ int main(int argc, char **argv) {
   Binary &Binary = *BinaryOrErr.get().getBinary();
 
   if (auto *e = dyn_cast<ELFObjectFileBase>(&Binary)) {
-    auto RIOrErr =
-        RewriteInstance::createRewriteInstance(e, argc, argv, ToolPath);
+    auto RIOrErr = RewriteInstance::create(e, argc, argv, ToolPath);
     if (Error E = RIOrErr.takeError())
       report_error("RewriteInstance", std::move(E));
 
index 4f2abfa..bdb5768 100644 (file)
@@ -45,8 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
     return 0;
 
   // Fuzz RewriteInstance.
-  auto RIOrErr =
-      RewriteInstance::createRewriteInstance(E, argc, argv, "llvm-bolt");
+  auto RIOrErr = RewriteInstance::create(E, argc, argv, "llvm-bolt");
   if (Error E = RIOrErr.takeError()) {
     consumeError(std::move(E));
     return 0;