[clang, clang-tools-extra] Use has_value instead of hasValue (NFC)

This commit is contained in:
Kazu Hirata 2022-07-12 22:47:41 -07:00
parent 3361a364e6
commit 53daa177f8
29 changed files with 109 additions and 112 deletions

View File

@ -745,7 +745,7 @@ public:
if (Callee) {
handleCall(Callee, E->arguments());
}
return !Info.hasValue();
return !Info.has_value();
}
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@ -753,7 +753,7 @@ public:
if (Callee) {
handleCall(Callee, E->arguments());
}
return !Info.hasValue();
return !Info.has_value();
}
// The expanded parameter pack to be resolved

View File

@ -394,7 +394,7 @@ struct CodeCompletionBuilder {
std::stable_partition(Completion.Includes.begin(),
Completion.Includes.end(),
[](const CodeCompletion::IncludeCandidate &I) {
return !I.Insertion.hasValue();
return !I.Insertion.has_value();
});
}

View File

@ -358,8 +358,8 @@ struct FragmentCompiler {
}
#endif
// Make sure exactly one of the Sources is set.
unsigned SourceCount = External.File.hasValue() +
External.Server.hasValue() + *External.IsNone;
unsigned SourceCount = External.File.has_value() +
External.Server.has_value() + *External.IsNone;
if (SourceCount != 1) {
diag(Error, "Exactly one of File, Server or None must be set.",
BlockRange);

View File

@ -354,23 +354,23 @@ template <> struct MappingTraits<CompileCommandYAML> {
template <> struct MappingTraits<VariantEntry> {
static void mapping(IO &IO, VariantEntry &Variant) {
if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) {
if (IO.mapTag("!Symbol", Variant.Symbol.has_value())) {
if (!IO.outputting())
Variant.Symbol.emplace();
MappingTraits<Symbol>::mapping(IO, *Variant.Symbol);
} else if (IO.mapTag("!Refs", Variant.Refs.hasValue())) {
} else if (IO.mapTag("!Refs", Variant.Refs.has_value())) {
if (!IO.outputting())
Variant.Refs.emplace();
MappingTraits<RefBundle>::mapping(IO, *Variant.Refs);
} else if (IO.mapTag("!Relations", Variant.Relation.hasValue())) {
} else if (IO.mapTag("!Relations", Variant.Relation.has_value())) {
if (!IO.outputting())
Variant.Relation.emplace();
MappingTraits<Relation>::mapping(IO, *Variant.Relation);
} else if (IO.mapTag("!Source", Variant.Source.hasValue())) {
} else if (IO.mapTag("!Source", Variant.Source.has_value())) {
if (!IO.outputting())
Variant.Source.emplace();
MappingTraits<IncludeGraphNode>::mapping(IO, *Variant.Source);
} else if (IO.mapTag("!Cmd", Variant.Cmd.hasValue())) {
} else if (IO.mapTag("!Cmd", Variant.Cmd.has_value())) {
if (!IO.outputting())
Variant.Cmd.emplace();
MappingTraits<CompileCommandYAML>::mapping(

View File

@ -163,9 +163,9 @@ Index:
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
ASSERT_EQ(Results.size(), 1u);
ASSERT_TRUE(Results[0].Index.External);
EXPECT_FALSE(Results[0].Index.External.getValue()->File.hasValue());
EXPECT_FALSE(Results[0].Index.External.getValue()->MountPoint.hasValue());
EXPECT_FALSE(Results[0].Index.External.getValue()->Server.hasValue());
EXPECT_FALSE(Results[0].Index.External.getValue()->File.has_value());
EXPECT_FALSE(Results[0].Index.External.getValue()->MountPoint.has_value());
EXPECT_FALSE(Results[0].Index.External.getValue()->Server.has_value());
EXPECT_THAT(*Results[0].Index.External.getValue()->IsNone, testing::Eq(true));
}

View File

@ -28,10 +28,10 @@ TEST(FSTests, PreambleStatusCache) {
EXPECT_TRUE(ProduceFS->status("y"));
EXPECT_TRUE(ProduceFS->status("main"));
EXPECT_TRUE(StatCache.lookup(testPath("x")).hasValue());
EXPECT_TRUE(StatCache.lookup(testPath("y")).hasValue());
EXPECT_TRUE(StatCache.lookup(testPath("x")).has_value());
EXPECT_TRUE(StatCache.lookup(testPath("y")).has_value());
// Main file is not cached.
EXPECT_FALSE(StatCache.lookup(testPath("main")).hasValue());
EXPECT_FALSE(StatCache.lookup(testPath("main")).has_value());
llvm::vfs::Status S("fake", llvm::sys::fs::UniqueID(123, 456),
std::chrono::system_clock::now(), 0, 0, 1024,

View File

@ -331,7 +331,7 @@ TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
FS.Files[testPath("x/compile_flags.txt")] = "-DFOO";
DirectoryBasedGlobalCompilationDatabase CDB(FS);
auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
ASSERT_TRUE(Commands.hasValue());
ASSERT_TRUE(Commands.has_value());
EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
// Make sure we pick the right working directory.
EXPECT_EQ(testPath("x"), Commands.getValue().Directory);

View File

@ -33,11 +33,11 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
FS.Files[Invalid];
Optional<Path> PathResult =
getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None));
EXPECT_TRUE(PathResult.hasValue());
EXPECT_TRUE(PathResult.has_value());
ASSERT_EQ(PathResult.getValue(), FooH);
PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None));
EXPECT_TRUE(PathResult.hasValue());
EXPECT_TRUE(PathResult.has_value());
ASSERT_EQ(PathResult.getValue(), FooCpp);
// Test with header file in capital letters and different extension, source
@ -48,7 +48,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
FS.Files[FooC];
FS.Files[FooHH];
PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None));
EXPECT_TRUE(PathResult.hasValue());
EXPECT_TRUE(PathResult.has_value());
ASSERT_EQ(PathResult.getValue(), FooHH);
// Test with both capital letters
@ -57,7 +57,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
FS.Files[Foo2C];
FS.Files[Foo2HH];
PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None));
EXPECT_TRUE(PathResult.hasValue());
EXPECT_TRUE(PathResult.has_value());
ASSERT_EQ(PathResult.getValue(), Foo2HH);
// Test with source file as capital letter and .hxx header file
@ -67,13 +67,13 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
FS.Files[Foo3C];
FS.Files[Foo3HXX];
PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None));
EXPECT_TRUE(PathResult.hasValue());
EXPECT_TRUE(PathResult.has_value());
ASSERT_EQ(PathResult.getValue(), Foo3HXX);
// Test if asking for a corresponding file that doesn't exist returns an empty
// string.
PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None));
EXPECT_FALSE(PathResult.hasValue());
EXPECT_FALSE(PathResult.has_value());
}
MATCHER_P(declNamed, Name, "") {

View File

@ -93,10 +93,10 @@ TEST(LSPBinderTest, IncomingCalls) {
auto &RawPlusOne = RawHandlers.MethodHandlers["plusOne"];
RawPlusOne(1, capture(Reply));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
RawPlusOne("foo", capture(Reply));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(
Reply.getValue(),
llvm::FailedWithMessage(
@ -104,7 +104,7 @@ TEST(LSPBinderTest, IncomingCalls) {
auto &RawFail = RawHandlers.MethodHandlers["fail"];
RawFail(2, capture(Reply));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("X=2"));
auto &RawNotify = RawHandlers.NotificationHandlers["notify"];
@ -117,7 +117,7 @@ TEST(LSPBinderTest, IncomingCalls) {
auto &RawCmdPlusOne = RawHandlers.CommandHandlers["cmdPlusOne"];
RawCmdPlusOne(1, capture(Reply));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
// None of this generated any outgoing traffic.
@ -139,7 +139,7 @@ TEST(LSPBinderTest, OutgoingCalls) {
llvm::Optional<llvm::Expected<Foo>> Reply;
Echo(Foo{2}, capture(Reply));
EXPECT_THAT(RawOutgoing.take("echo"), ElementsAre(llvm::json::Value(2)));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2}));
// JSON response is integer, can't be parsed as string.
@ -147,14 +147,14 @@ TEST(LSPBinderTest, OutgoingCalls) {
WrongSignature(Foo{2}, capture(WrongTypeReply));
EXPECT_THAT(RawOutgoing.take("wrongSignature"),
ElementsAre(llvm::json::Value(2)));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
llvm::FailedWithMessage(
HasSubstr("failed to decode wrongSignature reply")));
Fail(Foo{2}, capture(Reply));
EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2)));
ASSERT_TRUE(Reply.hasValue());
ASSERT_TRUE(Reply.has_value());
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2"));
}

