Skip to content

Commit 5413bf1

Browse files
Don't use Optional::hasValue (NFC)
1 parent 037f099 commit 5413bf1

File tree

72 files changed

+99
-99
lines changed

Some content is hidden

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

72 files changed

+99
-99
lines changed

clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) {
5353
}
5454

5555
void ClangTidyProfiling::storeProfileData() {
56-
assert(Storage.hasValue() && "We should have a filename.");
56+
assert(Storage && "We should have a filename.");
5757

5858
llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
5959
llvm::sys::path::remove_filename(OutputDirectory);
@@ -80,7 +80,7 @@ ClangTidyProfiling::ClangTidyProfiling(llvm::Optional<StorageParams> Storage)
8080
ClangTidyProfiling::~ClangTidyProfiling() {
8181
TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
8282

83-
if (!Storage.hasValue())
83+
if (!Storage)
8484
printUserFriendlyTable(llvm::errs());
8585
else
8686
storeProfileData();

clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ class PassedToSameFunction {
16831683
if (CalledFn->getParamDecl(Idx) == PassedToParam)
16841684
TargetIdx.emplace(Idx);
16851685

1686-
assert(TargetIdx.hasValue() && "Matched, but didn't find index?");
1686+
assert(TargetIdx && "Matched, but didn't find index?");
16871687
TargetParams[PassedParamOfThisFn].insert(
16881688
{CalledFn->getCanonicalDecl(), *TargetIdx});
16891689
}

clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void SuspiciousMemoryComparisonCheck::check(
6767

6868
if (!PointeeType->isIncompleteType()) {
6969
uint64_t PointeeSize = Ctx.getTypeSize(PointeeType);
70-
if (ComparedBits.hasValue() && *ComparedBits >= PointeeSize &&
70+
if (ComparedBits && *ComparedBits >= PointeeSize &&
7171
!Ctx.hasUniqueObjectRepresentations(PointeeQualifiedType)) {
7272
diag(CE->getBeginLoc(),
7373
"comparing object representation of type %0 which does not have a "

clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) {
6565
// `runDataflowAnalysis` doesn't guarantee that the exit block is visited;
6666
// for example, when it is unreachable.
6767
// FIXME: Diagnose violations even when the exit block is unreachable.
68-
if (!ExitBlockState.hasValue())
68+
if (!ExitBlockState)
6969
return llvm::None;
7070

7171
return std::move(ExitBlockState->Lattice);

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ IdentifierNamingCheck::FileStyle IdentifierNamingCheck::getFileStyleFromOptions(
258258

259259
auto HPTOpt =
260260
Options.get<IdentifierNamingCheck::HungarianPrefixType>(StyleString);
261-
if (HPTOpt.hasValue() && !HungarianNotation.checkOptionValid(I))
261+
if (HPTOpt && !HungarianNotation.checkOptionValid(I))
262262
configurationDiag("invalid identifier naming option '%0'") << StyleString;
263263

264264
memcpy(&StyleString[StyleSize], "IgnoredRegexp", 13);

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
493493

494494
Opts.CodeComplete.EnableSnippets = Params.capabilities.CompletionSnippets;
495495
Opts.CodeComplete.IncludeFixIts = Params.capabilities.CompletionFixes;
496-
if (!Opts.CodeComplete.BundleOverloads.hasValue())
496+
if (!Opts.CodeComplete.BundleOverloads)
497497
Opts.CodeComplete.BundleOverloads = Params.capabilities.HasSignatureHelp;
498498
Opts.CodeComplete.DocumentationFormat =
499499
Params.capabilities.CompletionDocumentationFormat;

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
9797
if (FIndex)
9898
FIndex->updateMain(Path, AST);
9999

100-
assert(AST.getDiagnostics().hasValue() &&
100+
assert(AST.getDiagnostics() &&
101101
"We issue callback only with fresh preambles");
102102
std::vector<Diag> Diagnostics = *AST.getDiagnostics();
103103
if (ServerCallbacks)
@@ -672,7 +672,7 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
672672
}
673673
Effect = T.takeError();
674674
}
675-
assert(Effect.hasValue() && "Expected at least one selection");
675+
assert(Effect && "Expected at least one selection");
676676
if (*Effect && (*Effect)->FormatEdits) {
677677
// Format tweaks that require it centrally here.
678678
for (auto &It : (*Effect)->ApplyEdits) {

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
835835
continue;
836836
// Skip injected class name when no class scope is not explicitly set.
837837
// E.g. show injected A::A in `using A::A^` but not in "A^".
838-
if (Result.Declaration && !Context.getCXXScopeSpecifier().hasValue() &&
838+
if (Result.Declaration && !Context.getCXXScopeSpecifier() &&
839839
isInjectedClass(*Result.Declaration))
840840
continue;
841841
// We choose to never append '::' to completion results in clangd.
@@ -1439,7 +1439,7 @@ class CodeCompleteFlow {
14391439
HeuristicPrefix = guessCompletionPrefix(SemaCCInput.ParseInput.Contents,
14401440
SemaCCInput.Offset);
14411441
populateContextWords(SemaCCInput.ParseInput.Contents);
1442-
if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq.hasValue()) {
1442+
if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq) {
14431443
assert(!SpecFuzzyFind->Result.valid());
14441444
SpecReq = speculativeFuzzyFindRequestForCompletion(
14451445
*SpecFuzzyFind->CachedReq, HeuristicPrefix);

clang-tools-extra/clangd/IncludeFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ IncludeFixer::unresolvedNameRecorder() {
544544
}
545545

546546
std::vector<Fix> IncludeFixer::fixUnresolvedName() const {
547-
assert(LastUnresolvedName.hasValue());
547+
assert(LastUnresolvedName);
548548
auto &Unresolved = *LastUnresolvedName;
549549
vlog("Trying to fix unresolved name \"{0}\" in scopes: [{1}]",
550550
Unresolved.Name, llvm::join(Unresolved.Scopes, ", "));

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop,
3434
assert(O);
3535
auto *V = O->get(Prop);
3636
// Field is missing or null.
37-
if (!V || V->getAsNull().hasValue())
37+
if (!V || V->getAsNull())
3838
return true;
3939
return fromJSON(*V, Out, P.field(Prop));
4040
}
@@ -608,7 +608,7 @@ llvm::json::Value toJSON(const Diagnostic &D) {
608608
Diag["codeActions"] = D.codeActions;
609609
if (!D.code.empty())
610610
Diag["code"] = D.code;
611-
if (D.codeDescription.hasValue())
611+
if (D.codeDescription)
612612
Diag["codeDescription"] = *D.codeDescription;
613613
if (!D.source.empty())
614614
Diag["source"] = D.source;
@@ -926,7 +926,7 @@ llvm::json::Value toJSON(const MarkupContent &MC) {
926926
llvm::json::Value toJSON(const Hover &H) {
927927
llvm::json::Object Result{{"contents", toJSON(H.contents)}};
928928

929-
if (H.range.hasValue())
929+
if (H.range)
930930
Result["range"] = toJSON(*H.range);
931931

932932
return std::move(Result);
@@ -1024,7 +1024,7 @@ llvm::json::Value toJSON(const CompletionList &L) {
10241024
}
10251025

10261026
llvm::json::Value toJSON(const ParameterInformation &PI) {
1027-
assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
1027+
assert((PI.labelOffsets || !PI.labelString.empty()) &&
10281028
"parameter information label is required");
10291029
llvm::json::Object Result;
10301030
if (PI.labelOffsets)

0 commit comments

Comments
 (0)