This is an archive of the discontinued LLVM Phabricator instance.

[LLVM] Fix Bug introduced from "llvm::Optional => std::optional"
AcceptedPublic

Authored by Qfrost911 on Dec 4 2022, 7:22 PM.

Details

Summary

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.

Diff Detail

Event Timeline

Qfrost911 created this revision.Dec 4 2022, 7:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 7:22 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
Qfrost911 requested review of this revision.Dec 4 2022, 7:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 7:22 PM
Qfrost911 retitled this revision from [LLVM] Fix Bug introduced from "[DebugInfo] llvm::Optional => std::optional" to [LLVM] Fix Bug introduced from "llvm::Optional => std::optional".Dec 4 2022, 10:06 PM
Qfrost911 added a reviewer: aaron.ballman.
MaskRay accepted this revision.Dec 4 2022, 10:37 PM

Thanks! LLVM_INCLUDE_EXAMPLES=off is the default, so I didn't notice this.

This revision is now accepted and ready to land.Dec 4 2022, 10:37 PM
Qfrost911 updated this revision to Diff 479986.Dec 4 2022, 10:53 PM

Adjust clang-format