[llvm] e842c06 - [IR] Use std::nullopt instead of None (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 20:05:27 PST 2022
Author: Kazu Hirata
Date: 2022-12-02T20:05:20-08:00
New Revision: e842c06c2d52ae1d60db7ed528ea3f4215a0aad6
URL: https://github.com/llvm/llvm-project/commit/e842c06c2d52ae1d60db7ed528ea3f4215a0aad6
DIFF: https://github.com/llvm/llvm-project/commit/e842c06c2d52ae1d60db7ed528ea3f4215a0aad6.diff
LOG: [IR] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/GCStrategy.h
llvm/include/llvm/IR/GlobalVariable.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/Instructions.h
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/IR/Metadata.h
llvm/include/llvm/IR/ModuleSummaryIndex.h
llvm/include/llvm/IR/Operator.h
llvm/include/llvm/IR/VPIntrinsics.def
llvm/include/llvm/IR/ValueMap.h
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/ConstantRange.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/ConstantsContext.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/FPEnv.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/IR/MDBuilder.cpp
llvm/lib/IR/Metadata.cpp
llvm/lib/IR/Module.cpp
llvm/lib/IR/Operator.cpp
llvm/lib/IR/PseudoProbe.cpp
llvm/lib/IR/Type.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index e4ddbbe6f3e90..b3b46385c90fe 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1215,30 +1215,30 @@ class ConstantExpr : public Constant {
///
/// \param InRangeIndex the inrange index if present or None.
/// \param OnlyIfReducedTy see \a getWithOperands() docs.
- static Constant *getGetElementPtr(Type *Ty, Constant *C,
- ArrayRef<Constant *> IdxList,
- bool InBounds = false,
- Optional<unsigned> InRangeIndex = None,
- Type *OnlyIfReducedTy = nullptr) {
+ static Constant *
+ getGetElementPtr(Type *Ty, Constant *C, ArrayRef<Constant *> IdxList,
+ bool InBounds = false,
+ Optional<unsigned> InRangeIndex = std::nullopt,
+ Type *OnlyIfReducedTy = nullptr) {
return getGetElementPtr(
Ty, C, makeArrayRef((Value *const *)IdxList.data(), IdxList.size()),
InBounds, InRangeIndex, OnlyIfReducedTy);
}
- static Constant *getGetElementPtr(Type *Ty, Constant *C, Constant *Idx,
- bool InBounds = false,
- Optional<unsigned> InRangeIndex = None,
- Type *OnlyIfReducedTy = nullptr) {
+ static Constant *
+ getGetElementPtr(Type *Ty, Constant *C, Constant *Idx, bool InBounds = false,
+ Optional<unsigned> InRangeIndex = std::nullopt,
+ Type *OnlyIfReducedTy = nullptr) {
// This form of the function only exists to avoid ambiguous overload
// warnings about whether to convert Idx to ArrayRef<Constant *> or
// ArrayRef<Value *>.
return getGetElementPtr(Ty, C, cast<Value>(Idx), InBounds, InRangeIndex,
OnlyIfReducedTy);
}
- static Constant *getGetElementPtr(Type *Ty, Constant *C,
- ArrayRef<Value *> IdxList,
- bool InBounds = false,
- Optional<unsigned> InRangeIndex = None,
- Type *OnlyIfReducedTy = nullptr);
+ static Constant *
+ getGetElementPtr(Type *Ty, Constant *C, ArrayRef<Value *> IdxList,
+ bool InBounds = false,
+ Optional<unsigned> InRangeIndex = std::nullopt,
+ Type *OnlyIfReducedTy = nullptr);
/// Create an "inbounds" getelementptr. See the documentation for the
/// "inbounds" flag in LangRef.html for details.
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index ef64fcd8cb924..81ead0cf067dc 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -173,10 +173,10 @@ namespace llvm {
/// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.)
/// and value.
/// \param Source Optional source text.
- DIFile *
- createFile(StringRef Filename, StringRef Directory,
- Optional<DIFile::ChecksumInfo<StringRef>> Checksum = None,
- Optional<StringRef> Source = None);
+ DIFile *createFile(
+ StringRef Filename, StringRef Directory,
+ Optional<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt,
+ Optional<StringRef> Source = std::nullopt);
/// Create debugging information entry for a macro.
/// \param Parent Macro parent (could be nullptr).
@@ -256,7 +256,7 @@ namespace llvm {
DIDerivedType *
createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
uint32_t AlignInBits = 0,
- Optional<unsigned> DWARFAddressSpace = None,
+ Optional<unsigned> DWARFAddressSpace = std::nullopt,
StringRef Name = "", DINodeArray Annotations = nullptr);
/// Create debugging information entry for a pointer to member.
@@ -271,11 +271,10 @@ namespace llvm {
/// Create debugging information entry for a c++
/// style reference or rvalue reference type.
- DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy,
- uint64_t SizeInBits = 0,
- uint32_t AlignInBits = 0,
- Optional<unsigned> DWARFAddressSpace =
- None);
+ DIDerivedType *
+ createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits = 0,
+ uint32_t AlignInBits = 0,
+ Optional<unsigned> DWARFAddressSpace = std::nullopt);
/// Create debugging information entry for a typedef.
/// \param Ty Original type.
@@ -732,7 +731,7 @@ namespace llvm {
/// Create a new descriptor for the specified
/// variable which has a complex address expression for its address.
/// \param Addr An array of complex address operations.
- DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
+ DIExpression *createExpression(ArrayRef<uint64_t> Addr = std::nullopt);
/// Create an expression for a variable that does not have an address, but
/// does have a constant value.
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 8731f3915919b..c4d60fbaef597 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -134,7 +134,7 @@ class DINode : public MDNode {
protected:
DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
- ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
+ ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = std::nullopt)
: MDNode(C, ID, Storage, Ops1, Ops2) {
assert(Tag < 1u << 16);
SubclassData16 = Tag;
@@ -305,7 +305,7 @@ class DIAssignID : public MDNode {
friend class MDNode;
DIAssignID(LLVMContext &C, StorageType Storage)
- : MDNode(C, DIAssignIDKind, Storage, None) {}
+ : MDNode(C, DIAssignIDKind, Storage, std::nullopt) {}
~DIAssignID() { dropAllReferences(); }
@@ -617,7 +617,7 @@ class DIFile : public DIScope {
Context, getCanonicalMDString(Context, Filename),
getCanonicalMDString(Context, Directory), MDChecksum,
Source ? Optional<MDString *>(getCanonicalMDString(Context, *Source))
- : None,
+ : std::nullopt,
Storage, ShouldCreate);
}
static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
@@ -634,13 +634,13 @@ class DIFile : public DIScope {
public:
DEFINE_MDNODE_GET(DIFile,
(StringRef Filename, StringRef Directory,
- Optional<ChecksumInfo<StringRef>> CS = None,
- Optional<StringRef> Source = None),
+ Optional<ChecksumInfo<StringRef>> CS = std::nullopt,
+ Optional<StringRef> Source = std::nullopt),
(Filename, Directory, CS, Source))
DEFINE_MDNODE_GET(DIFile,
(MDString * Filename, MDString *Directory,
- Optional<ChecksumInfo<MDString *>> CS = None,
- Optional<MDString *> Source = None),
+ Optional<ChecksumInfo<MDString *>> CS = std::nullopt,
+ Optional<MDString *> Source = std::nullopt),
(Filename, Directory, CS, Source))
TempDIFile clone() const { return cloneImpl(); }
@@ -654,7 +654,7 @@ class DIFile : public DIScope {
return StringRefChecksum;
}
Optional<StringRef> getSource() const {
- return Source ? Optional<StringRef>((*Source)->getString()) : None;
+ return Source ? Optional<StringRef>((*Source)->getString()) : std::nullopt;
}
MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
@@ -685,7 +685,7 @@ StringRef DIScope::getDirectory() const {
Optional<StringRef> DIScope::getSource() const {
if (auto *F = getFile())
return F->getSource();
- return None;
+ return std::nullopt;
}
/// Base class for types.
@@ -2275,7 +2275,7 @@ DILocation::cloneWithBaseDiscriminator(unsigned D) const {
return this;
if (Optional<unsigned> Encoded = encodeDiscriminator(D, DF, CI))
return cloneWithDiscriminator(*Encoded);
- return None;
+ return std::nullopt;
}
Optional<const DILocation *>
@@ -2290,7 +2290,7 @@ DILocation::cloneByMultiplyingDuplicationFactor(unsigned DF) const {
unsigned CI = getCopyIdentifier();
if (Optional<unsigned> D = encodeDiscriminator(BD, DF, CI))
return cloneWithDiscriminator(*D);
- return None;
+ return std::nullopt;
}
class DINamespace : public DIScope {
@@ -2552,7 +2552,7 @@ class DIVariable : public DINode {
Optional<DIBasicType::Signedness> getSignedness() const {
if (auto *BT = dyn_cast<DIBasicType>(getType()))
return BT->getSignedness();
- return None;
+ return std::nullopt;
}
StringRef getFilename() const {
@@ -2570,7 +2570,7 @@ class DIVariable : public DINode {
Optional<StringRef> getSource() const {
if (auto *F = getFile())
return F->getSource();
- return None;
+ return std::nullopt;
}
Metadata *getRawScope() const { return getOperand(0); }
@@ -2600,7 +2600,7 @@ class DIExpression : public MDNode {
std::vector<uint64_t> Elements;
DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
- : MDNode(C, DIExpressionKind, Storage, None),
+ : MDNode(C, DIExpressionKind, Storage, std::nullopt),
Elements(Elements.begin(), Elements.end()) {}
~DIExpression() = default;
@@ -3446,7 +3446,8 @@ class DIMacroNode : public MDNode {
protected:
DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
- ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
+ ArrayRef<Metadata *> Ops1,
+ ArrayRef<Metadata *> Ops2 = std::nullopt)
: MDNode(C, ID, Storage, Ops1, Ops2) {
assert(MIType < 1u << 16);
SubclassData16 = MIType;
@@ -3609,7 +3610,7 @@ class DIArgList : public MDNode {
DIArgList(LLVMContext &C, StorageType Storage,
ArrayRef<ValueAsMetadata *> Args)
- : MDNode(C, DIArgListKind, Storage, None),
+ : MDNode(C, DIArgListKind, Storage, std::nullopt),
Args(Args.begin(), Args.end()) {
track();
}
@@ -3675,7 +3676,8 @@ class DebugVariable {
DebugVariable(const DILocalVariable *Var, const DIExpression *DIExpr,
const DILocation *InlinedAt)
- : Variable(Var), Fragment(DIExpr ? DIExpr->getFragmentInfo() : None),
+ : Variable(Var),
+ Fragment(DIExpr ? DIExpr->getFragmentInfo() : std::nullopt),
InlinedAt(InlinedAt) {}
const DILocalVariable *getVariable() const { return Variable; }
@@ -3706,7 +3708,7 @@ template <> struct DenseMapInfo<DebugVariable> {
/// Empty key: no key should be generated that has no DILocalVariable.
static inline DebugVariable getEmptyKey() {
- return DebugVariable(nullptr, None, nullptr);
+ return DebugVariable(nullptr, std::nullopt, nullptr);
}
/// Difference in tombstone is that the Optional is meaningful.
diff --git a/llvm/include/llvm/IR/GCStrategy.h b/llvm/include/llvm/IR/GCStrategy.h
index 41024469044ff..b83a4bf72608b 100644
--- a/llvm/include/llvm/IR/GCStrategy.h
+++ b/llvm/include/llvm/IR/GCStrategy.h
@@ -95,7 +95,7 @@ class GCStrategy {
/// managed locations. Note a GCStrategy can always return 'None' (i.e. an
/// empty optional indicating it can't reliably distinguish.
virtual Optional<bool> isGCManagedPointer(const Type *Ty) const {
- return None;
+ return std::nullopt;
}
///@}
diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h
index e772964fcc6b5..9db5b04c14922 100644
--- a/llvm/include/llvm/IR/GlobalVariable.h
+++ b/llvm/include/llvm/IR/GlobalVariable.h
@@ -59,7 +59,7 @@ class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
Constant *Initializer, const Twine &Name = "",
GlobalVariable *InsertBefore = nullptr,
ThreadLocalMode = NotThreadLocal,
- Optional<unsigned> AddressSpace = None,
+ Optional<unsigned> AddressSpace = std::nullopt,
bool isExternallyInitialized = false);
GlobalVariable(const GlobalVariable &) = delete;
GlobalVariable &operator=(const GlobalVariable &) = delete;
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 0d57c127f2fec..d248715122eec 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -796,8 +796,9 @@ class IRBuilderBase {
///
/// The optional argument \p OpBundles specifies operand bundles that are
/// added to the call instruction.
- CallInst *CreateAssumption(Value *Cond,
- ArrayRef<OperandBundleDef> OpBundles = llvm::None);
+ CallInst *
+ CreateAssumption(Value *Cond,
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt);
/// Create a llvm.experimental.noalias.scope.decl intrinsic call.
Instruction *CreateNoAliasScopeDeclaration(Value *Scope);
@@ -1071,7 +1072,7 @@ class IRBuilderBase {
}
InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
- ArrayRef<Value *> Args = None,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "") {
InvokeInst *II =
InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
@@ -1090,7 +1091,7 @@ class IRBuilderBase {
InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,
BasicBlock *UnwindDest,
- ArrayRef<Value *> Args = None,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "") {
return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
NormalDest, UnwindDest, Args, Name);
@@ -1100,7 +1101,7 @@ class IRBuilderBase {
CallBrInst *CreateCallBr(FunctionType *Ty, Value *Callee,
BasicBlock *DefaultDest,
ArrayRef<BasicBlock *> IndirectDests,
- ArrayRef<Value *> Args = None,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "") {
return Insert(CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests,
Args), Name);
@@ -1118,7 +1119,7 @@ class IRBuilderBase {
CallBrInst *CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest,
ArrayRef<BasicBlock *> IndirectDests,
- ArrayRef<Value *> Args = None,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "") {
return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
DefaultDest, IndirectDests, Args, Name);
@@ -1154,7 +1155,7 @@ class IRBuilderBase {
}
CleanupPadInst *CreateCleanupPad(Value *ParentPad,
- ArrayRef<Value *> Args = None,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "") {
return Insert(CleanupPadInst::Create(ParentPad, Args), Name);
}
@@ -1602,8 +1603,8 @@ class IRBuilderBase {
CallInst *CreateConstrainedFPBinOp(
Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource = nullptr,
const Twine &Name = "", MDNode *FPMathTag = nullptr,
- Optional<RoundingMode> Rounding = None,
- Optional<fp::ExceptionBehavior> Except = None);
+ Optional<RoundingMode> Rounding = std::nullopt,
+ Optional<fp::ExceptionBehavior> Except = std::nullopt);
Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNUW = false,
bool HasNSW = false) {
@@ -2084,8 +2085,8 @@ class IRBuilderBase {
Intrinsic::ID ID, Value *V, Type *DestTy,
Instruction *FMFSource = nullptr, const Twine &Name = "",
MDNode *FPMathTag = nullptr,
- Optional<RoundingMode> Rounding = None,
- Optional<fp::ExceptionBehavior> Except = None);
+ Optional<RoundingMode> Rounding = std::nullopt,
+ Optional<fp::ExceptionBehavior> Except = std::nullopt);
// Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
// compile time error, instead of converting the string to bool for the
@@ -2243,9 +2244,10 @@ class IRBuilderBase {
bool IsSignaling);
public:
- CallInst *CreateConstrainedFPCmp(
- Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R,
- const Twine &Name = "", Optional<fp::ExceptionBehavior> Except = None);
+ CallInst *
+ CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L,
+ Value *R, const Twine &Name = "",
+ Optional<fp::ExceptionBehavior> Except = std::nullopt);
//===--------------------------------------------------------------------===//
// Instruction creation methods: Other Instructions
@@ -2267,8 +2269,8 @@ class IRBuilderBase {
public:
CallInst *CreateCall(FunctionType *FTy, Value *Callee,
- ArrayRef<Value *> Args = None, const Twine &Name = "",
- MDNode *FPMathTag = nullptr) {
+ ArrayRef<Value *> Args = std::nullopt,
+ const Twine &Name = "", MDNode *FPMathTag = nullptr) {
CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
if (IsFPConstrained)
setConstrainedFPCallAttr(CI);
@@ -2288,7 +2290,8 @@ class IRBuilderBase {
return Insert(CI, Name);
}
- CallInst *CreateCall(FunctionCallee Callee, ArrayRef<Value *> Args = None,
+ CallInst *CreateCall(FunctionCallee Callee,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &Name = "", MDNode *FPMathTag = nullptr) {
return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args, Name,
FPMathTag);
@@ -2303,8 +2306,8 @@ class IRBuilderBase {
CallInst *CreateConstrainedFPCall(
Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
- Optional<RoundingMode> Rounding = None,
- Optional<fp::ExceptionBehavior> Except = None);
+ Optional<RoundingMode> Rounding = std::nullopt,
+ Optional<fp::ExceptionBehavior> Except = std::nullopt);
Value *CreateSelect(Value *C, Value *True, Value *False,
const Twine &Name = "", Instruction *MDFrom = nullptr);
@@ -2530,47 +2533,49 @@ class IRBuilder : public IRBuilderBase {
public:
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter = InserterTy(),
MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles),
Folder(Folder), Inserter(Inserter) {}
explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles) {}
explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder,
MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
- FPMathTag, OpBundles), Folder(Folder) {
+ FPMathTag, OpBundles),
+ Folder(Folder) {
SetInsertPoint(TheBB);
}
explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
FPMathTag, OpBundles) {
SetInsertPoint(TheBB);
}
explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
- : IRBuilderBase(IP->getContext(), this->Folder, this->Inserter,
- FPMathTag, OpBundles) {
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
+ : IRBuilderBase(IP->getContext(), this->Folder, this->Inserter, FPMathTag,
+ OpBundles) {
SetInsertPoint(IP);
}
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder,
MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
- FPMathTag, OpBundles), Folder(Folder) {
+ FPMathTag, OpBundles),
+ Folder(Folder) {
SetInsertPoint(TheBB, IP);
}
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP,
MDNode *FPMathTag = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = None)
+ ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
FPMathTag, OpBundles) {
SetInsertPoint(TheBB, IP);
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index fe63344b7e2cb..09de9456960ff 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1736,7 +1736,7 @@ class CallBase : public Instruction {
return Align;
if (const Function *F = getCalledFunction())
return F->getAttributes().getRetAlignment();
- return None;
+ return std::nullopt;
}
/// Extract the alignment for a call or parameter (0=unknown).
@@ -2024,7 +2024,7 @@ class CallBase : public Instruction {
return U;
}
- return None;
+ return std::nullopt;
}
/// Return an operand bundle by tag ID, if present.
@@ -2040,7 +2040,7 @@ class CallBase : public Instruction {
return U;
}
- return None;
+ return std::nullopt;
}
/// Return the list of operand bundles attached to this instruction as
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index e9f07fcecbb57..63609587bc8ad 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -325,7 +325,7 @@ class Instruction : public User,
/// this API if the Instruction being modified is a call.
void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs);
void dropUnknownNonDebugMetadata() {
- return dropUnknownNonDebugMetadata(None);
+ return dropUnknownNonDebugMetadata(std::nullopt);
}
void dropUnknownNonDebugMetadata(unsigned ID1) {
return dropUnknownNonDebugMetadata(makeArrayRef(ID1));
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 725ee74b8f204..07bb2be39b652 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1482,7 +1482,7 @@ class CallInst : public CallBase {
inline CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr, Instruction *InsertBefore)
- : CallInst(Ty, Func, Args, None, NameStr, InsertBefore) {}
+ : CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore) {}
/// Construct a CallInst given a range of arguments.
/// Construct a CallInst from a range of arguments
@@ -1523,11 +1523,11 @@ class CallInst : public CallBase {
const Twine &NameStr,
Instruction *InsertBefore = nullptr) {
return new (ComputeNumOperands(Args.size()))
- CallInst(Ty, Func, Args, None, NameStr, InsertBefore);
+ CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore);
}
static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
const int NumOperands =
@@ -1546,7 +1546,7 @@ class CallInst : public CallBase {
static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new (ComputeNumOperands(Args.size()))
- CallInst(Ty, Func, Args, None, NameStr, InsertAtEnd);
+ CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertAtEnd);
}
static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
@@ -1567,7 +1567,7 @@ class CallInst : public CallBase {
}
static CallInst *Create(FunctionCallee Func, ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
@@ -1625,18 +1625,16 @@ class CallInst : public CallBase {
Value *ArraySize = nullptr,
Function *MallocF = nullptr,
const Twine &Name = "");
- static Instruction *CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy,
- Type *AllocTy, Value *AllocSize,
- Value *ArraySize = nullptr,
- ArrayRef<OperandBundleDef> Bundles = None,
- Function *MallocF = nullptr,
- const Twine &Name = "");
- static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, Type *IntPtrTy,
- Type *AllocTy, Value *AllocSize,
- Value *ArraySize = nullptr,
- ArrayRef<OperandBundleDef> Bundles = None,
- Function *MallocF = nullptr,
- const Twine &Name = "");
+ static Instruction *
+ CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy,
+ Value *AllocSize, Value *ArraySize = nullptr,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
+ Function *MallocF = nullptr, const Twine &Name = "");
+ static Instruction *
+ CreateMalloc(BasicBlock *InsertAtEnd, Type *IntPtrTy, Type *AllocTy,
+ Value *AllocSize, Value *ArraySize = nullptr,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
+ Function *MallocF = nullptr, const Twine &Name = "");
/// Generate the IR for a call to the builtin free function.
static Instruction *CreateFree(Value *Source, Instruction *InsertBefore);
static Instruction *CreateFree(Value *Source, BasicBlock *InsertAtEnd);
@@ -3619,7 +3617,7 @@ class SwitchInst : public Instruction {
/// their prof branch_weights metadata.
class SwitchInstProfUpdateWrapper {
SwitchInst &SI;
- std::optional<SmallVector<uint32_t, 8>> Weights = None;
+ std::optional<SmallVector<uint32_t, 8>> Weights = std::nullopt;
bool Changed = false;
protected:
@@ -3858,13 +3856,13 @@ class InvokeInst : public CallBase {
Instruction *InsertBefore = nullptr) {
int NumOperands = ComputeNumOperands(Args.size());
return new (NumOperands)
- InvokeInst(Ty, Func, IfNormal, IfException, Args, None, NumOperands,
- NameStr, InsertBefore);
+ InvokeInst(Ty, Func, IfNormal, IfException, Args, std::nullopt,
+ NumOperands, NameStr, InsertBefore);
}
static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
BasicBlock *IfException, ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
int NumOperands =
@@ -3881,8 +3879,8 @@ class InvokeInst : public CallBase {
const Twine &NameStr, BasicBlock *InsertAtEnd) {
int NumOperands = ComputeNumOperands(Args.size());
return new (NumOperands)
- InvokeInst(Ty, Func, IfNormal, IfException, Args, None, NumOperands,
- NameStr, InsertAtEnd);
+ InvokeInst(Ty, Func, IfNormal, IfException, Args, std::nullopt,
+ NumOperands, NameStr, InsertAtEnd);
}
static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
@@ -3903,12 +3901,12 @@ class InvokeInst : public CallBase {
const Twine &NameStr,
Instruction *InsertBefore = nullptr) {
return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
- IfException, Args, None, NameStr, InsertBefore);
+ IfException, Args, std::nullopt, NameStr, InsertBefore);
}
static InvokeInst *Create(FunctionCallee Func, BasicBlock *IfNormal,
BasicBlock *IfException, ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
@@ -4064,17 +4062,15 @@ class CallBrInst : public CallBase {
Instruction *InsertBefore = nullptr) {
int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.size());
return new (NumOperands)
- CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, None,
+ CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, std::nullopt,
NumOperands, NameStr, InsertBefore);
}
- static CallBrInst *Create(FunctionType *Ty, Value *Func,
- BasicBlock *DefaultDest,
- ArrayRef<BasicBlock *> IndirectDests,
- ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
- const Twine &NameStr = "",
- Instruction *InsertBefore = nullptr) {
+ static CallBrInst *
+ Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
+ ArrayRef<BasicBlock *> IndirectDests, ArrayRef<Value *> Args,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
+ const Twine &NameStr = "", Instruction *InsertBefore = nullptr) {
int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.size(),
CountBundleInputs(Bundles));
unsigned DescriptorBytes = Bundles.size() * sizeof(BundleOpInfo);
@@ -4091,7 +4087,7 @@ class CallBrInst : public CallBase {
BasicBlock *InsertAtEnd) {
int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.size());
return new (NumOperands)
- CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, None,
+ CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, std::nullopt,
NumOperands, NameStr, InsertAtEnd);
}
@@ -4121,7 +4117,7 @@ class CallBrInst : public CallBase {
static CallBrInst *Create(FunctionCallee Func, BasicBlock *DefaultDest,
ArrayRef<BasicBlock *> IndirectDests,
ArrayRef<Value *> Args,
- ArrayRef<OperandBundleDef> Bundles = None,
+ ArrayRef<OperandBundleDef> Bundles = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
@@ -4501,7 +4497,8 @@ class CleanupPadInst : public FuncletPadInst {
NameStr, InsertAtEnd) {}
public:
- static CleanupPadInst *Create(Value *ParentPad, ArrayRef<Value *> Args = None,
+ static CleanupPadInst *Create(Value *ParentPad,
+ ArrayRef<Value *> Args = std::nullopt,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
unsigned Values = 1 + Args.size();
@@ -5415,7 +5412,7 @@ inline Type *getLoadStoreType(Value *I) {
/// None if it is not an atomic operation.
inline std::optional<SyncScope::ID> getAtomicSyncScopeID(const Instruction *I) {
if (!I->isAtomic())
- return None;
+ return std::nullopt;
if (auto *AI = dyn_cast<LoadInst>(I))
return AI->getSyncScopeID();
if (auto *AI = dyn_cast<StoreInst>(I))
diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h
index a3db2fa59399d..559e5eef5259e 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -75,7 +75,7 @@ namespace Intrinsic {
/// Return the function type for an intrinsic.
FunctionType *getType(LLVMContext &Context, ID id,
- ArrayRef<Type*> Tys = None);
+ ArrayRef<Type *> Tys = std::nullopt);
/// Returns true if the intrinsic can be overloaded.
bool isOverloaded(ID id);
@@ -95,7 +95,8 @@ namespace Intrinsic {
/// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded
/// intrinsic, Tys must provide exactly one type for each overloaded type in
/// the intrinsic.
- Function *getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys = None);
+ Function *getDeclaration(Module *M, ID id,
+ ArrayRef<Type *> Tys = std::nullopt);
/// Looks up Name in NameTable via binary search. NameTable must be sorted
/// and all entries must start with "llvm.". If NameTable contains an exact
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index b90b895f32e88..bef69f82a5957 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -1056,7 +1056,7 @@ class MDNode : public Metadata {
protected:
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage,
- ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None);
+ ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = std::nullopt);
~MDNode() = default;
void *operator new(size_t Size, size_t NumOps, StorageType Storage);
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index e8a9a3b31b1b0..e5236523a522c 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1705,7 +1705,7 @@ class ModuleSummaryIndex {
getTypeIdCompatibleVtableSummary(StringRef TypeId) const {
auto I = TypeIdCompatibleVtableMap.find(TypeId);
if (I == TypeIdCompatibleVtableMap.end())
- return None;
+ return std::nullopt;
return I->second;
}
diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h
index 1a234e273efff..2c2c86385bf3d 100644
--- a/llvm/include/llvm/IR/Operator.h
+++ b/llvm/include/llvm/IR/Operator.h
@@ -396,7 +396,8 @@ class GEPOperator
/// Returns the offset of the index with an inrange attachment, or None if
/// none.
Optional<unsigned> getInRangeIndex() const {
- if (SubclassOptionalData >> 1 == 0) return None;
+ if (SubclassOptionalData >> 1 == 0)
+ return std::nullopt;
return (SubclassOptionalData >> 1) - 1;
}
diff --git a/llvm/include/llvm/IR/VPIntrinsics.def b/llvm/include/llvm/IR/VPIntrinsics.def
index c8d7f8fae45ff..db8d0a99e1e59 100644
--- a/llvm/include/llvm/IR/VPIntrinsics.def
+++ b/llvm/include/llvm/IR/VPIntrinsics.def
@@ -443,7 +443,7 @@ BEGIN_REGISTER_VP_SDNODE(VP_LOAD, -1, vp_load, 3, 4)
HELPER_MAP_VPID_TO_VPSD(vp_load, VP_LOAD)
VP_PROPERTY_FUNCTIONAL_OPC(Load)
VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_load)
-VP_PROPERTY_MEMOP(0, None)
+VP_PROPERTY_MEMOP(0, std::nullopt)
END_REGISTER_VP(vp_load, VP_LOAD)
// llvm.experimental.vp.strided.load(ptr,stride,mask,vlen)
@@ -451,7 +451,7 @@ BEGIN_REGISTER_VP_INTRINSIC(experimental_vp_strided_load, 2, 3)
// chain = EXPERIMENTAL_VP_STRIDED_LOAD chain,base,offset,stride,mask,evl
BEGIN_REGISTER_VP_SDNODE(EXPERIMENTAL_VP_STRIDED_LOAD, -1, experimental_vp_strided_load, 4, 5)
HELPER_MAP_VPID_TO_VPSD(experimental_vp_strided_load, EXPERIMENTAL_VP_STRIDED_LOAD)
-VP_PROPERTY_MEMOP(0, None)
+VP_PROPERTY_MEMOP(0, std::nullopt)
END_REGISTER_VP(experimental_vp_strided_load, EXPERIMENTAL_VP_STRIDED_LOAD)
// llvm.vp.gather(ptr,mask,vlen)
@@ -460,7 +460,7 @@ BEGIN_REGISTER_VP_INTRINSIC(vp_gather, 1, 2)
BEGIN_REGISTER_VP_SDNODE(VP_GATHER, -1, vp_gather, 4, 5)
HELPER_MAP_VPID_TO_VPSD(vp_gather, VP_GATHER)
VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_gather)
-VP_PROPERTY_MEMOP(0, None)
+VP_PROPERTY_MEMOP(0, std::nullopt)
END_REGISTER_VP(vp_gather, VP_GATHER)
///// } Memory Operations
@@ -568,12 +568,12 @@ HELPER_REGISTER_REDUCTION_SEQ_VP(vp_reduce_fmul, VP_REDUCE_FMUL,
// false.
//
// llvm.vp.select(cond,on_true,on_false,vlen)
-BEGIN_REGISTER_VP(vp_select, None, 3, VP_SELECT, -1)
+BEGIN_REGISTER_VP(vp_select, std::nullopt, 3, VP_SELECT, -1)
VP_PROPERTY_FUNCTIONAL_OPC(Select)
END_REGISTER_VP(vp_select, VP_SELECT)
// llvm.vp.merge(cond,on_true,on_false,pivot)
-BEGIN_REGISTER_VP(vp_merge, None, 3, VP_MERGE, -1)
+BEGIN_REGISTER_VP(vp_merge, std::nullopt, 3, VP_MERGE, -1)
END_REGISTER_VP(vp_merge, VP_MERGE)
BEGIN_REGISTER_VP(experimental_vp_splice, 3, 5, EXPERIMENTAL_VP_SPLICE, -1)
diff --git a/llvm/include/llvm/IR/ValueMap.h b/llvm/include/llvm/IR/ValueMap.h
index a4b6091cf1155..a8c9056310552 100644
--- a/llvm/include/llvm/IR/ValueMap.h
+++ b/llvm/include/llvm/IR/ValueMap.h
@@ -122,10 +122,10 @@ class ValueMap {
/// Get the mapped metadata, if it's in the map.
Optional<Metadata *> getMappedMD(const Metadata *MD) const {
if (!MDMap)
- return None;
+ return std::nullopt;
auto Where = MDMap->find(MD);
if (Where == MDMap->end())
- return None;
+ return std::nullopt;
return Where->second.get();
}
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 707c9398a989c..e67970a17c8e6 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1675,7 +1675,8 @@ struct MDFieldPrinter {
void printInt(StringRef Name, IntTy Int, bool ShouldSkipZero = true);
void printAPInt(StringRef Name, const APInt &Int, bool IsUnsigned,
bool ShouldSkipZero);
- void printBool(StringRef Name, bool Value, Optional<bool> Default = None);
+ void printBool(StringRef Name, bool Value,
+ Optional<bool> Default = std::nullopt);
void printDIFlags(StringRef Name, DINode::DIFlags Flags);
void printDISPFlags(StringRef Name, DISubprogram::DISPFlags Flags);
template <class IntTy, class Stringifier>
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index e4dee3f4d9b44..2e18398f4d51d 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -774,11 +774,11 @@ Attribute AttributeSet::getAttribute(StringRef Kind) const {
}
MaybeAlign AttributeSet::getAlignment() const {
- return SetNode ? SetNode->getAlignment() : None;
+ return SetNode ? SetNode->getAlignment() : std::nullopt;
}
MaybeAlign AttributeSet::getStackAlignment() const {
- return SetNode ? SetNode->getStackAlignment() : None;
+ return SetNode ? SetNode->getStackAlignment() : std::nullopt;
}
uint64_t AttributeSet::getDereferenceableBytes() const {
@@ -960,13 +960,13 @@ Attribute AttributeSetNode::getAttribute(StringRef Kind) const {
MaybeAlign AttributeSetNode::getAlignment() const {
if (auto A = findEnumAttribute(Attribute::Alignment))
return A->getAlignment();
- return None;
+ return std::nullopt;
}
MaybeAlign AttributeSetNode::getStackAlignment() const {
if (auto A = findEnumAttribute(Attribute::StackAlignment))
return A->getStackAlignment();
- return None;
+ return std::nullopt;
}
Type *AttributeSetNode::getAttributeType(Attribute::AttrKind Kind) const {
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 9150b52085e80..b5c7818dfae29 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1133,7 +1133,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
// Remangle our intrinsic since we upgrade the mangling
auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F);
- if (Result != None) {
+ if (Result != std::nullopt) {
NewFn = *Result;
return true;
}
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 68de6c45e9335..7a30005eb981f 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -529,7 +529,7 @@ Optional<uint64_t> BasicBlock::getIrrLoopHeaderWeight() const {
return Optional<uint64_t>(CI->getValue().getZExtValue());
}
}
- return None;
+ return std::nullopt;
}
BasicBlock::iterator llvm::skipDebugIntrinsics(BasicBlock::iterator It) {
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 74b7d198e9338..1815bba021385 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1073,7 +1073,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
} else if (isa<Function>(GV)) {
// Without a datalayout we have to assume the worst case: that the
// function pointer isn't aligned at all.
- GVAlign = llvm::None;
+ GVAlign = std::nullopt;
} else if (isa<GlobalVariable>(GV)) {
GVAlign = cast<GlobalVariable>(GV)->getAlign();
}
@@ -2024,7 +2024,7 @@ static Constant *foldGEPOfGEP(GEPOperator *GEP, Type *PointeeTy, bool InBounds,
// outer GEP, any inbounds attribute on that index is invalidated.
Optional<unsigned> IRIndex = GEP->getInRangeIndex();
if (IRIndex && *IRIndex == GEP->getNumIndices() - 1)
- IRIndex = None;
+ IRIndex = std::nullopt;
return ConstantExpr::getGetElementPtr(
GEP->getSourceElementType(), cast<Constant>(GEP->getPointerOperand()),
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 9d239101d8fde..d443f2cb847ea 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -705,7 +705,7 @@ ConstantRange::exactIntersectWith(const ConstantRange &CR) const {
ConstantRange Result = intersectWith(CR);
if (Result == inverse().unionWith(CR.inverse()).inverse())
return Result;
- return None;
+ return std::nullopt;
}
Optional<ConstantRange>
@@ -714,7 +714,7 @@ ConstantRange::exactUnionWith(const ConstantRange &CR) const {
ConstantRange Result = unionWith(CR);
if (Result == inverse().intersectWith(CR.inverse()).inverse())
return Result;
- return None;
+ return std::nullopt;
}
ConstantRange ConstantRange::castOp(Instruction::CastOps CastOp,
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index d6a87c868b847..adbc158c8c1e3 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2487,7 +2487,7 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
if (InRangeIndex && *InRangeIndex < 63)
SubClassOptionalData |= (*InRangeIndex + 1) << 1;
const ConstantExprKeyType Key(Instruction::GetElementPtr, ArgVec, 0,
- SubClassOptionalData, None, Ty);
+ SubClassOptionalData, std::nullopt, Ty);
LLVMContextImpl *pImpl = C->getContext().pImpl;
return pImpl->ExprConstants.getOrCreate(ReqTy, Key);
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index c95f7a170bf72..0363ea1c03c97 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -441,7 +441,7 @@ struct ConstantExprKeyType {
static ArrayRef<int> getShuffleMaskIfValid(const ConstantExpr *CE) {
if (CE->getOpcode() == Instruction::ShuffleVector)
return CE->getShuffleMask();
- return None;
+ return std::nullopt;
}
static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) {
@@ -454,7 +454,7 @@ struct ConstantExprKeyType {
ConstantExprKeyType(unsigned Opcode, ArrayRef<Constant *> Ops,
unsigned short SubclassData = 0,
unsigned short SubclassOptionalData = 0,
- ArrayRef<int> ShuffleMask = None,
+ ArrayRef<int> ShuffleMask = std::nullopt,
Type *ExplicitTy = nullptr)
: Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
SubclassData(SubclassData), Ops(Ops), ShuffleMask(ShuffleMask),
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 989b55463b4dc..730069308e20c 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -312,7 +312,7 @@ DIStringType *DIBuilder::createStringType(StringRef Name,
DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {
return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, FromTy, 0,
- 0, 0, None, DINode::FlagZero);
+ 0, 0, std::nullopt, DINode::FlagZero);
}
DIDerivedType *
@@ -334,7 +334,7 @@ DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy,
DINode::DIFlags Flags) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
nullptr, 0, nullptr, PointeeTy, SizeInBits,
- AlignInBits, 0, None, Flags, Base);
+ AlignInBits, 0, std::nullopt, Flags, Base);
}
DIDerivedType *
@@ -354,14 +354,15 @@ DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
DINodeArray Annotations) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
LineNo, getNonCompileUnitScope(Context), Ty, 0,
- AlignInBits, 0, None, Flags, nullptr, Annotations);
+ AlignInBits, 0, std::nullopt, Flags, nullptr,
+ Annotations);
}
DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
assert(Ty && "Invalid type!");
assert(FriendTy && "Invalid friend type!");
return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, Ty,
- FriendTy, 0, 0, 0, None, DINode::FlagZero);
+ FriendTy, 0, 0, 0, std::nullopt, DINode::FlagZero);
}
DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy,
@@ -372,8 +373,8 @@ DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy,
Metadata *ExtraData = ConstantAsMetadata::get(
ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset));
return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
- 0, Ty, BaseTy, 0, 0, BaseOffset, None, Flags,
- ExtraData);
+ 0, Ty, BaseTy, 0, 0, BaseOffset, std::nullopt,
+ Flags, ExtraData);
}
DIDerivedType *DIBuilder::createMemberType(
@@ -382,8 +383,8 @@ DIDerivedType *DIBuilder::createMemberType(
DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
LineNumber, getNonCompileUnitScope(Scope), Ty,
- SizeInBits, AlignInBits, OffsetInBits, None, Flags,
- nullptr, Annotations);
+ SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
+ Flags, nullptr, Annotations);
}
static ConstantAsMetadata *getConstantOrNull(Constant *C) {
@@ -398,8 +399,8 @@ DIDerivedType *DIBuilder::createVariantMemberType(
Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
LineNumber, getNonCompileUnitScope(Scope), Ty,
- SizeInBits, AlignInBits, OffsetInBits, None, Flags,
- getConstantOrNull(Discriminant));
+ SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
+ Flags, getConstantOrNull(Discriminant));
}
DIDerivedType *DIBuilder::createBitFieldMemberType(
@@ -410,7 +411,7 @@ DIDerivedType *DIBuilder::createBitFieldMemberType(
return DIDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
- OffsetInBits, None, Flags,
+ OffsetInBits, std::nullopt, Flags,
ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
StorageOffsetInBits)),
Annotations);
@@ -424,7 +425,7 @@ DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File,
Flags |= DINode::FlagStaticMember;
return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
LineNumber, getNonCompileUnitScope(Scope), Ty, 0,
- AlignInBits, 0, None, Flags,
+ AlignInBits, 0, std::nullopt, Flags,
getConstantOrNull(Val));
}
@@ -435,8 +436,8 @@ DIBuilder::createObjCIVar(StringRef Name, DIFile *File, unsigned LineNumber,
DIType *Ty, MDNode *PropertyNode) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
LineNumber, getNonCompileUnitScope(File), Ty,
- SizeInBits, AlignInBits, OffsetInBits, None, Flags,
- PropertyNode);
+ SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
+ Flags, PropertyNode);
}
DIObjCProperty *
@@ -570,7 +571,7 @@ DIDerivedType *DIBuilder::createSetType(DIScope *Scope, StringRef Name,
auto *R =
DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File, LineNo,
getNonCompileUnitScope(Scope), Ty, SizeInBits,
- AlignInBits, 0, None, DINode::FlagZero);
+ AlignInBits, 0, std::nullopt, DINode::FlagZero);
trackIfUnresolved(R);
return R;
}
@@ -855,7 +856,7 @@ DISubprogram *DIBuilder::createFunction(
/*IsDistinct=*/IsDefinition, VMContext, getNonCompileUnitScope(Context),
Name, LinkageName, File, LineNo, Ty, ScopeLine, nullptr, 0, 0, Flags,
SPFlags, IsDefinition ? CUNode : nullptr, TParams, Decl,
- MDTuple::getTemporary(VMContext, None).release(), ThrownTypes,
+ MDTuple::getTemporary(VMContext, std::nullopt).release(), ThrownTypes,
Annotations, TargetFuncName);
if (IsDefinition)
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 96f55cf14de8f..e451234eaa4d9 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -937,7 +937,7 @@ Optional<APInt> DataLayout::getGEPIndexForOffset(Type *&ElemTy,
unsigned ElemSizeInBits = getTypeSizeInBits(ElemTy).getFixedSize();
// GEPs over non-multiple of 8 size vector elements are invalid.
if (ElemSizeInBits % 8 != 0)
- return None;
+ return std::nullopt;
return getElementIndex(TypeSize::Fixed(ElemSizeInBits / 8), Offset);
}
@@ -946,7 +946,7 @@ Optional<APInt> DataLayout::getGEPIndexForOffset(Type *&ElemTy,
const StructLayout *SL = getStructLayout(STy);
uint64_t IntOffset = Offset.getZExtValue();
if (IntOffset >= SL->getSizeInBytes())
- return None;
+ return std::nullopt;
unsigned Index = SL->getElementContainingOffset(IntOffset);
Offset -= SL->getElementOffset(Index);
@@ -955,7 +955,7 @@ Optional<APInt> DataLayout::getGEPIndexForOffset(Type *&ElemTy,
}
// Non-aggregate type.
- return None;
+ return std::nullopt;
}
SmallVector<APInt> DataLayout::getGEPIndicesForOffset(Type *&ElemTy,
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index d02154f367ba3..cbbdcaf18d3bb 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1755,10 +1755,10 @@ static Optional<AssignmentInfo> getAssignmentInfoImpl(const DataLayout &DL,
uint64_t OffsetInBytes = GEPOffset.getLimitedValue();
// Check for overflow.
if (OffsetInBytes == UINT64_MAX)
- return None;
+ return std::nullopt;
if (const auto *Alloca = dyn_cast<AllocaInst>(Base))
return AssignmentInfo(DL, Alloca, OffsetInBytes * 8, SizeInBits);
- return None;
+ return std::nullopt;
}
Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
@@ -1768,7 +1768,7 @@ Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
auto *ConstLengthInBytes = dyn_cast<ConstantInt>(I->getLength());
if (!ConstLengthInBytes)
// We can't use a non-const size, bail.
- return None;
+ return std::nullopt;
uint64_t SizeInBits = 8 * ConstLengthInBytes->getZExtValue();
return getAssignmentInfoImpl(DL, StoreDest, SizeInBits);
}
@@ -1793,14 +1793,16 @@ static CallInst *emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest,
assert(ID && "Store instruction must have DIAssignID metadata");
(void)ID;
- DIExpression *Expr = DIExpression::get(StoreLikeInst.getContext(), None);
+ DIExpression *Expr =
+ DIExpression::get(StoreLikeInst.getContext(), std::nullopt);
if (!Info.StoreToWholeAlloca) {
auto R = DIExpression::createFragmentExpression(Expr, Info.OffsetInBits,
Info.SizeInBits);
assert(R.has_value() && "failed to create fragment expression");
Expr = R.value();
}
- DIExpression *AddrExpr = DIExpression::get(StoreLikeInst.getContext(), None);
+ DIExpression *AddrExpr =
+ DIExpression::get(StoreLikeInst.getContext(), std::nullopt);
return DIB.insertDbgAssign(&StoreLikeInst, Val, VarRec.Var, Expr, Dest,
AddrExpr, VarRec.DL);
}
@@ -1827,7 +1829,7 @@ void at::trackAssignments(Function::iterator Start, Function::iterator End,
for (auto BBI = Start; BBI != End; ++BBI) {
for (Instruction &I : *BBI) {
- Optional<AssignmentInfo> Info = None;
+ Optional<AssignmentInfo> Info = std::nullopt;
Value *ValueComponent = nullptr;
Value *DestComponent = nullptr;
if (auto *AI = dyn_cast<AllocaInst>(&I)) {
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 5483595a78667..4db2b6989711f 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -203,7 +203,7 @@ Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF,
decodeDiscriminator(Ret, TBD, TDF, TCI);
if (TBD == BD && TDF == DF && TCI == CI)
return Ret;
- return None;
+ return std::nullopt;
}
void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
@@ -610,7 +610,7 @@ Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
case dwarf::DW_ATE_unsigned_char:
return Signedness::Unsigned;
default:
- return None;
+ return std::nullopt;
}
}
@@ -824,7 +824,7 @@ Optional<DIFile::ChecksumKind> DIFile::getChecksumKind(StringRef CSKindStr) {
.Case("CSK_MD5", DIFile::CSK_MD5)
.Case("CSK_SHA1", DIFile::CSK_SHA1)
.Case("CSK_SHA256", DIFile::CSK_SHA256)
- .Default(None);
+ .Default(std::nullopt);
}
DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
@@ -896,7 +896,7 @@ DICompileUnit::getEmissionKind(StringRef Str) {
.Case("FullDebug", FullDebug)
.Case("LineTablesOnly", LineTablesOnly)
.Case("DebugDirectivesOnly", DebugDirectivesOnly)
- .Default(None);
+ .Default(std::nullopt);
}
Optional<DICompileUnit::DebugNameTableKind>
@@ -905,7 +905,7 @@ DICompileUnit::getNameTableKind(StringRef Str) {
.Case("Default", DebugNameTableKind::Default)
.Case("GNU", DebugNameTableKind::GNU)
.Case("None", DebugNameTableKind::None)
- .Default(None);
+ .Default(std::nullopt);
}
const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
@@ -1224,7 +1224,7 @@ Optional<uint64_t> DIVariable::getSizeInBits() const {
}
// Fail gracefully.
- return None;
+ return std::nullopt;
}
DILabel::DILabel(LLVMContext &C, StorageType Storage, unsigned Line,
@@ -1415,7 +1415,7 @@ DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
return Info;
}
- return None;
+ return std::nullopt;
}
void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
@@ -1597,7 +1597,7 @@ DIExpression *DIExpression::append(const DIExpression *Expr,
NewOps.append(Ops.begin(), Ops.end());
// Ensure that the new opcodes are only appended once.
- Ops = None;
+ Ops = std::nullopt;
}
Op.appendToVector(NewOps);
}
@@ -1679,7 +1679,7 @@ Optional<DIExpression *> DIExpression::createFragmentExpression(
case dwarf::DW_OP_stack_value:
// Bail if this expression computes a value that cannot be split.
if (!CanSplitValue)
- return None;
+ return std::nullopt;
break;
case dwarf::DW_OP_LLVM_fragment: {
// Make the new offset point into the existing fragment.
@@ -1765,7 +1765,7 @@ DIExpression::isConstant() const {
getNumElements() != 6) ||
(getElement(0) != dwarf::DW_OP_consts &&
getElement(0) != dwarf::DW_OP_constu))
- return None;
+ return std::nullopt;
if (getNumElements() == 2 && getElement(0) == dwarf::DW_OP_consts)
return SignedOrUnsignedConstant::SignedConstant;
@@ -1773,7 +1773,7 @@ DIExpression::isConstant() const {
if ((getNumElements() == 3 && getElement(2) != dwarf::DW_OP_stack_value) ||
(getNumElements() == 6 && (getElement(2) != dwarf::DW_OP_stack_value ||
getElement(3) != dwarf::DW_OP_LLVM_fragment)))
- return None;
+ return std::nullopt;
return getElement(0) == dwarf::DW_OP_constu
? SignedOrUnsignedConstant::UnsignedConstant
: SignedOrUnsignedConstant::SignedConstant;
diff --git a/llvm/lib/IR/FPEnv.cpp b/llvm/lib/IR/FPEnv.cpp
index 4de43f471f3ec..1e01a79b6263a 100644
--- a/llvm/lib/IR/FPEnv.cpp
+++ b/llvm/lib/IR/FPEnv.cpp
@@ -30,7 +30,7 @@ Optional<RoundingMode> convertStrToRoundingMode(StringRef RoundingArg) {
.Case("round.downward", RoundingMode::TowardNegative)
.Case("round.upward", RoundingMode::TowardPositive)
.Case("round.towardzero", RoundingMode::TowardZero)
- .Default(None);
+ .Default(std::nullopt);
}
Optional<StringRef> convertRoundingModeToStr(RoundingMode UseRounding) {
@@ -66,7 +66,7 @@ convertStrToExceptionBehavior(StringRef ExceptionArg) {
.Case("fpexcept.ignore", fp::ebIgnore)
.Case("fpexcept.maytrap", fp::ebMayTrap)
.Case("fpexcept.strict", fp::ebStrict)
- .Default(None);
+ .Default(std::nullopt);
}
Optional<StringRef>
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index bb0fc27a064b9..51ef4d0972f29 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1846,14 +1846,14 @@ bool Intrinsic::getIntrinsicSignature(Function *F,
Optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
SmallVector<Type *, 4> ArgTys;
if (!getIntrinsicSignature(F, ArgTys))
- return None;
+ return std::nullopt;
Intrinsic::ID ID = F->getIntrinsicID();
StringRef Name = F->getName();
std::string WantedName =
Intrinsic::getName(ID, ArgTys, F->getParent(), F->getFunctionType());
if (Name == WantedName)
- return None;
+ return std::nullopt;
Function *NewDecl = [&] {
if (auto *ExistingGV = F->getParent()->getNamedValue(WantedName)) {
@@ -2061,7 +2061,7 @@ Optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {
// A value of -1 is used for SamplePGO when there were no samples.
// Treat this the same as unknown.
if (Count == (uint64_t)-1)
- return None;
+ return std::nullopt;
return ProfileCount(Count, PCT_Real);
} else if (AllowSynthetic &&
MDS->getString().equals("synthetic_function_entry_count")) {
@@ -2070,7 +2070,7 @@ Optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {
return ProfileCount(Count, PCT_Synthetic);
}
}
- return None;
+ return std::nullopt;
}
DenseSet<GlobalValue::GUID> Function::getImportGUIDs() const {
@@ -2099,7 +2099,7 @@ Optional<StringRef> Function::getSectionPrefix() const {
"Metadata not match");
return cast<MDString>(MD->getOperand(1))->getString();
}
- return None;
+ return std::nullopt;
}
bool Function::nullPointerIsDefined() const {
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 41b090a00ece6..7169ca2c34017 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -373,11 +373,11 @@ bool GlobalValue::isAbsoluteSymbolRef() const {
Optional<ConstantRange> GlobalValue::getAbsoluteSymbolRange() const {
auto *GO = dyn_cast<GlobalObject>(this);
if (!GO)
- return None;
+ return std::nullopt;
MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
if (!MD)
- return None;
+ return std::nullopt;
return getConstantRangeFromMetadata(*MD);
}
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index fcd7205bc0f85..d0bf980bef9c7 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -820,7 +820,7 @@ CallInst *IRBuilderBase::CreateGCStatepointCall(
ArrayRef<Value *> GCArgs, const Twine &Name) {
return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
- CallArgs, None /* No Transition Args */, DeoptArgs, GCArgs, Name);
+ CallArgs, std::nullopt /* No Transition Args */, DeoptArgs, GCArgs, Name);
}
CallInst *IRBuilderBase::CreateGCStatepointCall(
@@ -839,7 +839,7 @@ CallInst *IRBuilderBase::CreateGCStatepointCall(
ArrayRef<Value *> GCArgs, const Twine &Name) {
return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
- CallArgs, None, DeoptArgs, GCArgs, Name);
+ CallArgs, std::nullopt, DeoptArgs, GCArgs, Name);
}
template <typename T0, typename T1, typename T2, typename T3>
@@ -875,8 +875,8 @@ InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
ArrayRef<Value *> GCArgs, const Twine &Name) {
return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
- uint32_t(StatepointFlags::None), InvokeArgs, None /* No Transition Args*/,
- DeoptArgs, GCArgs, Name);
+ uint32_t(StatepointFlags::None), InvokeArgs,
+ std::nullopt /* No Transition Args*/, DeoptArgs, GCArgs, Name);
}
InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
@@ -897,8 +897,8 @@ InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
const Twine &Name) {
return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
- uint32_t(StatepointFlags::None), InvokeArgs, None, DeoptArgs, GCArgs,
- Name);
+ uint32_t(StatepointFlags::None), InvokeArgs, std::nullopt, DeoptArgs,
+ GCArgs, Name);
}
CallInst *IRBuilderBase::CreateGCResult(Instruction *Statepoint,
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 539d325089864..97f3c0e3ff82f 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -61,7 +61,7 @@ AllocaInst::getAllocationSizeInBits(const DataLayout &DL) const {
if (isArrayAllocation()) {
auto *C = dyn_cast<ConstantInt>(getArraySize());
if (!C)
- return None;
+ return std::nullopt;
assert(!Size.isScalable() && "Array elements cannot have a scalable size");
Size *= C->getZExtValue();
}
@@ -852,7 +852,7 @@ Instruction *CallInst::CreateMalloc(Instruction *InsertBefore,
Function *MallocF,
const Twine &Name) {
return createMalloc(InsertBefore, nullptr, IntPtrTy, AllocTy, AllocSize,
- ArraySize, None, MallocF, Name);
+ ArraySize, std::nullopt, MallocF, Name);
}
Instruction *CallInst::CreateMalloc(Instruction *InsertBefore,
Type *IntPtrTy, Type *AllocTy,
@@ -877,7 +877,7 @@ Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd,
Value *AllocSize, Value *ArraySize,
Function *MallocF, const Twine &Name) {
return createMalloc(nullptr, InsertAtEnd, IntPtrTy, AllocTy, AllocSize,
- ArraySize, None, MallocF, Name);
+ ArraySize, std::nullopt, MallocF, Name);
}
Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd,
Type *IntPtrTy, Type *AllocTy,
@@ -924,7 +924,7 @@ static Instruction *createFree(Value *Source,
/// CreateFree - Generate the IR for a call to the builtin free function.
Instruction *CallInst::CreateFree(Value *Source, Instruction *InsertBefore) {
- return createFree(Source, None, InsertBefore, nullptr);
+ return createFree(Source, std::nullopt, InsertBefore, nullptr);
}
Instruction *CallInst::CreateFree(Value *Source,
ArrayRef<OperandBundleDef> Bundles,
@@ -936,7 +936,8 @@ Instruction *CallInst::CreateFree(Value *Source,
/// Note: This function does not add the call to the basic block, that is the
/// responsibility of the caller.
Instruction *CallInst::CreateFree(Value *Source, BasicBlock *InsertAtEnd) {
- Instruction *FreeCall = createFree(Source, None, nullptr, InsertAtEnd);
+ Instruction *FreeCall =
+ createFree(Source, std::nullopt, nullptr, InsertAtEnd);
assert(FreeCall && "CreateFree did not create a CallInst");
return FreeCall;
}
@@ -4653,7 +4654,7 @@ SwitchInstProfUpdateWrapper::eraseFromParent() {
SwitchInstProfUpdateWrapper::CaseWeightOpt
SwitchInstProfUpdateWrapper::getSuccessorWeight(unsigned idx) {
if (!Weights)
- return None;
+ return std::nullopt;
return (*Weights)[idx];
}
@@ -4683,7 +4684,7 @@ SwitchInstProfUpdateWrapper::getSuccessorWeight(const SwitchInst &SI,
->getValue()
.getZExtValue();
- return None;
+ return std::nullopt;
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 2cdebae52a952..242ddc44c4d94 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -282,7 +282,7 @@ Optional<RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
if (MAV)
MD = MAV->getMetadata();
if (!MD || !isa<MDString>(MD))
- return None;
+ return std::nullopt;
return convertStrToRoundingMode(cast<MDString>(MD)->getString());
}
@@ -294,7 +294,7 @@ ConstrainedFPIntrinsic::getExceptionBehavior() const {
if (MAV)
MD = MAV->getMetadata();
if (!MD || !isa<MDString>(MD))
- return None;
+ return std::nullopt;
return convertStrToExceptionBehavior(cast<MDString>(MD)->getString());
}
@@ -415,7 +415,7 @@ void VPIntrinsic::setVectorLengthParam(Value *NewEVL) {
Optional<unsigned> VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
- return None;
+ return std::nullopt;
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
case Intrinsic::VPID: \
@@ -428,7 +428,7 @@ Optional<unsigned>
VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
- return None;
+ return std::nullopt;
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
case Intrinsic::VPID: \
@@ -461,7 +461,7 @@ Optional<unsigned> VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
#define END_REGISTER_VP_INTRINSIC(VPID) break;
#include "llvm/IR/VPIntrinsics.def"
}
- return None;
+ return std::nullopt;
}
/// \return The data (payload) operand of this store or scatter.
@@ -481,7 +481,7 @@ Optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
#define END_REGISTER_VP_INTRINSIC(VPID) break;
#include "llvm/IR/VPIntrinsics.def"
}
- return None;
+ return std::nullopt;
}
bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) {
@@ -506,7 +506,7 @@ Optional<unsigned> VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
#define END_REGISTER_VP_INTRINSIC(VPID) break;
#include "llvm/IR/VPIntrinsics.def"
}
- return None;
+ return std::nullopt;
}
Intrinsic::ID VPIntrinsic::getForOpcode(unsigned IROPC) {
@@ -717,7 +717,7 @@ Optional<unsigned> VPReductionIntrinsic::getVectorParamPos(Intrinsic::ID ID) {
default:
break;
}
- return None;
+ return std::nullopt;
}
Optional<unsigned> VPReductionIntrinsic::getStartParamPos(Intrinsic::ID ID) {
@@ -729,7 +729,7 @@ Optional<unsigned> VPReductionIntrinsic::getStartParamPos(Intrinsic::ID ID) {
default:
break;
}
- return None;
+ return std::nullopt;
}
Instruction::BinaryOps BinaryOpIntrinsic::getBinaryOp() const {
diff --git a/llvm/lib/IR/LLVMRemarkStreamer.cpp b/llvm/lib/IR/LLVMRemarkStreamer.cpp
index f7e2aa4e9a35d..915f6080c6ea6 100644
--- a/llvm/lib/IR/LLVMRemarkStreamer.cpp
+++ b/llvm/lib/IR/LLVMRemarkStreamer.cpp
@@ -48,7 +48,7 @@ static remarks::Type toRemarkType(enum DiagnosticKind Kind) {
static Optional<remarks::RemarkLocation>
toRemarkLocation(const DiagnosticLocation &DL) {
if (!DL.isValid())
- return None;
+ return std::nullopt;
StringRef File = DL.getRelativePath();
unsigned Line = DL.getLine();
unsigned Col = DL.getColumn();
diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp
index df08eb2063efb..38ab1d3d10244 100644
--- a/llvm/lib/IR/MDBuilder.cpp
+++ b/llvm/lib/IR/MDBuilder.cpp
@@ -53,7 +53,7 @@ MDNode *MDBuilder::createBranchWeights(ArrayRef<uint32_t> Weights) {
}
MDNode *MDBuilder::createUnpredictable() {
- return MDNode::get(Context, None);
+ return MDNode::get(Context, std::nullopt);
}
MDNode *MDBuilder::createFunctionEntryCount(
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index bde83717ebef7..1237070979035 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -82,7 +82,7 @@ static Metadata *canonicalizeMetadataForValue(LLVMContext &Context,
Metadata *MD) {
if (!MD)
// !{}
- return MDNode::get(Context, None);
+ return MDNode::get(Context, std::nullopt);
// Return early if this isn't a single-operand MDNode.
auto *N = dyn_cast<MDNode>(MD);
@@ -91,7 +91,7 @@ static Metadata *canonicalizeMetadataForValue(LLVMContext &Context,
if (!N->getOperand(0))
// !{}
- return MDNode::get(Context, None);
+ return MDNode::get(Context, std::nullopt);
if (auto *C = dyn_cast<ConstantAsMetadata>(N->getOperand(0)))
// Look through the MDNode.
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 33d71fb5ad817..a9e80b3d35472 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -620,7 +620,7 @@ Optional<CodeModel::Model> Module::getCodeModel() const {
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Code Model"));
if (!Val)
- return None;
+ return std::nullopt;
return static_cast<CodeModel::Model>(
cast<ConstantInt>(Val->getValue())->getZExtValue());
@@ -778,7 +778,7 @@ static VersionTuple getSDKVersionMD(Metadata *MD) {
return {};
auto getVersionComponent = [&](unsigned Index) -> std::optional<unsigned> {
if (Index >= Arr->getNumElements())
- return None;
+ return std::nullopt;
return (unsigned)Arr->getElementAsInteger(Index);
};
auto Major = getVersionComponent(0);
diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp
index c2a4a7c299152..0e263118d885b 100644
--- a/llvm/lib/IR/Operator.cpp
+++ b/llvm/lib/IR/Operator.cpp
@@ -35,7 +35,7 @@ bool Operator::hasPoisonGeneratingFlags() const {
case Instruction::GetElementPtr: {
auto *GEP = cast<GEPOperator>(this);
// Note: inrange exists on constexpr only
- return GEP->isInBounds() || GEP->getInRangeIndex() != None;
+ return GEP->isInBounds() || GEP->getInRangeIndex() != std::nullopt;
}
default:
if (const auto *FP = dyn_cast<FPMathOperator>(this))
diff --git a/llvm/lib/IR/PseudoProbe.cpp b/llvm/lib/IR/PseudoProbe.cpp
index 5cad887b295db..ae307d871f595 100644
--- a/llvm/lib/IR/PseudoProbe.cpp
+++ b/llvm/lib/IR/PseudoProbe.cpp
@@ -42,7 +42,7 @@ Optional<PseudoProbe> extractProbeFromDiscriminator(const Instruction &Inst) {
return Probe;
}
}
- return None;
+ return std::nullopt;
}
Optional<PseudoProbe> extractProbe(const Instruction &Inst) {
@@ -59,7 +59,7 @@ Optional<PseudoProbe> extractProbe(const Instruction &Inst) {
if (isa<CallBase>(&Inst) && !isa<IntrinsicInst>(&Inst))
return extractProbeFromDiscriminator(Inst);
- return None;
+ return std::nullopt;
}
void setProbeDistributionFactor(Instruction &Inst, float Factor) {
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 6676717b4c597..2590588ab30ad 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -385,7 +385,7 @@ FunctionType *FunctionType::get(Type *ReturnType,
}
FunctionType *FunctionType::get(Type *Result, bool isVarArg) {
- return get(Result, None, isVarArg);
+ return get(Result, std::nullopt, isVarArg);
}
bool FunctionType::isValidReturnType(Type *RetTy) {
@@ -518,7 +518,7 @@ StructType *StructType::create(LLVMContext &Context, StringRef Name) {
}
StructType *StructType::get(LLVMContext &Context, bool isPacked) {
- return get(Context, None, isPacked);
+ return get(Context, std::nullopt, isPacked);
}
StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements,
More information about the llvm-commits
mailing list