diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index 8dfc3bf4f1e58a..af5f05bc0d365a 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -10,9 +10,9 @@ #define LLVM_CLANG_APINOTES_TYPES_H #include "clang/Basic/Specifiers.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include +#include #include namespace llvm { @@ -74,12 +74,12 @@ class CommonEntityInfo { : Unavailable(0), UnavailableInSwift(0), SwiftPrivateSpecified(0), SwiftPrivate(0) {} - llvm::Optional isSwiftPrivate() const { - return SwiftPrivateSpecified ? llvm::Optional(SwiftPrivate) + std::optional isSwiftPrivate() const { + return SwiftPrivateSpecified ? std::optional(SwiftPrivate) : std::nullopt; } - void setSwiftPrivate(llvm::Optional Private) { + void setSwiftPrivate(std::optional Private) { SwiftPrivateSpecified = Private.has_value(); SwiftPrivate = Private.value_or(0); } @@ -131,38 +131,38 @@ class CommonTypeInfo : public CommonEntityInfo { /// The Swift type to which a given type is bridged. /// /// Reflects the swift_bridge attribute. - llvm::Optional SwiftBridge; + std::optional SwiftBridge; /// The NS error domain for this type. - llvm::Optional NSErrorDomain; + std::optional NSErrorDomain; public: CommonTypeInfo() {} - const llvm::Optional &getSwiftBridge() const { + const std::optional &getSwiftBridge() const { return SwiftBridge; } - void setSwiftBridge(const llvm::Optional &SwiftType) { + void setSwiftBridge(const std::optional &SwiftType) { SwiftBridge = SwiftType; } - void setSwiftBridge(const llvm::Optional &SwiftType) { + void setSwiftBridge(const std::optional &SwiftType) { SwiftBridge = SwiftType - ? llvm::Optional(std::string(*SwiftType)) + ? std::optional(std::string(*SwiftType)) : std::nullopt; } - const llvm::Optional &getNSErrorDomain() const { + const std::optional &getNSErrorDomain() const { return NSErrorDomain; } - void setNSErrorDomain(const llvm::Optional &Domain) { + void setNSErrorDomain(const std::optional &Domain) { NSErrorDomain = Domain; } - void setNSErrorDomain(const llvm::Optional &Domain) { - NSErrorDomain = Domain ? llvm::Optional(std::string(*Domain)) + void setNSErrorDomain(const std::optional &Domain) { + NSErrorDomain = Domain ? std::optional(std::string(*Domain)) : std::nullopt; } @@ -221,9 +221,9 @@ class ObjCContextInfo : public CommonTypeInfo { /// /// Returns the default nullability, if implied, or std::nullopt if there is /// none. - llvm::Optional getDefaultNullability() const { + std::optional getDefaultNullability() const { return HasDefaultNullability - ? llvm::Optional( + ? std::optional( static_cast(DefaultNullability)) : std::nullopt; } @@ -237,21 +237,21 @@ class ObjCContextInfo : public CommonTypeInfo { bool hasDesignatedInits() const { return HasDesignatedInits; } void setHasDesignatedInits(bool Value) { HasDesignatedInits = Value; } - llvm::Optional getSwiftImportAsNonGeneric() const { + std::optional getSwiftImportAsNonGeneric() const { return SwiftImportAsNonGenericSpecified - ? llvm::Optional(SwiftImportAsNonGeneric) + ? std::optional(SwiftImportAsNonGeneric) : std::nullopt; } - void setSwiftImportAsNonGeneric(llvm::Optional Value) { + void setSwiftImportAsNonGeneric(std::optional Value) { SwiftImportAsNonGenericSpecified = Value.has_value(); SwiftImportAsNonGeneric = Value.value_or(false); } - llvm::Optional getSwiftObjCMembers() const { - return SwiftObjCMembersSpecified ? llvm::Optional(SwiftObjCMembers) + std::optional getSwiftObjCMembers() const { + return SwiftObjCMembersSpecified ? std::optional(SwiftObjCMembers) : std::nullopt; } - void setSwiftObjCMembers(llvm::Optional Value) { + void setSwiftObjCMembers(std::optional Value) { SwiftObjCMembersSpecified = Value.has_value(); SwiftObjCMembers = Value.value_or(false); } @@ -315,8 +315,8 @@ class VariableInfo : public CommonEntityInfo { public: VariableInfo() : NullabilityAudited(false), Nullable(0) {} - llvm::Optional getNullability() const { - return NullabilityAudited ? llvm::Optional( + std::optional getNullability() const { + return NullabilityAudited ? std::optional( static_cast(Nullable)) : std::nullopt; } @@ -364,12 +364,12 @@ class ObjCPropertyInfo : public VariableInfo { ObjCPropertyInfo() : SwiftImportAsAccessorsSpecified(false), SwiftImportAsAccessors(false) {} - llvm::Optional getSwiftImportAsAccessors() const { + std::optional getSwiftImportAsAccessors() const { return SwiftImportAsAccessorsSpecified - ? llvm::Optional(SwiftImportAsAccessors) + ? std::optional(SwiftImportAsAccessors) : std::nullopt; } - void setSwiftImportAsAccessors(llvm::Optional Value) { + void setSwiftImportAsAccessors(std::optional Value) { SwiftImportAsAccessorsSpecified = Value.has_value(); SwiftImportAsAccessors = Value.value_or(false); } @@ -428,23 +428,23 @@ class ParamInfo : public VariableInfo { ParamInfo() : NoEscapeSpecified(false), NoEscape(false), RawRetainCountConvention() {} - llvm::Optional isNoEscape() const { + std::optional isNoEscape() const { if (!NoEscapeSpecified) return std::nullopt; return NoEscape; } - void setNoEscape(llvm::Optional Value) { + void setNoEscape(std::optional Value) { NoEscapeSpecified = Value.has_value(); NoEscape = Value.value_or(false); } - llvm::Optional getRetainCountConvention() const { + std::optional getRetainCountConvention() const { if (!RawRetainCountConvention) return std::nullopt; return static_cast(RawRetainCountConvention - 1); } void - setRetainCountConvention(llvm::Optional Value) { + setRetainCountConvention(std::optional Value) { RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0; assert(getRetainCountConvention() == Value && "bitfield too small"); } @@ -556,13 +556,13 @@ class FunctionInfo : public CommonEntityInfo { NullabilityKind getReturnTypeInfo() const { return getTypeInfo(0); } - llvm::Optional getRetainCountConvention() const { + std::optional getRetainCountConvention() const { if (!RawRetainCountConvention) return std::nullopt; return static_cast(RawRetainCountConvention - 1); } void - setRetainCountConvention(llvm::Optional Value) { + setRetainCountConvention(std::optional Value) { RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0; assert(getRetainCountConvention() == Value && "bitfield too small"); } @@ -659,16 +659,16 @@ class TagInfo : public CommonTypeInfo { unsigned IsFlagEnum : 1; public: - llvm::Optional EnumExtensibility; + std::optional EnumExtensibility; TagInfo() : HasFlagEnum(0), IsFlagEnum(0) {} - llvm::Optional isFlagEnum() const { + std::optional isFlagEnum() const { if (HasFlagEnum) return IsFlagEnum; return std::nullopt; } - void setFlagEnum(llvm::Optional Value) { + void setFlagEnum(std::optional Value) { HasFlagEnum = Value.has_value(); IsFlagEnum = Value.value_or(false); } @@ -703,7 +703,7 @@ inline bool operator!=(const TagInfo &LHS, const TagInfo &RHS) { /// Describes API notes data for a typedef. class TypedefInfo : public CommonTypeInfo { public: - llvm::Optional SwiftWrapper; + std::optional SwiftWrapper; TypedefInfo() {} diff --git a/clang/include/clang/Basic/CLWarnings.h b/clang/include/clang/Basic/CLWarnings.h index e3351f430c4379..9b8be93bad3a6e 100644 --- a/clang/include/clang/Basic/CLWarnings.h +++ b/clang/include/clang/Basic/CLWarnings.h @@ -9,7 +9,7 @@ #ifndef LLVM_CLANG_BASIC_CLWARNINGS_H #define LLVM_CLANG_BASIC_CLWARNINGS_H -#include "llvm/ADT/Optional.h" +#include namespace clang { @@ -19,7 +19,7 @@ enum class Group; /// For cl.exe warning IDs that cleany map to clang diagnostic groups, /// returns the corresponding group. Else, returns an empty Optional. -llvm::Optional diagGroupFromCLWarningID(unsigned); +std::optional diagGroupFromCLWarningID(unsigned); } // end namespace clang diff --git a/clang/include/clang/Basic/CustomizableOptional.h b/clang/include/clang/Basic/CustomizableOptional.h index 52e761d449330a..7323a818b0b51f 100644 --- a/clang/include/clang/Basic/CustomizableOptional.h +++ b/clang/include/clang/Basic/CustomizableOptional.h @@ -10,11 +10,11 @@ #define CLANG_BASIC_CUSTOMIZABLEOPTIONAL_H #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/type_traits.h" #include #include +#include #include namespace clang { @@ -46,9 +46,9 @@ template class CustomizableOptional { : Storage(std::in_place, std::forward(Args)...) {} // Allow conversion from Optional. - constexpr CustomizableOptional(const llvm::Optional &y) + constexpr CustomizableOptional(const std::optional &y) : CustomizableOptional(y ? *y : CustomizableOptional()) {} - constexpr CustomizableOptional(llvm::Optional &&y) + constexpr CustomizableOptional(std::optional &&y) : CustomizableOptional(y ? std::move(*y) : CustomizableOptional()) {} CustomizableOptional &operator=(T &&y) { @@ -99,11 +99,11 @@ template class CustomizableOptional { } // Allow conversion to Optional. - explicit operator llvm::Optional &() const & { - return *this ? **this : llvm::Optional(); + explicit operator std::optional &() const & { + return *this ? **this : std::optional(); } - explicit operator llvm::Optional &&() const && { - return *this ? std::move(**this) : llvm::Optional(); + explicit operator std::optional &&() const && { + return *this ? std::move(**this) : std::optional(); } }; diff --git a/clang/include/clang/Basic/TargetID.h b/clang/include/clang/Basic/TargetID.h index d7c05b2d0c49ef..f1922942804eb0 100644 --- a/clang/include/clang/Basic/TargetID.h +++ b/clang/include/clang/Basic/TargetID.h @@ -12,6 +12,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Triple.h" +#include #include namespace clang { @@ -37,9 +38,9 @@ llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T, /// If the target ID contains feature+, map it to true. /// If the target ID contains feature-, map it to false. /// If the target ID does not contain a feature (default), do not map it. -llvm::Optional -parseTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch, - llvm::StringMap *FeatureMap); +std::optional parseTargetID(const llvm::Triple &T, + llvm::StringRef OffloadArch, + llvm::StringMap *FeatureMap); /// Returns canonical target ID, assuming \p Processor is canonical and all /// entries in \p Features are valid. diff --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h index b5ce83a2654deb..0d5ebf058e6047 100644 --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -11,10 +11,10 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include +#include #include #include #include @@ -27,7 +27,7 @@ class raw_ostream; namespace clang { namespace RISCV { -using VScaleVal = llvm::Optional; +using VScaleVal = std::optional; // Modifier for vector type. enum class VectorTypeModifier : uint8_t { @@ -197,7 +197,7 @@ struct PrototypeDescriptor { static const PrototypeDescriptor Mask; static const PrototypeDescriptor Vector; static const PrototypeDescriptor VL; - static llvm::Optional + static std::optional parsePrototypeDescriptor(llvm::StringRef PrototypeStr); }; @@ -238,7 +238,7 @@ struct LMULType { LMULType(int Log2LMUL); // Return the C/C++ string representation of LMUL std::string str() const; - llvm::Optional getScale(unsigned ElementBitwidth) const; + std::optional getScale(unsigned ElementBitwidth) const; void MulLog2LMUL(int Log2LMUL); }; @@ -354,11 +354,11 @@ class RVVTypeCache { /// and LMUL with type transformers). It also record result of type in legal /// or illegal set to avoid compute the same config again. The result maybe /// have illegal RVVType. - llvm::Optional + std::optional computeTypes(BasicType BT, int Log2LMUL, unsigned NF, llvm::ArrayRef Prototype); - llvm::Optional computeType(BasicType BT, int Log2LMUL, - PrototypeDescriptor Proto); + std::optional computeType(BasicType BT, int Log2LMUL, + PrototypeDescriptor Proto); }; enum PolicyScheme : uint8_t { diff --git a/clang/lib/Basic/CLWarnings.cpp b/clang/lib/Basic/CLWarnings.cpp index 0cf367d9f7f62d..5449d8f59fcf47 100644 --- a/clang/lib/Basic/CLWarnings.cpp +++ b/clang/lib/Basic/CLWarnings.cpp @@ -12,10 +12,11 @@ #include "clang/Basic/CLWarnings.h" #include "clang/Basic/DiagnosticCategories.h" +#include using namespace clang; -llvm::Optional +std::optional clang::diagGroupFromCLWarningID(unsigned CLWarningID) { switch (CLWarningID) { case 4005: return diag::Group::MacroRedefined; diff --git a/clang/lib/Basic/TargetID.cpp b/clang/lib/Basic/TargetID.cpp index 20e07cb7266a7b..7cc4d67e3a5227 100644 --- a/clang/lib/Basic/TargetID.cpp +++ b/clang/lib/Basic/TargetID.cpp @@ -101,7 +101,7 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID, return Processor; } -llvm::Optional +std::optional parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID, llvm::StringMap *FeatureMap) { auto OptionalProcessor = diff --git a/clang/lib/DirectoryWatcher/DirectoryScanner.cpp b/clang/lib/DirectoryWatcher/DirectoryScanner.cpp index fa060af9c7ae51..428f87eddc7b60 100644 --- a/clang/lib/DirectoryWatcher/DirectoryScanner.cpp +++ b/clang/lib/DirectoryWatcher/DirectoryScanner.cpp @@ -9,12 +9,13 @@ #include "DirectoryScanner.h" #include "llvm/Support/Path.h" +#include namespace clang { using namespace llvm; -Optional getFileStatus(StringRef Path) { +std::optional getFileStatus(StringRef Path) { sys::fs::file_status Status; std::error_code EC = status(Path, Status); if (EC) diff --git a/clang/lib/DirectoryWatcher/DirectoryScanner.h b/clang/lib/DirectoryWatcher/DirectoryScanner.h index 42fe8efcc8fecd..84cffa5704f76f 100644 --- a/clang/lib/DirectoryWatcher/DirectoryScanner.h +++ b/clang/lib/DirectoryWatcher/DirectoryScanner.h @@ -8,6 +8,7 @@ #include "clang/DirectoryWatcher/DirectoryWatcher.h" #include "llvm/Support/FileSystem.h" +#include #include #include @@ -24,6 +25,6 @@ getAsFileEvents(const std::vector &Scan); /// Gets status of file (or directory) at \p Path. /// \returns std::nullopt if \p Path doesn't exist or can't get the status. -llvm::Optional getFileStatus(llvm::StringRef Path); +std::optional getFileStatus(llvm::StringRef Path); } // namespace clang diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h index 5815742d57ac72..91e3ccf2ec3047 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h @@ -10,7 +10,7 @@ #define LLVM_CLANG_ANALYZER_WEBKIT_PTRTYPESEMANTICS_H #include "llvm/ADT/APInt.h" -#include "llvm/ADT/Optional.h" +#include namespace clang { class CXXBaseSpecifier; @@ -28,30 +28,30 @@ class Type; /// \returns CXXRecordDecl of the base if the type is ref-countable, nullptr if /// not, std::nullopt if inconclusive. -llvm::Optional -isRefCountable(const clang::CXXBaseSpecifier *Base); +std::optional +isRefCountable(const clang::CXXBaseSpecifier* Base); /// \returns true if \p Class is ref-countable, false if not, std::nullopt if /// inconclusive. -llvm::Optional isRefCountable(const clang::CXXRecordDecl *Class); +std::optional isRefCountable(const clang::CXXRecordDecl* Class); /// \returns true if \p Class is ref-counted, false if not. bool isRefCounted(const clang::CXXRecordDecl *Class); /// \returns true if \p Class is ref-countable AND not ref-counted, false if /// not, std::nullopt if inconclusive. -llvm::Optional isUncounted(const clang::CXXRecordDecl *Class); +std::optional isUncounted(const clang::CXXRecordDecl* Class); /// \returns true if \p T is either a raw pointer or reference to an uncounted /// class, false if not, std::nullopt if inconclusive. -llvm::Optional isUncountedPtr(const clang::Type *T); +std::optional isUncountedPtr(const clang::Type* T); /// \returns true if \p F creates ref-countable object from uncounted parameter, /// false if not. bool isCtorOfRefCounted(const clang::FunctionDecl *F); /// \returns true if \p M is getter of a ref-counted class, false if not. -llvm::Optional isGetterOfRefCounted(const clang::CXXMethodDecl *Method); +std::optional isGetterOfRefCounted(const clang::CXXMethodDecl* Method); /// \returns true if \p F is a conversion between ref-countable or ref-counted /// pointer types. diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp index c1c4a30576adc3..9a550806f69d82 100644 --- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -8,7 +8,6 @@ #include "clang/Support/RISCVVIntrinsicUtils.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" @@ -16,6 +15,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" #include +#include using namespace llvm; @@ -362,7 +362,8 @@ void RVVType::applyBasicType() { assert(ElementBitwidth != 0 && "Bad element bitwidth!"); } -Optional PrototypeDescriptor::parsePrototypeDescriptor( +std::optional +PrototypeDescriptor::parsePrototypeDescriptor( llvm::StringRef PrototypeDescriptorStr) { PrototypeDescriptor PD; BaseTypeModifier PT = BaseTypeModifier::Invalid; @@ -783,7 +784,7 @@ void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) { Scale = LMUL.getScale(ElementBitwidth); } -Optional +std::optional RVVTypeCache::computeTypes(BasicType BT, int Log2LMUL, unsigned NF, ArrayRef Prototype) { // LMUL x NF must be less than or equal to 8. @@ -814,8 +815,8 @@ static uint64_t computeRVVTypeHashValue(BasicType BT, int Log2LMUL, ((uint64_t)(Proto.VTM & 0xff) << 32); } -Optional RVVTypeCache::computeType(BasicType BT, int Log2LMUL, - PrototypeDescriptor Proto) { +std::optional RVVTypeCache::computeType(BasicType BT, int Log2LMUL, + PrototypeDescriptor Proto) { uint64_t Idx = computeRVVTypeHashValue(BT, Log2LMUL, Proto); // Search first auto It = LegalTypes.find(Idx); diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 2e60519691f044..ad942efb352e84 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -53,6 +53,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include +#include using namespace llvm; using namespace llvm::opt; @@ -1231,8 +1232,8 @@ linkAndWrapDeviceFiles(SmallVectorImpl &LinkerInputFiles, return WrappedOutput; } -Optional findFile(StringRef Dir, StringRef Root, - const Twine &Name) { +std::optional findFile(StringRef Dir, StringRef Root, + const Twine &Name) { SmallString<128> Path; if (Dir.startswith("=")) sys::path::append(Path, Root, Dir.substr(1), Name); @@ -1244,20 +1245,24 @@ Optional findFile(StringRef Dir, StringRef Root, return std::nullopt; } -Optional findFromSearchPaths(StringRef Name, StringRef Root, - ArrayRef SearchPaths) { +std::optional +findFromSearchPaths(StringRef Name, StringRef Root, + ArrayRef SearchPaths) { for (StringRef Dir : SearchPaths) - if (Optional File = findFile(Dir, Root, Name)) + if (std::optional File = findFile(Dir, Root, Name)) return File; return std::nullopt; } -Optional searchLibraryBaseName(StringRef Name, StringRef Root, - ArrayRef SearchPaths) { +std::optional +searchLibraryBaseName(StringRef Name, StringRef Root, + ArrayRef SearchPaths) { for (StringRef Dir : SearchPaths) { - if (Optional File = findFile(Dir, Root, "lib" + Name + ".so")) + if (std::optional File = + findFile(Dir, Root, "lib" + Name + ".so")) return File; - if (Optional File = findFile(Dir, Root, "lib" + Name + ".a")) + if (std::optional File = + findFile(Dir, Root, "lib" + Name + ".a")) return File; } return std::nullopt; @@ -1265,8 +1270,8 @@ Optional searchLibraryBaseName(StringRef Name, StringRef Root, /// Search for static libraries in the linker's library path given input like /// `-lfoo` or `-l:libfoo.a`. -Optional searchLibrary(StringRef Input, StringRef Root, - ArrayRef SearchPaths) { +std::optional searchLibrary(StringRef Input, StringRef Root, + ArrayRef SearchPaths) { if (Input.startswith(":")) return findFromSearchPaths(Input.drop_front(), Root, SearchPaths); return searchLibraryBaseName(Input, Root, SearchPaths); diff --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp index 53361a1184f5d1..4ad6f8025674b4 100644 --- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp +++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include using namespace llvm; @@ -177,7 +178,7 @@ struct VerifyingConsumer { } // Not locking - caller has to lock Mtx. - llvm::Optional result() const { + std::optional result() const { if (ExpectedInitial.empty() && ExpectedNonInitial.empty() && UnexpectedInitial.empty() && UnexpectedNonInitial.empty()) return true; diff --git a/clang/unittests/libclang/LibclangTest.cpp b/clang/unittests/libclang/LibclangTest.cpp index 0845476f31dea6..809426a01ca7a6 100644 --- a/clang/unittests/libclang/LibclangTest.cpp +++ b/clang/unittests/libclang/LibclangTest.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #define DEBUG_TYPE "libclang-test" @@ -934,7 +935,7 @@ void Class1::fun() {} ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args, 1, nullptr, 0, TUFlags); - llvm::Optional typeRefCsr; + std::optional typeRefCsr; Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult { if (cursor.kind == CXCursor_TypeRef) { typeRefCsr.emplace(cursor); diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index ec682edb57f630..0b553254682ca8 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -12,7 +12,6 @@ #include "TableGenBackends.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" @@ -30,6 +29,7 @@ #include #include #include +#include #include using namespace llvm; @@ -250,8 +250,9 @@ typedef llvm::PointerUnion VecOrSet; namespace { class InferPedantic { - typedef llvm::DenseMap > > GMap; + typedef llvm::DenseMap>> + GMap; DiagGroupParentMap &DiagGroupParents; const std::vector &Diags; @@ -675,7 +676,7 @@ struct DiagnosticTextBuilder { }; template struct DiagTextVisitor { - using ModifierMappingsType = Optional>; + using ModifierMappingsType = std::optional>; private: Derived &getDerived() { return static_cast(*this); } @@ -706,7 +707,7 @@ template struct DiagTextVisitor { private: DiagTextVisitor &Visitor; - Optional> OldMappings; + std::optional> OldMappings; public: Piece *Substitution; diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 98e195d0a63a23..8f46b08b1366f0 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -26,7 +26,6 @@ #include "TableGenBackends.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" @@ -44,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -559,7 +559,7 @@ class NeonEmitter { /// Called by Intrinsic - this attempts to get an intrinsic that takes /// the given types as arguments. Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types, - Optional MangledName); + std::optional MangledName); /// Called by Intrinsic - returns a globally-unique number. unsigned getUniqueNumber() { return UniqueNumber++; } @@ -1471,7 +1471,7 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) { N = SI->getAsUnquotedString(); else N = emitDagArg(DI->getArg(0), "").second; - Optional MangledName; + std::optional MangledName; if (MatchMangledName) { if (Intr.getRecord()->getValueAsBit("isLaneQ")) N += "q"; @@ -1895,7 +1895,7 @@ void Intrinsic::indexBody() { //===----------------------------------------------------------------------===// Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types, - Optional MangledName) { + std::optional MangledName) { // First, look up the name in the intrinsic map. assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(), ("Intrinsic '" + Name + "' not found!").str()); diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp index b69712e57f04f5..d9caafeec8c421 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -25,6 +25,7 @@ #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include +#include using namespace llvm; using namespace clang::RISCV; @@ -560,7 +561,7 @@ void RVVEmitter::createRVVIntrinsics( for (char I : TypeRange) { for (int Log2LMUL : Log2LMULList) { BasicType BT = ParseBasicType(I); - Optional Types = + std::optional Types = TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype); // Ignored to create new intrinsic if there are any illegal types. if (!Types) @@ -584,7 +585,7 @@ void RVVEmitter::createRVVIntrinsics( BasicPrototype, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU, UnMaskedPolicyScheme, P); - Optional PolicyTypes = + std::optional PolicyTypes = TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype); Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName, @@ -596,7 +597,7 @@ void RVVEmitter::createRVVIntrinsics( if (!HasMasked) continue; // Create a masked intrinsic - Optional MaskTypes = + std::optional MaskTypes = TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype); Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName, @@ -611,7 +612,7 @@ void RVVEmitter::createRVVIntrinsics( RVVIntrinsic::computeBuiltinTypes( BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF, IsPrototypeDefaultTU, MaskedPolicyScheme, P); - Optional PolicyTypes = + std::optional PolicyTypes = TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype); Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName, OverloadedSuffixStr,