Skip to content

Fix warnings in main and rebranch #62217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions include/swift/APIDigester/ModuleAnalyzerNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class SDKContext {
DiagnosticEngine &getDiags(SourceLoc Loc = SourceLoc());
void addDiagConsumer(DiagnosticConsumer &Consumer);
void setCommonVersion(uint8_t Ver) {
assert(!CommonVersion.hasValue());
assert(!CommonVersion.has_value());
CommonVersion = Ver;
}
uint8_t getCommonVersion() const {
Expand Down Expand Up @@ -401,7 +401,7 @@ class SDKNodeDecl: public SDKNode {
StringRef getGenericSignature() const { return GenericSig; }
StringRef getSugaredGenericSignature() const { return SugaredGenericSig; }
StringRef getScreenInfo() const;
bool hasFixedBinaryOrder() const { return FixedBinaryOrder.hasValue(); }
bool hasFixedBinaryOrder() const { return FixedBinaryOrder.has_value(); }
uint8_t getFixedBinaryOrder() const { return *FixedBinaryOrder; }
PlatformIntroVersion getIntroducingVersion() const { return introVersions; }
StringRef getObjCName() const { return ObjCName; }
Expand Down Expand Up @@ -685,9 +685,9 @@ class SDKNodeDeclAbstractFunc : public SDKNodeDecl {
public:
bool isThrowing() const { return IsThrowing; }
bool reqNewWitnessTableEntry() const { return ReqNewWitnessTableEntry; }
uint8_t getSelfIndex() const { return SelfIndex.getValue(); }
uint8_t getSelfIndex() const { return SelfIndex.value(); }
Optional<uint8_t> getSelfIndexOptional() const { return SelfIndex; }
bool hasSelfIndex() const { return SelfIndex.hasValue(); }
bool hasSelfIndex() const { return SelfIndex.has_value(); }
static bool classof(const SDKNode *N);
virtual void jsonize(json::Output &out) override;
static StringRef getTypeRoleDescription(SDKContext &Ctx, unsigned Index);
Expand Down
10 changes: 5 additions & 5 deletions include/swift/AST/ArgumentList.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class alignas(Argument) ArgumentList final
assert(!firstTrailingClosureIndex || *firstTrailingClosureIndex < numArgs &&
"Invalid trailing closure index");
RawFirstTrailingClosureIndex =
firstTrailingClosureIndex.getValueOr(numArgs);
firstTrailingClosureIndex.value_or(numArgs);
}

ArgumentList(const ArgumentList &) = delete;
Expand Down Expand Up @@ -400,7 +400,7 @@ class alignas(Argument) ArgumentList final

/// Whether any unlabeled or labeled trailing closures are present.
bool hasAnyTrailingClosures() const {
return getOriginalArgs()->getFirstTrailingClosureIndex().hasValue();
return getOriginalArgs()->getFirstTrailingClosureIndex().has_value();
}

/// Whether a given index is for an unlabeled trailing closure, which is the
Expand Down Expand Up @@ -443,7 +443,7 @@ class alignas(Argument) ArgumentList final
iterator_range<iterator> getNonTrailingArgs() const {
assert(!HasOriginalArgs && "Query original args instead");
auto idx = getFirstTrailingClosureIndex();
if (!idx.hasValue())
if (!idx.has_value())
return *this;

return {begin(), iterator(this, *idx)};
Expand All @@ -456,7 +456,7 @@ class alignas(Argument) ArgumentList final
iterator_range<iterator> getTrailingClosures() const {
assert(!HasOriginalArgs && "Query original args instead");
auto idx = getFirstTrailingClosureIndex();
if (!idx.hasValue())
if (!idx.has_value())
return {end(), end()};

return {iterator(this, *idx), end()};
Expand All @@ -470,7 +470,7 @@ class alignas(Argument) ArgumentList final
Optional<Argument> getFirstTrailingClosure() const {
assert(!HasOriginalArgs && "Query original args instead");
auto idx = getFirstTrailingClosureIndex();
if (!idx.hasValue())
if (!idx.has_value())
return None;
return get(*idx);
}
Expand Down
8 changes: 4 additions & 4 deletions include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2634,13 +2634,13 @@ class TypeAttributes {
return true;
}

bool hasConvention() const { return ConventionArguments.hasValue(); }
bool hasConvention() const { return ConventionArguments.has_value(); }

/// Returns the primary calling convention string.
///
/// Note: For C conventions, this may not represent the full convention.
StringRef getConventionName() const {
return ConventionArguments.getValue().Name;
return ConventionArguments.value().Name;
}

/// Show the string enclosed between @convention(..)'s parentheses.
Expand All @@ -2664,10 +2664,10 @@ class TypeAttributes {
#include "swift/AST/ReferenceStorage.def"
}

bool hasOpenedID() const { return OpenedID.hasValue(); }
bool hasOpenedID() const { return OpenedID.has_value(); }
UUID getOpenedID() const { return *OpenedID; }

bool hasConstraintType() const { return ConstraintType.hasValue(); }
bool hasConstraintType() const { return ConstraintType.has_value(); }
TypeRepr *getConstraintType() const { return *ConstraintType; }

/// Given a name like "autoclosure", return the type attribute ID that
Expand Down
14 changes: 7 additions & 7 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3002,18 +3002,18 @@ class OpaqueTypeDecl final :
}

void setUniqueUnderlyingTypeSubstitutions(SubstitutionMap subs) {
assert(!UniqueUnderlyingType.hasValue() && "resetting underlying type?!");
assert(!UniqueUnderlyingType.has_value() && "resetting underlying type?!");
UniqueUnderlyingType = subs;
}

bool hasConditionallyAvailableSubstitutions() const {
return ConditionallyAvailableTypes.hasValue();
return ConditionallyAvailableTypes.has_value();
}

ArrayRef<ConditionallyAvailableSubstitutions *>
getConditionallyAvailableSubstitutions() const {
assert(ConditionallyAvailableTypes);
return ConditionallyAvailableTypes.getValue();
return ConditionallyAvailableTypes.value();
}

void setConditionallyAvailableSubstitutions(
Expand Down Expand Up @@ -4891,7 +4891,7 @@ class ProtocolDecl final : public NominalTypeDecl {

/// Has the requirement signature been computed yet?
bool isRequirementSignatureComputed() const {
return RequirementSig.hasValue();
return RequirementSig.has_value();
}

void setRequirementSignature(RequirementSignature requirementSig);
Expand Down Expand Up @@ -6451,8 +6451,8 @@ class BodyAndFingerprint {

public:
BodyAndFingerprint(BraceStmt *body, Optional<Fingerprint> fp)
: BodyAndHasFp(body, fp.hasValue()),
Fp(fp.hasValue() ? *fp : Fingerprint::ZERO()) {}
: BodyAndHasFp(body, fp.has_value()),
Fp(fp.has_value() ? *fp : Fingerprint::ZERO()) {}
BodyAndFingerprint() : BodyAndFingerprint(nullptr, None) {}

BraceStmt *getBody() const { return BodyAndHasFp.getPointer(); }
Expand All @@ -6465,7 +6465,7 @@ class BodyAndFingerprint {
}

void setFingerprint(Optional<Fingerprint> fp) {
if (fp.hasValue()) {
if (fp.has_value()) {
Fp = *fp;
BodyAndHasFp.setInt(true);
} else {
Expand Down
6 changes: 3 additions & 3 deletions include/swift/AST/FineGrainedDependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ template <typename KeyT, typename ValueT> class Memoizer {
findExistingOrCreateIfNew(KeyT key,
function_ref<ValueT(const KeyT &)> createFn) {
if (auto existing = findExisting(key))
return existing.getValue();
return existing.value();
ValueT v = createFn(key);
(void)insert(key, v);
return v;
Expand Down Expand Up @@ -324,10 +324,10 @@ class BiIndexedTwoStageMap {
unsigned index)>
verifyFn) const {
map1.verify([&](const Key1 &k1, const Key2 &k2, Value v) {
assertConsistent(map2.find(k2, k1).getValue(), v);
assertConsistent(map2.find(k2, k1).value(), v);
});
map2.verify([&](const Key2 &k2, const Key1 &k1, Value v) {
assertConsistent(map1.find(k1, k2).getValue(), v);
assertConsistent(map1.find(k1, k2).value(), v);
});
map1.verify([&](const Key1 &k1, const Key2 &k2, Value v) {
verifyFn(k1, k2, v, 0);
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/ModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ModuleLoader {

public:
/// Returns true if the version has a valid source kind.
bool isValid() const { return SourceKind.hasValue(); }
bool isValid() const { return SourceKind.has_value(); }

/// Returns the version, which may be empty if a version was not present or
/// was unparsable.
Expand All @@ -223,7 +223,7 @@ class ModuleLoader {
/// Returns the kind of source of the module version. Do not call if
/// \c isValid() returns false.
ModuleVersionSourceKind getSourceKind() const {
return SourceKind.getValue();
return SourceKind.value();
}

void setVersion(llvm::VersionTuple version, ModuleVersionSourceKind kind) {
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class SourceFile final : public FileUnit {
~SourceFile();

bool hasImports() const {
return Imports.hasValue();
return Imports.has_value();
}

/// Retrieve an immutable view of the source file's imports.
Expand Down
6 changes: 3 additions & 3 deletions include/swift/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class alignas(8) Stmt : public ASTAllocated<Stmt> {
/// Return the given value for the 'implicit' flag if present, or if None,
/// return true if the location is invalid.
static bool getDefaultImplicitFlag(Optional<bool> implicit, SourceLoc keyLoc){
return implicit.hasValue() ? *implicit : keyLoc.isInvalid();
return implicit.has_value() ? *implicit : keyLoc.isInvalid();
}

public:
Expand Down Expand Up @@ -1093,7 +1093,7 @@ class CaseStmt final
void setBody(BraceStmt *body) { BodyAndHasFallthrough.setPointer(body); }

/// True if the case block declares any patterns with local variable bindings.
bool hasBoundDecls() const { return CaseBodyVariables.hasValue(); }
bool hasBoundDecls() const { return CaseBodyVariables.has_value(); }

/// Get the source location of the 'case', 'default', or 'catch' of the first
/// label.
Expand Down Expand Up @@ -1152,7 +1152,7 @@ class CaseStmt final
return a;
}

bool hasCaseBodyVariables() const { return CaseBodyVariables.hasValue(); }
bool hasCaseBodyVariables() const { return CaseBodyVariables.has_value(); }

/// Return an MutableArrayRef containing the case body variables of this
/// CaseStmt.
Expand Down
14 changes: 7 additions & 7 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3107,15 +3107,15 @@ class AnyFunctionType : public TypeBase {
RecursiveTypeProperties properties, unsigned NumParams,
Optional<ExtInfo> Info)
: TypeBase(Kind, CanTypeContext, properties), Output(Output) {
if (Info.hasValue()) {
if (Info.has_value()) {
Bits.AnyFunctionType.HasExtInfo = true;
Bits.AnyFunctionType.ExtInfoBits = Info.getValue().getBits();
Bits.AnyFunctionType.ExtInfoBits = Info.value().getBits();
Bits.AnyFunctionType.HasClangTypeInfo =
!Info.getValue().getClangTypeInfo().empty();
!Info.value().getClangTypeInfo().empty();
Bits.AnyFunctionType.HasGlobalActor =
!Info.getValue().getGlobalActor().isNull();
!Info.value().getGlobalActor().isNull();
// The use of both assert() and static_assert() is intentional.
assert(Bits.AnyFunctionType.ExtInfoBits == Info.getValue().getBits() &&
assert(Bits.AnyFunctionType.ExtInfoBits == Info.value().getBits() &&
"Bits were dropped!");
static_assert(
ASTExtInfoBuilder::NumMaskBits == NumAFTExtInfoBits,
Expand Down Expand Up @@ -4929,8 +4929,8 @@ class SILFunctionType final
kind == innerty::ABIEscapeToNoEscapeConversion;
}

bool hasPayload() const { return payload.hasValue(); }
uintptr_t getPayload() const { return payload.getValue(); }
bool hasPayload() const { return payload.has_value(); }
uintptr_t getPayload() const { return payload.value(); }
StringRef getMessage() const;
};

Expand Down
4 changes: 2 additions & 2 deletions include/swift/Basic/BlotMapVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BlotMapVector {
Vector.push_back({std::make_pair(Arg, ValueT())});
return (*Vector[Num]).second;
}
return Vector[Pair.first->second].getValue().second;
return Vector[Pair.first->second].value().second;
}

template <typename... Ts>
Expand Down Expand Up @@ -107,7 +107,7 @@ class BlotMapVector {
if (It == Map.end())
return Vector.end();
auto Iter = Vector.begin() + It->second;
if (!Iter->hasValue())
if (!Iter->has_value())
return Vector.end();
return Iter;
}
Expand Down
Loading