Don't use Optional::hasValue (NFC)
This patch replaces x.hasValue() with x where x is contextually convertible to bool.
This commit is contained in:
parent
586fb81eee
commit
94460f5136
|
@ -817,7 +817,7 @@ void NotNullTerminatedResultCheck::check(
|
|||
++It;
|
||||
}
|
||||
|
||||
if (AreSafeFunctionsWanted.hasValue())
|
||||
if (AreSafeFunctionsWanted)
|
||||
UseSafeFunctions = AreSafeFunctionsWanted.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ void ClangdLSPServer::onDocumentDidOpen(
|
|||
void ClangdLSPServer::onDocumentDidChange(
|
||||
const DidChangeTextDocumentParams &Params) {
|
||||
auto WantDiags = WantDiagnostics::Auto;
|
||||
if (Params.wantDiagnostics.hasValue())
|
||||
if (Params.wantDiagnostics)
|
||||
WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
|
||||
: WantDiagnostics::No;
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
|
|||
clang::clangd::trace::Span Tracer("Completion results callback");
|
||||
CB(std::move(Result));
|
||||
}
|
||||
if (SpecFuzzyFind && SpecFuzzyFind->NewReq.hasValue()) {
|
||||
if (SpecFuzzyFind && SpecFuzzyFind->NewReq) {
|
||||
std::lock_guard<std::mutex> Lock(CachedCompletionFuzzyFindRequestMutex);
|
||||
CachedCompletionFuzzyFindRequestByFile[File] =
|
||||
SpecFuzzyFind->NewReq.getValue();
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace clang {
|
|||
namespace clangd {
|
||||
|
||||
void FeatureModule::initialize(const Facilities &F) {
|
||||
assert(!Fac.hasValue() && "Initialized twice");
|
||||
assert(!Fac && "Initialized twice");
|
||||
Fac.emplace(F);
|
||||
}
|
||||
|
||||
FeatureModule::Facilities &FeatureModule::facilities() {
|
||||
assert(Fac.hasValue() && "Not initialized yet");
|
||||
assert(Fac && "Not initialized yet");
|
||||
return *Fac;
|
||||
}
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
|
|||
}
|
||||
|
||||
MATCHER_P(hasArg, Flag, "") {
|
||||
if (!arg.hasValue()) {
|
||||
if (!arg) {
|
||||
*result_listener << "command is null";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -375,11 +375,11 @@ private:
|
|||
for (auto &A : Params.Table.getActions(Head->State, Lookahead)) {
|
||||
if (A.kind() != LRTable::Action::Reduce)
|
||||
continue;
|
||||
if (RID.hasValue())
|
||||
if (RID)
|
||||
return false;
|
||||
RID = A.getReduceRule();
|
||||
}
|
||||
if (!RID.hasValue())
|
||||
if (!RID)
|
||||
return true; // no reductions available, but we've processed the head!
|
||||
const auto &Rule = Params.G.lookupRule(*RID);
|
||||
const GSS::Node *Base = Head;
|
||||
|
|
|
@ -96,7 +96,7 @@ void CheckBaseInfo(Info *Expected, Info *Actual) {
|
|||
void CheckSymbolInfo(SymbolInfo *Expected, SymbolInfo *Actual) {
|
||||
CheckBaseInfo(Expected, Actual);
|
||||
EXPECT_EQ(Expected->DefLoc.hasValue(), Actual->DefLoc.hasValue());
|
||||
if (Expected->DefLoc.hasValue() && Actual->DefLoc.hasValue()) {
|
||||
if (Expected->DefLoc && Actual->DefLoc.hasValue()) {
|
||||
EXPECT_EQ(Expected->DefLoc->LineNumber, Actual->DefLoc->LineNumber);
|
||||
EXPECT_EQ(Expected->DefLoc->Filename, Actual->DefLoc->Filename);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
assert(Call != nullptr && "Did not find node \"foo\"");
|
||||
auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar",
|
||||
{"b", "some_alias"});
|
||||
if (Hint.hasValue())
|
||||
if (Hint)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
|
||||
diag(Call->getBeginLoc(), "insert call") << FixItHint::CreateInsertion(
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
auto Hint =
|
||||
Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");
|
||||
|
||||
if (Hint.hasValue())
|
||||
if (Hint)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
|
||||
diag(Call->getBeginLoc(), "insert call")
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
void setSwiftPrivate(llvm::Optional<bool> Private) {
|
||||
SwiftPrivateSpecified = Private.hasValue();
|
||||
SwiftPrivate = Private.hasValue() ? *Private : 0;
|
||||
SwiftPrivate = Private ? *Private : 0;
|
||||
}
|
||||
|
||||
friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);
|
||||
|
|
|
@ -24514,9 +24514,8 @@ bool DAGCombiner::mayAlias(SDNode *Op0, SDNode *Op1) const {
|
|||
auto &Size0 = MUC0.NumBytes;
|
||||
auto &Size1 = MUC1.NumBytes;
|
||||
if (OrigAlignment0 == OrigAlignment1 && SrcValOffset0 != SrcValOffset1 &&
|
||||
Size0.hasValue() && Size1.hasValue() && *Size0 == *Size1 &&
|
||||
OrigAlignment0 > *Size0 && SrcValOffset0 % *Size0 == 0 &&
|
||||
SrcValOffset1 % *Size1 == 0) {
|
||||
Size0 && Size1 && *Size0 == *Size1 && OrigAlignment0 > *Size0 &&
|
||||
SrcValOffset0 % *Size0 == 0 && SrcValOffset1 % *Size1 == 0) {
|
||||
int64_t OffAlign0 = SrcValOffset0 % OrigAlignment0.value();
|
||||
int64_t OffAlign1 = SrcValOffset1 % OrigAlignment1.value();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static TransformationMode hasUnrollTransformation(MDNode *LoopID) {
|
|||
|
||||
Optional<int> Count =
|
||||
getOptionalIntLoopAttribute(LoopID, "llvm.loop.unroll.count");
|
||||
if (Count.hasValue())
|
||||
if (Count)
|
||||
return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
|
||||
|
||||
if (getBooleanLoopAttribute(LoopID, "llvm.loop.unroll.enable"))
|
||||
|
|
|
@ -570,19 +570,19 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) {
|
|||
auto L1DCache = llvm::TargetTransformInfo::CacheLevel::L1D;
|
||||
auto L2DCache = llvm::TargetTransformInfo::CacheLevel::L2D;
|
||||
if (FirstCacheLevelSize == -1) {
|
||||
if (TTI->getCacheSize(L1DCache).hasValue())
|
||||
if (TTI->getCacheSize(L1DCache))
|
||||
FirstCacheLevelSize = TTI->getCacheSize(L1DCache).getValue();
|
||||
else
|
||||
FirstCacheLevelSize = static_cast<int>(FirstCacheLevelDefaultSize);
|
||||
}
|
||||
if (SecondCacheLevelSize == -1) {
|
||||
if (TTI->getCacheSize(L2DCache).hasValue())
|
||||
if (TTI->getCacheSize(L2DCache))
|
||||
SecondCacheLevelSize = TTI->getCacheSize(L2DCache).getValue();
|
||||
else
|
||||
SecondCacheLevelSize = static_cast<int>(SecondCacheLevelDefaultSize);
|
||||
}
|
||||
if (FirstCacheLevelAssociativity == -1) {
|
||||
if (TTI->getCacheAssociativity(L1DCache).hasValue())
|
||||
if (TTI->getCacheAssociativity(L1DCache))
|
||||
FirstCacheLevelAssociativity =
|
||||
TTI->getCacheAssociativity(L1DCache).getValue();
|
||||
else
|
||||
|
@ -590,7 +590,7 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) {
|
|||
static_cast<int>(FirstCacheLevelDefaultAssociativity);
|
||||
}
|
||||
if (SecondCacheLevelAssociativity == -1) {
|
||||
if (TTI->getCacheAssociativity(L2DCache).hasValue())
|
||||
if (TTI->getCacheAssociativity(L2DCache))
|
||||
SecondCacheLevelAssociativity =
|
||||
TTI->getCacheAssociativity(L2DCache).getValue();
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue