Skip to content

Commit bd8e6bc

Browse files
authored
Merge pull request #66861 from etcwilde/ewilde/llvm-all-the-optionals
[NFC] llvm-all-the-optionals!
2 parents 50d2f4d + 250082d commit bd8e6bc

File tree

684 files changed

+8388
-8297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+8388
-8297
lines changed

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class SDKContext {
179179
CheckerOptions Opts;
180180
std::vector<BreakingAttributeInfo> BreakingAttrs;
181181
// The common version of two ABI/API descriptors under comparison.
182-
Optional<uint8_t> CommonVersion;
182+
llvm::Optional<uint8_t> CommonVersion;
183+
183184
public:
184185
// Define the set of known identifiers.
185186
#define IDENTIFIER_WITH_NAME(Name, IdStr) StringRef Id_##Name = IdStr;
@@ -231,7 +232,7 @@ class SDKContext {
231232
const CheckerOptions &getOpts() const { return Opts; }
232233
bool shouldIgnore(Decl *D, const Decl* Parent = nullptr) const;
233234
ArrayRef<BreakingAttributeInfo> getBreakingAttributeInfo() const { return BreakingAttrs; }
234-
Optional<uint8_t> getFixedBinaryOrder(ValueDecl *VD) const;
235+
llvm::Optional<uint8_t> getFixedBinaryOrder(ValueDecl *VD) const;
235236

236237
CompilerInstance &newCompilerInstance() {
237238
CIs.emplace_back(new CompilerInstance());
@@ -363,7 +364,7 @@ class SDKNodeDecl: public SDKNode {
363364
// In ABI mode, this field is populated as a user-friendly version of GenericSig.
364365
// Diagnostic preferes the sugared versions if they differ as well.
365366
StringRef SugaredGenericSig;
366-
Optional<uint8_t> FixedBinaryOrder;
367+
llvm::Optional<uint8_t> FixedBinaryOrder;
367368
PlatformIntroVersion introVersions;
368369
StringRef ObjCName;
369370

@@ -586,11 +587,11 @@ class SDKNodeDeclType: public SDKNodeDecl {
586587
return InheritsConvenienceInitializers;
587588
};
588589

589-
Optional<SDKNodeDeclType*> getSuperclass() const;
590+
llvm::Optional<SDKNodeDeclType *> getSuperclass() const;
590591

591592
/// Finding the node through all children, including the inherited ones,
592593
/// whose printed name matches with the given name.
593-
Optional<SDKNodeDecl*> lookupChildByPrintedName(StringRef Name) const;
594+
llvm::Optional<SDKNodeDecl *> lookupChildByPrintedName(StringRef Name) const;
594595
SDKNodeType *getRawValueType() const;
595596
bool isConformingTo(KnownProtocolKind Kind) const;
596597
void jsonize(json::Output &out) override;
@@ -684,7 +685,7 @@ class SDKNodeDeclMacro : public SDKNodeDecl {
684685
class SDKNodeDeclAbstractFunc : public SDKNodeDecl {
685686
bool IsThrowing;
686687
bool ReqNewWitnessTableEntry;
687-
Optional<uint8_t> SelfIndex;
688+
llvm::Optional<uint8_t> SelfIndex;
688689

689690
protected:
690691
SDKNodeDeclAbstractFunc(SDKNodeInitInfo Info, SDKNodeKind Kind);
@@ -693,7 +694,7 @@ class SDKNodeDeclAbstractFunc : public SDKNodeDecl {
693694
bool isThrowing() const { return IsThrowing; }
694695
bool reqNewWitnessTableEntry() const { return ReqNewWitnessTableEntry; }
695696
uint8_t getSelfIndex() const { return SelfIndex.value(); }
696-
Optional<uint8_t> getSelfIndexOptional() const { return SelfIndex; }
697+
llvm::Optional<uint8_t> getSelfIndexOptional() const { return SelfIndex; }
697698
bool hasSelfIndex() const { return SelfIndex.has_value(); }
698699
static bool classof(const SDKNode *N);
699700
virtual void jsonize(json::Output &out) override;

include/swift/AST/ASTContext.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ enum class KnownFoundationEntity {
168168

169169
/// Retrieve the Foundation entity kind for the given Objective-C
170170
/// entity name.
171-
Optional<KnownFoundationEntity> getKnownFoundationEntity(StringRef name);
171+
llvm::Optional<KnownFoundationEntity> getKnownFoundationEntity(StringRef name);
172172

173173
/// Retrieve the Swift name for the given Foundation entity, where
174174
/// "NS" prefix stripping will apply under omit-needless-words.
@@ -343,7 +343,7 @@ class ASTContext final {
343343
unsigned NumTypoCorrections = 0;
344344

345345
/// Cached mapping from types to their associated tangent spaces.
346-
llvm::DenseMap<Type, Optional<TangentSpace>> AutoDiffTangentSpaces;
346+
llvm::DenseMap<Type, llvm::Optional<TangentSpace>> AutoDiffTangentSpaces;
347347

348348
/// A cache of derivative function types per configuration.
349349
llvm::DenseMap<SILAutoDiffDerivativeFunctionKey, CanSILFunctionType>
@@ -803,9 +803,9 @@ class ASTContext final {
803803
///
804804
/// SIL analog of \c ASTContext::getClangFunctionType .
805805
const clang::Type *
806-
getCanonicalClangFunctionType(
807-
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
808-
SILFunctionType::Representation trueRep);
806+
getCanonicalClangFunctionType(ArrayRef<SILParameterInfo> params,
807+
llvm::Optional<SILResultInfo> result,
808+
SILFunctionType::Representation trueRep);
809809

810810
/// Instantiates "Impl.Converter" if needed, then translate Swift generic
811811
/// substitutions to equivalent C++ types using \p templateParams and \p
@@ -1031,25 +1031,24 @@ class ASTContext final {
10311031

10321032
/// Retrieve the module dependencies for the module with the given name.
10331033
///
1034-
Optional<const ModuleDependencyInfo*> getModuleDependencies(
1035-
StringRef moduleName,
1036-
ModuleDependenciesCache &cache,
1034+
llvm::Optional<const ModuleDependencyInfo *> getModuleDependencies(
1035+
StringRef moduleName, ModuleDependenciesCache &cache,
10371036
InterfaceSubContextDelegate &delegate,
1038-
bool optionalDependencyLookup = false,
1039-
bool isTestableImport = false,
1040-
llvm::Optional<std::pair<std::string, swift::ModuleDependencyKind>> dependencyOf = None);
1037+
bool optionalDependencyLookup = false, bool isTestableImport = false,
1038+
llvm::Optional<std::pair<std::string, swift::ModuleDependencyKind>>
1039+
dependencyOf = llvm::None);
10411040

10421041
/// Retrieve the module dependencies for the Clang module with the given name.
1043-
Optional<const ModuleDependencyInfo*> getClangModuleDependencies(
1044-
StringRef moduleName,
1045-
ModuleDependenciesCache &cache,
1046-
InterfaceSubContextDelegate &delegate);
1042+
llvm::Optional<const ModuleDependencyInfo *>
1043+
getClangModuleDependencies(StringRef moduleName,
1044+
ModuleDependenciesCache &cache,
1045+
InterfaceSubContextDelegate &delegate);
10471046

10481047
/// Retrieve the module dependencies for the Swift module with the given name.
1049-
Optional<const ModuleDependencyInfo*> getSwiftModuleDependencies(
1050-
StringRef moduleName,
1051-
ModuleDependenciesCache &cache,
1052-
InterfaceSubContextDelegate &delegate);
1048+
llvm::Optional<const ModuleDependencyInfo *>
1049+
getSwiftModuleDependencies(StringRef moduleName,
1050+
ModuleDependenciesCache &cache,
1051+
InterfaceSubContextDelegate &delegate);
10531052

10541053
/// Compute the extra implicit framework search paths on Apple platforms:
10551054
/// $SDKROOT/System/Library/Frameworks/ and $SDKROOT/Library/Frameworks/.
@@ -1519,7 +1518,7 @@ class ASTContext final {
15191518
private:
15201519
friend Decl;
15211520

1522-
Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
1521+
llvm::Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
15231522
void setExternalSourceLocs(const Decl *D, ExternalSourceLocs *Locs);
15241523

15251524
friend TypeBase;

include/swift/AST/ASTDemangler.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
#ifndef SWIFT_AST_ASTDEMANGLER_H
2323
#define SWIFT_AST_ASTDEMANGLER_H
2424

25-
#include "llvm/ADT/ArrayRef.h"
26-
#include "llvm/ADT/StringRef.h"
2725
#include "swift/AST/Types.h"
2826
#include "swift/Demangling/Demangler.h"
2927
#include "swift/Demangling/NamespaceMacros.h"
3028
#include "swift/Demangling/TypeDecoder.h"
29+
#include "llvm/ADT/ArrayRef.h"
30+
#include "llvm/ADT/Optional.h"
31+
#include "llvm/ADT/StringRef.h"
3132

3233
namespace swift {
3334

@@ -123,11 +124,11 @@ class ASTBuilder {
123124
FunctionMetadataDifferentiabilityKind diffKind, Type globalActor);
124125

125126
Type createImplFunctionType(
126-
Demangle::ImplParameterConvention calleeConvention,
127-
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
128-
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
129-
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
130-
ImplFunctionTypeFlags flags);
127+
Demangle::ImplParameterConvention calleeConvention,
128+
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
129+
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
130+
llvm::Optional<Demangle::ImplFunctionResult<Type>> errorResult,
131+
ImplFunctionTypeFlags flags);
131132

132133
Type createProtocolCompositionType(ArrayRef<ProtocolDecl *> protocols,
133134
Type superclass,
@@ -142,11 +143,13 @@ class ASTBuilder {
142143
Type createSymbolicExtendedExistentialType(NodePointer shapeNode,
143144
ArrayRef<Type> genArgs);
144145

145-
Type createExistentialMetatypeType(Type instance,
146-
Optional<Demangle::ImplMetatypeRepresentation> repr=None);
146+
Type createExistentialMetatypeType(
147+
Type instance,
148+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = llvm::None);
147149

148-
Type createMetatypeType(Type instance,
149-
Optional<Demangle::ImplMetatypeRepresentation> repr=None);
150+
Type createMetatypeType(
151+
Type instance,
152+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = llvm::None);
150153

151154
Type createGenericTypeParameterType(unsigned depth, unsigned index);
152155

@@ -222,8 +225,7 @@ class ASTBuilder {
222225
SynthesizedByImporter
223226
};
224227

225-
Optional<ForeignModuleKind>
226-
getForeignModuleKind(NodePointer node);
228+
llvm::Optional<ForeignModuleKind> getForeignModuleKind(NodePointer node);
227229

228230
GenericTypeDecl *findTypeDecl(DeclContext *dc,
229231
Identifier name,

include/swift/AST/ASTMangler.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
#ifndef SWIFT_AST_ASTMANGLER_H
1414
#define SWIFT_AST_ASTMANGLER_H
1515

16-
#include "swift/Basic/Mangler.h"
17-
#include "swift/AST/Types.h"
1816
#include "swift/AST/Decl.h"
1917
#include "swift/AST/FreestandingMacroExpansion.h"
18+
#include "swift/AST/Types.h"
19+
#include "swift/Basic/Mangler.h"
2020
#include "swift/Basic/TaggedUnion.h"
21+
#include "llvm/ADT/Optional.h"
2122

2223
namespace clang {
2324
class NamedDecl;
@@ -251,12 +252,10 @@ class ASTMangler : public Mangler {
251252
///
252253
/// - If `predefined` is true, this mangles the symbol name of the completion handler
253254
/// predefined in the Swift runtime for the given type signature.
254-
std::string mangleObjCAsyncCompletionHandlerImpl(CanSILFunctionType BlockType,
255-
CanType ResultType,
256-
CanGenericSignature Sig,
257-
Optional<bool> FlagParamIsZeroOnError,
258-
bool predefined);
259-
255+
std::string mangleObjCAsyncCompletionHandlerImpl(
256+
CanSILFunctionType BlockType, CanType ResultType, CanGenericSignature Sig,
257+
llvm::Optional<bool> FlagParamIsZeroOnError, bool predefined);
258+
260259
/// Mangle the derivative function (JVP/VJP), or optionally its vtable entry
261260
/// thunk, for the given:
262261
/// - Mangled original function declaration.
@@ -380,8 +379,8 @@ class ASTMangler : public Mangler {
380379
ObjCContext,
381380
ClangImporterContext,
382381
};
383-
384-
static Optional<SpecialContext>
382+
383+
static llvm::Optional<SpecialContext>
385384
getSpecialManglingContext(const ValueDecl *decl, bool useObjCProtocolNames);
386385

387386
static bool isCXXCFOptionsDefinition(const ValueDecl *decl);

include/swift/AST/ASTPrinter.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class ASTPrinter {
133133
/// Called before printing of a declaration.
134134
///
135135
/// Callers should use callPrintDeclPre().
136-
virtual void printDeclPre(const Decl *D, Optional<BracketOptions> Bracket) {}
136+
virtual void printDeclPre(const Decl *D,
137+
llvm::Optional<BracketOptions> Bracket) {}
137138
/// Called before printing at the point which would be considered the location
138139
/// of the declaration (normally the name of the declaration).
139140
///
@@ -147,7 +148,8 @@ class ASTPrinter {
147148
/// Called after finishing printing of a declaration.
148149
///
149150
/// Callers should use callPrintDeclPost().
150-
virtual void printDeclPost(const Decl *D, Optional<BracketOptions> Bracket) {}
151+
virtual void printDeclPost(const Decl *D,
152+
llvm::Optional<BracketOptions> Bracket) {}
151153

152154
/// Called before printing the result type of the declaration. Printer can
153155
/// replace \p TL to customize the input.
@@ -174,15 +176,15 @@ class ASTPrinter {
174176
virtual void printModuleRef(ModuleEntity Mod, Identifier Name);
175177

176178
/// Called before printing a synthesized extension.
177-
virtual void printSynthesizedExtensionPre(const ExtensionDecl *ED,
178-
TypeOrExtensionDecl NTD,
179-
Optional<BracketOptions> Bracket) {}
179+
virtual void
180+
printSynthesizedExtensionPre(const ExtensionDecl *ED, TypeOrExtensionDecl NTD,
181+
llvm::Optional<BracketOptions> Bracket) {}
180182

181183
/// Called after printing a synthesized extension.
182-
virtual void printSynthesizedExtensionPost(const ExtensionDecl *ED,
183-
TypeOrExtensionDecl TargetDecl,
184-
Optional<BracketOptions> Bracket) {
185-
}
184+
virtual void
185+
printSynthesizedExtensionPost(const ExtensionDecl *ED,
186+
TypeOrExtensionDecl TargetDecl,
187+
llvm::Optional<BracketOptions> Bracket) {}
186188

187189
/// Called before printing a structured entity.
188190
///
@@ -304,10 +306,11 @@ class ASTPrinter {
304306
// MARK: Callback interface wrappers that perform ASTPrinter bookkeeping.
305307

306308
/// Make a callback to printDeclPre(), performing any necessary bookkeeping.
307-
void callPrintDeclPre(const Decl *D, Optional<BracketOptions> Bracket);
309+
void callPrintDeclPre(const Decl *D, llvm::Optional<BracketOptions> Bracket);
308310

309311
/// Make a callback to printDeclPost(), performing any necessary bookkeeping.
310-
void callPrintDeclPost(const Decl *D, Optional<BracketOptions> Bracket) {
312+
void callPrintDeclPost(const Decl *D,
313+
llvm::Optional<BracketOptions> Bracket) {
311314
printDeclPost(D, Bracket);
312315
}
313316

include/swift/AST/ASTScope.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "swift/Basic/LLVM.h"
3737
#include "swift/Basic/NullablePtr.h"
3838
#include "swift/Basic/SourceManager.h"
39+
#include "llvm/ADT/Optional.h"
3940
#include "llvm/ADT/PointerIntPair.h"
4041
#include "llvm/ADT/STLExtras.h"
4142
#include "llvm/ADT/SmallVector.h"
@@ -152,7 +153,7 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
152153
/// Child scopes, sorted by source range.
153154
Children storedChildren;
154155

155-
mutable Optional<CharSourceRange> cachedCharSourceRange;
156+
mutable llvm::Optional<CharSourceRange> cachedCharSourceRange;
156157

157158
#pragma mark - constructor / destructor
158159
public:
@@ -922,11 +923,11 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
922923

923924
class PatternEntryDeclScope final : public AbstractPatternEntryScope {
924925
const bool isLocalBinding;
925-
Optional<SourceLoc> endLoc;
926+
llvm::Optional<SourceLoc> endLoc;
926927

927928
public:
928929
PatternEntryDeclScope(PatternBindingDecl *pbDecl, unsigned entryIndex,
929-
bool isLocalBinding, Optional<SourceLoc> endLoc)
930+
bool isLocalBinding, llvm::Optional<SourceLoc> endLoc)
930931
: AbstractPatternEntryScope(pbDecl, entryIndex),
931932
isLocalBinding(isLocalBinding), endLoc(endLoc) {}
932933
virtual ~PatternEntryDeclScope() {}

include/swift/AST/ASTTypeIDZone.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ SWIFT_TYPEID_NAMED(NamedPattern *, NamedPattern)
6262
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
6363
SWIFT_TYPEID_NAMED(OpaqueTypeDecl *, OpaqueTypeDecl)
6464
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
65-
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperLValueness>,
65+
SWIFT_TYPEID_NAMED(llvm::Optional<PropertyWrapperLValueness>,
6666
PropertyWrapperLValueness)
67-
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
67+
SWIFT_TYPEID_NAMED(llvm::Optional<PropertyWrapperMutability>,
6868
PropertyWrapperMutability)
6969
SWIFT_TYPEID_NAMED(ParamDecl *, ParamDecl)
7070
SWIFT_TYPEID_NAMED(PatternBindingEntry *, PatternBindingEntry)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "swift/Basic/LLVM.h"
2121
#include "swift/Basic/TypeID.h"
22+
#include "llvm/ADT/Optional.h"
2223

2324
namespace swift {
2425

0 commit comments

Comments
 (0)