[PATCH] D139286: [LLVM] Fix Bug introduced from "[DebugInfo] llvm::Optional => std::optional"

Qfrost via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 4 19:22:23 PST 2022


Qfrost911 created this revision.
Qfrost911 added a reviewer: MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
Qfrost911 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In `[DebugInfo] llvm::Optional => std::optional (Git Hash:89fab98e884f05076bbd420d95b5de3596f5452c)`, he have converted all of defines of functions from `llvm::Optional` to `std::optional`, including function `llvm::TargetMachine *llvm::Target::createTargetMachine`

But in the `llvm\examples\Kaleidoscope\Chapter8\toy.cpp`, the type of `RM` is `llvm::Optional<Reloc::Model>`, when this variable is passed in as a parameter to the `llvm::TargetMachine *llvm::Target::createTargetMachine`, an error will be raised.

  error C2664: “llvm::TargetMachine *llvm::Target::createTargetMachine(llvm::StringRef,llvm::StringRef,llvm::StringRef,const llvm::TargetOptions &,std::optional<llvm::Reloc::Model>,std::optional<llvm::CodeModel::Model>,llvm::CodeGenOpt::Level,bool) const”: Unable to convert parameter 5 from "llvm::Optional<llvm::Reloc::Model>" to "std::optional<llvm::Reloc::Model>"

My patch modified the type of RM from `llvm::Optional<llvm::Reloc::Model>` to `std::optional<Reloc::Model>`

Additionally, my build environment is VisualStudio2019, I didn't know why his revision passed the CI.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139286

Files:
  llvm/examples/Kaleidoscope/Chapter8/toy.cpp


Index: llvm/examples/Kaleidoscope/Chapter8/toy.cpp
===================================================================
--- llvm/examples/Kaleidoscope/Chapter8/toy.cpp
+++ llvm/examples/Kaleidoscope/Chapter8/toy.cpp
@@ -30,6 +30,7 @@
 #include <system_error>
 #include <utility>
 #include <vector>
+#include <optional>
 
 using namespace llvm;
 using namespace llvm::sys;
@@ -1243,7 +1244,7 @@
   auto Features = "";
 
   TargetOptions opt;
-  auto RM = Optional<Reloc::Model>();
+  std::optional<Reloc::Model> RM;
   auto TheTargetMachine =
       Target->createTargetMachine(TargetTriple, CPU, Features, opt, RM);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139286.479961.patch
Type: text/x-patch
Size: 617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221205/99f2407c/attachment.bin>


More information about the llvm-commits mailing list