Skip to content

Commit 8b78963

Browse files
authored
Merge pull request #67209 from etcwilde/ewilde/5.9/llvm-all-the-things
🍒[NFC][5.9] add `llvm` namespace to `Optional` and `None`
2 parents 869c5bf + 71fff66 commit 8b78963

File tree

678 files changed

+8287
-8178
lines changed

Some content is hidden

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

678 files changed

+8287
-8178
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
@@ -167,7 +167,7 @@ enum class KnownFoundationEntity {
167167

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

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

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

342342
/// A cache of derivative function types per configuration.
343343
llvm::DenseMap<SILAutoDiffDerivativeFunctionKey, CanSILFunctionType>
@@ -797,9 +797,9 @@ class ASTContext final {
797797
///
798798
/// SIL analog of \c ASTContext::getClangFunctionType .
799799
const clang::Type *
800-
getCanonicalClangFunctionType(
801-
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
802-
SILFunctionType::Representation trueRep);
800+
getCanonicalClangFunctionType(ArrayRef<SILParameterInfo> params,
801+
llvm::Optional<SILResultInfo> result,
802+
SILFunctionType::Representation trueRep);
803803

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

10211021
/// Retrieve the module dependencies for the module with the given name.
10221022
///
1023-
Optional<const ModuleDependencyInfo*> getModuleDependencies(
1024-
StringRef moduleName,
1025-
ModuleDependenciesCache &cache,
1023+
llvm::Optional<const ModuleDependencyInfo *> getModuleDependencies(
1024+
StringRef moduleName, ModuleDependenciesCache &cache,
10261025
InterfaceSubContextDelegate &delegate,
1027-
bool optionalDependencyLookup = false,
1028-
bool isTestableImport = false,
1029-
llvm::Optional<std::pair<std::string, swift::ModuleDependencyKind>> dependencyOf = None);
1026+
bool optionalDependencyLookup = false, bool isTestableImport = false,
1027+
llvm::Optional<std::pair<std::string, swift::ModuleDependencyKind>>
1028+
dependencyOf = llvm::None);
10301029

10311030
/// Retrieve the module dependencies for the Clang module with the given name.
1032-
Optional<const ModuleDependencyInfo*> getClangModuleDependencies(
1033-
StringRef moduleName,
1034-
ModuleDependenciesCache &cache,
1035-
InterfaceSubContextDelegate &delegate);
1031+
llvm::Optional<const ModuleDependencyInfo *>
1032+
getClangModuleDependencies(StringRef moduleName,
1033+
ModuleDependenciesCache &cache,
1034+
InterfaceSubContextDelegate &delegate);
10361035

10371036
/// Retrieve the module dependencies for the Swift module with the given name.
1038-
Optional<const ModuleDependencyInfo*> getSwiftModuleDependencies(
1039-
StringRef moduleName,
1040-
ModuleDependenciesCache &cache,
1041-
InterfaceSubContextDelegate &delegate);
1037+
llvm::Optional<const ModuleDependencyInfo *>
1038+
getSwiftModuleDependencies(StringRef moduleName,
1039+
ModuleDependenciesCache &cache,
1040+
InterfaceSubContextDelegate &delegate);
10421041

10431042
/// Compute the extra implicit framework search paths on Apple platforms:
10441043
/// $SDKROOT/System/Library/Frameworks/ and $SDKROOT/Library/Frameworks/.
@@ -1496,7 +1495,7 @@ class ASTContext final {
14961495
private:
14971496
friend Decl;
14981497

1499-
Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
1498+
llvm::Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
15001499
void setExternalSourceLocs(const Decl *D, ExternalSourceLocs *Locs);
15011500

15021501
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

@@ -137,11 +138,11 @@ class ASTBuilder {
137138
FunctionMetadataDifferentiabilityKind diffKind, Type globalActor);
138139

139140
Type createImplFunctionType(
140-
Demangle::ImplParameterConvention calleeConvention,
141-
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
142-
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
143-
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
144-
ImplFunctionTypeFlags flags);
141+
Demangle::ImplParameterConvention calleeConvention,
142+
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
143+
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
144+
llvm::Optional<Demangle::ImplFunctionResult<Type>> errorResult,
145+
ImplFunctionTypeFlags flags);
145146

146147
Type createProtocolCompositionType(ArrayRef<ProtocolDecl *> protocols,
147148
Type superclass,
@@ -156,11 +157,13 @@ class ASTBuilder {
156157
Type createSymbolicExtendedExistentialType(NodePointer shapeNode,
157158
ArrayRef<Type> genArgs);
158159

159-
Type createExistentialMetatypeType(Type instance,
160-
Optional<Demangle::ImplMetatypeRepresentation> repr=None);
160+
Type createExistentialMetatypeType(
161+
Type instance,
162+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = llvm::None);
161163

162-
Type createMetatypeType(Type instance,
163-
Optional<Demangle::ImplMetatypeRepresentation> repr=None);
164+
Type createMetatypeType(
165+
Type instance,
166+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = llvm::None);
164167

165168
Type createGenericTypeParameterType(unsigned depth, unsigned index);
166169

@@ -236,8 +239,7 @@ class ASTBuilder {
236239
SynthesizedByImporter
237240
};
238241

239-
Optional<ForeignModuleKind>
240-
getForeignModuleKind(NodePointer node);
242+
llvm::Optional<ForeignModuleKind> getForeignModuleKind(NodePointer node);
241243

242244
GenericTypeDecl *findTypeDecl(DeclContext *dc,
243245
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)