View File

@ -37,18 +37,18 @@ TEST(TidyProvider, NestedDirectories) {
TidyProvider Provider = provideClangTidyFiles(FS);
auto BaseOptions = getTidyOptionsForFile(Provider, testPath("File.cpp"));
ASSERT_TRUE(BaseOptions.Checks.hasValue());
ASSERT_TRUE(BaseOptions.Checks.has_value());
EXPECT_EQ(*BaseOptions.Checks, "llvm-*");
EXPECT_EQ(BaseOptions.CheckOptions.lookup("TestKey").Value, "1");
auto Sub1Options = getTidyOptionsForFile(Provider, testPath("sub1/File.cpp"));
ASSERT_TRUE(Sub1Options.Checks.hasValue());
ASSERT_TRUE(Sub1Options.Checks.has_value());
EXPECT_EQ(*Sub1Options.Checks, "misc-*");
EXPECT_EQ(Sub1Options.CheckOptions.lookup("TestKey").Value, "2");
auto Sub2Options =
getTidyOptionsForFile(Provider, testPath("sub1/sub2/File.cpp"));
ASSERT_TRUE(Sub2Options.Checks.hasValue());
ASSERT_TRUE(Sub2Options.Checks.has_value());
EXPECT_EQ(*Sub2Options.Checks, "misc-*,bugprone-*");
EXPECT_EQ(Sub2Options.CheckOptions.lookup("TestKey").Value, "3");
}

