[clang] 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:
Kazu Hirata 2022-06-26 18:51:54 -07:00
parent d08f34b592
commit ca05cc2064
6 changed files with 12 additions and 18 deletions

View File

@ -53,14 +53,10 @@ public:
}
/// Return true if the constraint is perfectly constrained to 'true'.
bool isConstrainedTrue() const {
return Val.hasValue() && Val.getValue();
}
bool isConstrainedTrue() const { return Val && Val.getValue(); }
/// Return true if the constraint is perfectly constrained to 'false'.
bool isConstrainedFalse() const {
return Val.hasValue() && !Val.getValue();
}
bool isConstrainedFalse() const { return Val && !Val.getValue(); }
/// Return true if the constrained is perfectly constrained.
bool isConstrained() const {

View File

@ -209,8 +209,8 @@ public:
}
bool isValid() const { return Valid; }
bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
bool isScalar() const { return Scale && Scale.getValue() == 0; }
bool isVector() const { return Scale && Scale.getValue() != 0; }
bool isVector(unsigned Width) const {
return isVector() && ElementBitwidth == Width;
}

View File

@ -3325,8 +3325,8 @@ class OffloadingActionBuilder final {
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
AssociatedOffloadKind);
if (CompileDeviceOnly && CurPhase == FinalPhase &&
BundleOutput.hasValue() && BundleOutput.getValue()) {
if (CompileDeviceOnly && CurPhase == FinalPhase && BundleOutput &&
BundleOutput.getValue()) {
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
OffloadAction::DeviceDependences DDep;
DDep.add(*CudaDeviceActions[I], *ToolChains.front(), GpuArchList[I],

View File

@ -213,8 +213,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
isPublic = VisMD->isPublic();
}
return DefInfo(nullptr, UndefLoc,
!isPublic.hasValue() || isPublic.getValue());
return DefInfo(nullptr, UndefLoc, !isPublic || isPublic.getValue());
}
const MacroDirective::DefInfo

View File

@ -2313,9 +2313,9 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
Sema::DeclareTargetContextInfo DTCI(DKind, DTLoc);
if (HasClauses)
ParseOMPDeclareTargetClauses(DTCI);
bool HasImplicitMappings =
DKind == OMPD_begin_declare_target || !HasClauses ||
(DTCI.ExplicitlyMapped.empty() && DTCI.Indirect.hasValue());
bool HasImplicitMappings = DKind == OMPD_begin_declare_target ||
!HasClauses ||
(DTCI.ExplicitlyMapped.empty() && DTCI.Indirect);
// Skip the last annot_pragma_openmp_end.
ConsumeAnyToken();

View File

@ -40,9 +40,8 @@ isAnnotationDirectlyAfterStatement(const Stmt *Stmt, unsigned AnnotationBegin,
auto NextToken =
Lexer::findNextToken(Stmt->getEndLoc(), SourceManager, LangOptions);
while (NextToken.hasValue() &&
SourceManager.getFileOffset(NextToken->getLocation()) <
AnnotationBegin) {
while (NextToken && SourceManager.getFileOffset(NextToken->getLocation()) <
AnnotationBegin) {
if (NextToken->isNot(tok::semi))
return false;