View File

@ -499,7 +499,7 @@ private:
FamilySequences.emplace_back(Sequences.top().first.Rule, *Push.Seq);
for (const GSS::Node *Base : Push.LastPop->parents()) {
auto NextState = Lang.Table.getGoToState(Base->State, F.Symbol);
assert(NextState.hasValue() && "goto must succeed after reduce!");
assert(NextState.has_value() && "goto must succeed after reduce!");
FamilyBases.emplace_back(*NextState, Base);
}
@ -555,7 +555,7 @@ private:
const GSS::Node *Head = Heads->back();
llvm::Optional<RuleID> RID;
for (RuleID R : Lang.Table.getReduceRules(Head->State)) {
if (RID.hasValue())
if (RID.has_value())
return false;
RID = R;
}
@ -577,7 +577,7 @@ private:
const ForestNode *Parsed =
&Params.Forest.createSequence(Rule.Target, *RID, TempSequence);
auto NextState = Lang.Table.getGoToState(Base->State, Rule.Target);
assert(NextState.hasValue() && "goto must succeed after reduce!");
assert(NextState.has_value() && "goto must succeed after reduce!");
Heads->push_back(Params.GSStack.addNode(*NextState, Parsed, {Base}));
return true;
}
@ -642,7 +642,7 @@ const ForestNode &glrParse(const ParseParams &Params, SymbolID StartSymbol,
// The parse was successful if we're in state `_ := start-symbol .`
auto AcceptState = Lang.Table.getGoToState(StartState, StartSymbol);
assert(AcceptState.hasValue() && "goto must succeed after start symbol!");
assert(AcceptState.has_value() && "goto must succeed after start symbol!");
auto SearchForAccept = [&](llvm::ArrayRef<const GSS::Node *> Heads) {
const ForestNode *Result = nullptr;
for (const auto *Head : Heads) {

View File

@ -95,8 +95,8 @@ 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 && Actual->DefLoc.hasValue()) {
EXPECT_EQ(Expected->DefLoc.has_value(), Actual->DefLoc.has_value());
if (Expected->DefLoc && Actual->DefLoc.has_value()) {
EXPECT_EQ(Expected->DefLoc->LineNumber, Actual->DefLoc->LineNumber);
EXPECT_EQ(Expected->DefLoc->Filename, Actual->DefLoc->Filename);
}

View File

@ -129,14 +129,14 @@ TEST(ParseConfiguration, MergeConfigurations) {
EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
EXPECT_EQ("user2", *Options.User);
ASSERT_TRUE(Options.ExtraArgs.hasValue());
ASSERT_TRUE(Options.ExtraArgs.has_value());
EXPECT_EQ("arg1,arg2,arg3,arg4", llvm::join(Options.ExtraArgs->begin(),
Options.ExtraArgs->end(), ","));
ASSERT_TRUE(Options.ExtraArgsBefore.hasValue());
ASSERT_TRUE(Options.ExtraArgsBefore.has_value());
EXPECT_EQ("arg-before1,arg-before2,arg-before3,arg-before4",
llvm::join(Options.ExtraArgsBefore->begin(),
Options.ExtraArgsBefore->end(), ","));
ASSERT_TRUE(Options.UseColor.hasValue());
ASSERT_TRUE(Options.UseColor.has_value());
EXPECT_TRUE(*Options.UseColor);
}
@ -325,9 +325,9 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
CHECK_VAL(TestCheck.getIntLocal("IntExpected"), 1);
CHECK_VAL(TestCheck.getIntGlobal("GlobalIntExpected"), 1);
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid1").hasValue());
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").hasValue());
EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").hasValue());
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid1").has_value());
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").has_value());
EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").has_value());
ASSERT_EQ(TestCheck.getIntLocal("DefaultedIntInvalid", 1), 1);
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolITrueValue"), true);
@ -395,14 +395,14 @@ TEST(ValidConfiguration, ValidEnumOptions) {
/*IgnoreCase*/ true),
Colours::Violet);
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").hasValue());
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").hasValue());
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").hasValue());
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").has_value());
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").has_value());
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").has_value());
EXPECT_FALSE(
TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").hasValue());
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").hasValue());
TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").has_value());
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").has_value());
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").hasValue());
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").has_value());
EXPECT_THAT(
DiagConsumer.take(),
UnorderedElementsAre(

View File

@ -53,9 +53,9 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) {
ClangTidyOptions File3Options =
FileOpt.getOptions("ProjectRoot/SubDir1/SubDir2/SubDir3/File.cpp");
ASSERT_TRUE(File1Options.Checks.hasValue());
ASSERT_TRUE(File1Options.Checks.has_value());
EXPECT_EQ(*File1Options.Checks, "-*,clang-diagnostic-*,readability-*");
ASSERT_TRUE(File2Options.Checks.hasValue());
ASSERT_TRUE(File2Options.Checks.has_value());
EXPECT_EQ(*File2Options.Checks, "bugprone-*,misc-*,clang-diagnostic-*");
// 2 and 3 should use the same config so these should also be the same.

View File

@ -76,7 +76,7 @@ public:
}
void setSwiftPrivate(llvm::Optional<bool> Private) {
SwiftPrivateSpecified = Private.hasValue();
SwiftPrivateSpecified = Private.has_value();
SwiftPrivate = Private ? *Private : 0;
}

View File

@ -414,7 +414,8 @@ public:
bool isArgumentConstructedDirectly(unsigned Index) const {
// This assumes that the object was not yet removed from the state.
return ExprEngine::getObjectUnderConstruction(
getState(), {getOriginExpr(), Index}, getLocationContext()).hasValue();
getState(), {getOriginExpr(), Index}, getLocationContext())
.has_value();
}
/// Some calls have parameter numbering mismatched from argument numbering.

View File

@ -59,15 +59,11 @@ public:
bool isConstrainedFalse() const { return Val && !Val.getValue(); }
/// Return true if the constrained is perfectly constrained.
bool isConstrained() const {
return Val.hasValue();
}
bool isConstrained() const { return Val.has_value(); }
/// Return true if the constrained is underconstrained and we do not know
/// if the constraint is true of value.
bool isUnderconstrained() const {
return !Val.hasValue();
}
bool isUnderconstrained() const { return !Val.has_value(); }
};
class ConstraintManager {

View File

@ -94,7 +94,7 @@ public:
assert(!isDirectory() && "not a file");
assert(Contents && "contents not initialized");
if (auto *Directives = Contents->DepDirectives.load()) {
if (Directives->hasValue())
if (Directives->has_value())
return ArrayRef<dependency_directives_scan::Directive>(
Directives->getValue());
}

View File

@ -5362,8 +5362,8 @@ private:
// Overwrite existing if the new member has more info.
// The preference of . vs :: vs -> is fairly arbitrary.
if (/*Inserted*/ R.second ||
std::make_tuple(M.ArgTypes.hasValue(), M.ResultType != nullptr,
M.Operator) > std::make_tuple(O.ArgTypes.hasValue(),
std::make_tuple(M.ArgTypes.has_value(), M.ResultType != nullptr,
M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
O.ResultType != nullptr,
O.Operator))
O = std::move(M);

View File

@ -840,7 +840,7 @@ public:
/// false - otherwise.
bool isOrderedRegion() const {
if (const SharingMapTy *Top = getTopOfStackOrNull())
return Top->OrderedRegion.hasValue();
return Top->OrderedRegion.has_value();
return false;
}
/// Returns optional parameter for the ordered region.
@ -854,7 +854,7 @@ public:
/// 'ordered' clause), false - otherwise.
bool isParentOrderedRegion() const {
if (const SharingMapTy *Parent = getSecondOnStackOrNull())
return Parent->OrderedRegion.hasValue();
return Parent->OrderedRegion.has_value();
return false;
}
/// Returns optional parameter for the ordered region.
@ -7831,9 +7831,9 @@ public:
/// Return true if any expression is dependent.
bool dependent() const;
/// Returns true if the initializer forms non-rectangular loop.
bool doesInitDependOnLC() const { return InitDependOnLC.hasValue(); }
bool doesInitDependOnLC() const { return InitDependOnLC.has_value(); }
/// Returns true if the condition forms non-rectangular loop.
bool doesCondDependOnLC() const { return CondDependOnLC.hasValue(); }
bool doesCondDependOnLC() const { return CondDependOnLC.has_value(); }
/// Returns index of the loop we depend on (starting from 1), or 0 otherwise.
unsigned getLoopDependentIdx() const {
return InitDependOnLC.value_or(CondDependOnLC.value_or(0));
@ -8774,10 +8774,10 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
Expr *MaxExpr = nullptr;
Expr *LBExpr = TestIsLessOp.getValue() ? LB : UB;
Expr *UBExpr = TestIsLessOp.getValue() ? UB : LB;
bool LBNonRect = TestIsLessOp.getValue() ? InitDependOnLC.hasValue()
: CondDependOnLC.hasValue();
bool UBNonRect = TestIsLessOp.getValue() ? CondDependOnLC.hasValue()
: InitDependOnLC.hasValue();
bool LBNonRect = TestIsLessOp.getValue() ? InitDependOnLC.has_value()
: CondDependOnLC.has_value();
bool UBNonRect = TestIsLessOp.getValue() ? CondDependOnLC.has_value()
: InitDependOnLC.has_value();
Expr *Lower =
LBNonRect ? LBExpr : tryBuildCapture(SemaRef, LBExpr, Captures).get();
Expr *Upper =

View File

@ -1888,8 +1888,8 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
// without this file existing on disk.
if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
PP->Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
<< WritingModule->getFullModuleName() << U.Size.hasValue()
<< U.FileName;
<< WritingModule->getFullModuleName() << U.Size.has_value()
<< U.FileName;
continue;
}

View File

@ -2363,15 +2363,15 @@ PathSensitiveBugReport::getInterestingnessKind(const MemRegion *R) const {
}
bool PathSensitiveBugReport::isInteresting(SVal V) const {
return getInterestingnessKind(V).hasValue();
return getInterestingnessKind(V).has_value();
}
bool PathSensitiveBugReport::isInteresting(SymbolRef sym) const {
return getInterestingnessKind(sym).hasValue();
return getInterestingnessKind(sym).has_value();
}
bool PathSensitiveBugReport::isInteresting(const MemRegion *R) const {
return getInterestingnessKind(R).hasValue();
return getInterestingnessKind(R).has_value();
}
bool PathSensitiveBugReport::isInteresting(const LocationContext *LC) const {

View File

@ -449,27 +449,27 @@ TEST(ParserTest, ParseMultiline) {
)
)matcher";
Diagnostics Error;
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
}
{
Code = R"matcher(decl(decl()
, decl()))matcher";
Diagnostics Error;
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
}
{
Code = R"matcher(decl(decl(),
decl()))matcher";
Diagnostics Error;
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
}
{
Code = "namedDecl(hasName(\"n\"\n))";
Diagnostics Error;
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
}
{

View File

@ -82,8 +82,8 @@ TEST(DataflowAnalysisTest, NoopAnalysis) {
return NoopAnalysis(C, false);
}));
EXPECT_EQ(BlockStates.size(), 2u);
EXPECT_TRUE(BlockStates[0].hasValue());
EXPECT_TRUE(BlockStates[1].hasValue());
EXPECT_TRUE(BlockStates[0].has_value());
EXPECT_TRUE(BlockStates[1].has_value());
}
struct NonConvergingLattice {

View File

@ -121,14 +121,14 @@ TEST_F(MacroExpansionContextTest, IgnoresPragmas) {
EXPECT_EQ("\n=============== ExpansionRanges ===============\n",
dumpExpansionRanges(*Ctx));
EXPECT_FALSE(Ctx->getExpandedText(at(2, 1)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 1)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(2, 1)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 1)).has_value());
EXPECT_FALSE(Ctx->getExpandedText(at(2, 3)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 3)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(2, 3)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 3)).has_value());
EXPECT_FALSE(Ctx->getExpandedText(at(3, 3)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 3)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(3, 3)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 3)).has_value());
}
TEST_F(MacroExpansionContextTest, NoneForNonExpansionLocations) {
@ -142,33 +142,33 @@ EMPTY zz
// zz
// That's the beginning of the definition of EMPTY.
EXPECT_FALSE(Ctx->getExpandedText(at(2, 11)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 11)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(2, 11)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(2, 11)).has_value());
// The space before the first expansion of EMPTY.
EXPECT_FALSE(Ctx->getExpandedText(at(3, 9)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 9)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(3, 9)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 9)).has_value());
// The beginning of the first expansion of EMPTY.
EXPECT_TRUE(Ctx->getExpandedText(at(3, 10)).hasValue());
EXPECT_TRUE(Ctx->getOriginalText(at(3, 10)).hasValue());
EXPECT_TRUE(Ctx->getExpandedText(at(3, 10)).has_value());
EXPECT_TRUE(Ctx->getOriginalText(at(3, 10)).has_value());
// Pointing inside of the token EMPTY, but not at the beginning.
// FIXME: We only deal with begin locations.
EXPECT_FALSE(Ctx->getExpandedText(at(3, 11)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 11)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(3, 11)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 11)).has_value());
// Same here.
EXPECT_FALSE(Ctx->getExpandedText(at(3, 12)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 12)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(3, 12)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(3, 12)).has_value());
// The beginning of the last expansion of EMPTY.
EXPECT_TRUE(Ctx->getExpandedText(at(4, 1)).hasValue());
EXPECT_TRUE(Ctx->getOriginalText(at(4, 1)).hasValue());
EXPECT_TRUE(Ctx->getExpandedText(at(4, 1)).has_value());
EXPECT_TRUE(Ctx->getOriginalText(at(4, 1)).has_value());
// Same as for the 3:11 case.
EXPECT_FALSE(Ctx->getExpandedText(at(4, 2)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(4, 2)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(4, 2)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(4, 2)).has_value());
}
TEST_F(MacroExpansionContextTest, EmptyExpansions) {
@ -388,8 +388,8 @@ TEST_F(MacroExpansionContextTest, RedefUndef) {
EXPECT_EQ("Hi", Ctx->getOriginalText(at(5, 3)).getValue());
// There was no macro expansion at 7:3, we should expect None.
EXPECT_FALSE(Ctx->getExpandedText(at(7, 3)).hasValue());
EXPECT_FALSE(Ctx->getOriginalText(at(7, 3)).hasValue());
EXPECT_FALSE(Ctx->getExpandedText(at(7, 3)).has_value());
EXPECT_FALSE(Ctx->getOriginalText(at(7, 3)).has_value());
}
TEST_F(MacroExpansionContextTest, UnbalacedParenthesis) {

View File

@ -64,14 +64,14 @@ TEST(DarwinSDKInfo, VersionMappingParseEmpty) {
llvm::json::Object Obj({});
EXPECT_FALSE(
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj, VersionTuple())
.hasValue());
.has_value());
}
TEST(DarwinSDKInfo, VersionMappingParseError) {
llvm::json::Object Obj({{"test", "1.2"}});
EXPECT_FALSE(
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj, VersionTuple())
.hasValue());
.has_value());
}
TEST(DarwinSDKInfoTest, ParseAndTestMappingMacCatalyst) {

View File

@ -258,7 +258,7 @@ void checkEventualResultWithTimeout(VerifyingConsumer &TestConsumer) {
std::future_status::ready)
<< "The expected result state wasn't reached before the time-out.";
std::unique_lock<std::mutex> L(TestConsumer.Mtx);
EXPECT_TRUE(TestConsumer.result().hasValue());
EXPECT_TRUE(TestConsumer.result().has_value());
if (TestConsumer.result()) {
EXPECT_TRUE(*TestConsumer.result());
}

View File

@ -200,7 +200,7 @@ TEST_F(HeaderSearchTest, HeaderFrameworkLookup) {
/*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
/*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, &IsFrameworkFound);
EXPECT_TRUE(FoundFile.hasValue());
EXPECT_TRUE(FoundFile.has_value());
EXPECT_TRUE(IsFrameworkFound);
auto &FE = FoundFile.getValue();
auto FI = Search.getExistingFileInfo(FE);
@ -269,7 +269,7 @@ TEST_F(HeaderSearchTest, HeaderMapFrameworkLookup) {
/*SuggestedModule=*/nullptr, &IsMapped,
/*IsFrameworkFound=*/nullptr);
EXPECT_TRUE(FoundFile.hasValue());
EXPECT_TRUE(FoundFile.has_value());
EXPECT_TRUE(IsMapped);
auto &FE = FoundFile.getValue();
auto FI = Search.getExistingFileInfo(FE);

View File

@ -305,13 +305,13 @@ void foo(int x) {
EXPECT_EQ("TestUnion", CRecordType->getDecl()->getName());
auto D = getByName("d").getAs<nonloc::CompoundVal>();
ASSERT_TRUE(D.hasValue());
ASSERT_TRUE(D.has_value());
auto Begin = D->begin();
ASSERT_NE(D->end(), Begin);
++Begin;
ASSERT_EQ(D->end(), Begin);
auto LD = D->begin()->getAs<nonloc::LazyCompoundVal>();
ASSERT_TRUE(LD.hasValue());
ASSERT_TRUE(LD.has_value());
auto LDT = LD->getType(Context);
ASSERT_FALSE(LDT.isNull());
const auto *DElaboratedType = dyn_cast<ElaboratedType>(LDT);