forked from OSchip/llvm-project
Don't use Optional::hasValue (NFC)
This commit is contained in:
parent
b8df4093e4
commit
aa8feeefd3
|
@ -653,10 +653,10 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
|
|||
|
||||
if (I.DefLoc) {
|
||||
if (!CDCtx.RepositoryUrl)
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
Out.emplace_back(writeFileDefinition(*I.DefLoc));
|
||||
else
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
}
|
||||
|
||||
std::string Description;
|
||||
|
@ -702,10 +702,10 @@ genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx,
|
|||
|
||||
if (I.DefLoc) {
|
||||
if (!CDCtx.RepositoryUrl)
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
Out.emplace_back(writeFileDefinition(*I.DefLoc));
|
||||
else
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
}
|
||||
|
||||
std::string Description;
|
||||
|
@ -768,10 +768,10 @@ genHTML(const RecordInfo &I, Index &InfoIndex, const ClangDocContext &CDCtx,
|
|||
|
||||
if (I.DefLoc) {
|
||||
if (!CDCtx.RepositoryUrl)
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
Out.emplace_back(writeFileDefinition(*I.DefLoc));
|
||||
else
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
}
|
||||
|
||||
std::string Description;
|
||||
|
|
|
@ -817,8 +817,8 @@ void NotNullTerminatedResultCheck::check(
|
|||
++It;
|
||||
}
|
||||
|
||||
if (AreSafeFunctionsWanted.hasValue())
|
||||
UseSafeFunctions = AreSafeFunctionsWanted.getValue();
|
||||
if (AreSafeFunctionsWanted)
|
||||
UseSafeFunctions = *AreSafeFunctionsWanted;
|
||||
}
|
||||
|
||||
StringRef Name = FunctionExpr->getDirectCallee()->getName();
|
||||
|
|
|
@ -663,9 +663,9 @@ void ClangdLSPServer::onDocumentDidOpen(
|
|||
void ClangdLSPServer::onDocumentDidChange(
|
||||
const DidChangeTextDocumentParams &Params) {
|
||||
auto WantDiags = WantDiagnostics::Auto;
|
||||
if (Params.wantDiagnostics.hasValue())
|
||||
WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
|
||||
: WantDiagnostics::No;
|
||||
if (Params.wantDiagnostics)
|
||||
WantDiags =
|
||||
*Params.wantDiagnostics ? WantDiagnostics::Yes : WantDiagnostics::No;
|
||||
|
||||
PathRef File = Params.textDocument.uri.file();
|
||||
auto Code = Server->getDraft(File);
|
||||
|
|
|
@ -411,10 +411,9 @@ 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();
|
||||
CachedCompletionFuzzyFindRequestByFile[File] = *SpecFuzzyFind->NewReq;
|
||||
}
|
||||
// SpecFuzzyFind is only destroyed after speculative fuzzy find finishes.
|
||||
// We don't want `codeComplete` to wait for the async call if it doesn't use
|
||||
|
|
|
@ -391,11 +391,9 @@ struct CodeCompletionBuilder {
|
|||
ToInclude.takeError());
|
||||
}
|
||||
// Prefer includes that do not need edits (i.e. already exist).
|
||||
std::stable_partition(Completion.Includes.begin(),
|
||||
Completion.Includes.end(),
|
||||
[](const CodeCompletion::IncludeCandidate &I) {
|
||||
return !I.Insertion.hasValue();
|
||||
});
|
||||
std::stable_partition(
|
||||
Completion.Includes.begin(), Completion.Includes.end(),
|
||||
[](const CodeCompletion::IncludeCandidate &I) { return !I.Insertion; });
|
||||
}
|
||||
|
||||
void add(const CompletionCandidate &C, CodeCompletionString *SemaCCS) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -82,12 +82,12 @@ Diagnostics:
|
|||
EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(val("b\naz\n")));
|
||||
|
||||
ASSERT_TRUE(Results[2].Index.Background);
|
||||
EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
|
||||
EXPECT_EQ("Skip", *Results[2].Index.Background.value());
|
||||
EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
|
||||
ElementsAre(PairVal("IgnoreMacros", "true"),
|
||||
PairVal("example-check.ExampleOption", "0")));
|
||||
EXPECT_TRUE(Results[3].Diagnostics.UnusedIncludes);
|
||||
EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
|
||||
EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.value());
|
||||
}
|
||||
|
||||
TEST(ParseYAML, Locations) {
|
||||
|
@ -163,10 +163,10 @@ 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_THAT(*Results[0].Index.External.getValue()->IsNone, testing::Eq(true));
|
||||
EXPECT_FALSE(Results[0].Index.External.value()->File.has_value());
|
||||
EXPECT_FALSE(Results[0].Index.External.value()->MountPoint.has_value());
|
||||
EXPECT_FALSE(Results[0].Index.External.value()->Server.has_value());
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->IsNone, testing::Eq(true));
|
||||
}
|
||||
|
||||
TEST(ParseYAML, ExternalBlock) {
|
||||
|
@ -182,10 +182,10 @@ Index:
|
|||
Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
|
||||
ASSERT_EQ(Results.size(), 1u);
|
||||
ASSERT_TRUE(Results[0].Index.External);
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->File, val("foo"));
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->MountPoint, val("baz"));
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->File, val("foo"));
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->MountPoint, val("baz"));
|
||||
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->Server, val("bar"));
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->Server, val("bar"));
|
||||
}
|
||||
|
||||
TEST(ParseYAML, AllScopes) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -331,14 +331,14 @@ 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());
|
||||
EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
|
||||
ASSERT_TRUE(Commands.has_value());
|
||||
EXPECT_THAT(Commands->CommandLine, Contains("-DFOO"));
|
||||
// Make sure we pick the right working directory.
|
||||
EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
|
||||
EXPECT_EQ(testPath("x"), Commands->Directory);
|
||||
}
|
||||
|
||||
MATCHER_P(hasArg, Flag, "") {
|
||||
if (!arg.hasValue()) {
|
||||
if (!arg) {
|
||||
*result_listener << "command is null";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
|
|||
FS.Files[Invalid];
|
||||
Optional<Path> PathResult =
|
||||
getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), FooH);
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, FooH);
|
||||
|
||||
PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), FooCpp);
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, FooCpp);
|
||||
|
||||
// Test with header file in capital letters and different extension, source
|
||||
// file with different extension
|
||||
|
@ -48,8 +48,8 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
|
|||
FS.Files[FooC];
|
||||
FS.Files[FooHH];
|
||||
PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), FooHH);
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, FooHH);
|
||||
|
||||
// Test with both capital letters
|
||||
auto Foo2C = testPath("foo2.C");
|
||||
|
@ -57,8 +57,8 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
|
|||
FS.Files[Foo2C];
|
||||
FS.Files[Foo2HH];
|
||||
PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), Foo2HH);
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, Foo2HH);
|
||||
|
||||
// Test with source file as capital letter and .hxx header file
|
||||
auto Foo3C = testPath("foo3.C");
|
||||
|
@ -67,13 +67,13 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
|
|||
FS.Files[Foo3C];
|
||||
FS.Files[Foo3HXX];
|
||||
PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), Foo3HXX);
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, 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, "") {
|
||||
|
|
|
@ -93,19 +93,18 @@ TEST(LSPBinderTest, IncomingCalls) {
|
|||
|
||||
auto &RawPlusOne = RawHandlers.MethodHandlers["plusOne"];
|
||||
RawPlusOne(1, capture(Reply));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(2));
|
||||
RawPlusOne("foo", capture(Reply));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(
|
||||
Reply.getValue(),
|
||||
llvm::FailedWithMessage(
|
||||
HasSubstr("failed to decode plusOne request: expected integer")));
|
||||
*Reply, llvm::FailedWithMessage(HasSubstr(
|
||||
"failed to decode plusOne request: expected integer")));
|
||||
|
||||
auto &RawFail = RawHandlers.MethodHandlers["fail"];
|
||||
RawFail(2, capture(Reply));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("X=2"));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::FailedWithMessage("X=2"));
|
||||
|
||||
auto &RawNotify = RawHandlers.NotificationHandlers["notify"];
|
||||
RawNotify(42);
|
||||
|
@ -117,8 +116,8 @@ TEST(LSPBinderTest, IncomingCalls) {
|
|||
|
||||
auto &RawCmdPlusOne = RawHandlers.CommandHandlers["cmdPlusOne"];
|
||||
RawCmdPlusOne(1, capture(Reply));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(2));
|
||||
|
||||
// None of this generated any outgoing traffic.
|
||||
EXPECT_THAT(RawOutgoing.Received, IsEmpty());
|
||||
|
@ -139,23 +138,23 @@ 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());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2}));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(Foo{2}));
|
||||
|
||||
// JSON response is integer, can't be parsed as string.
|
||||
llvm::Optional<llvm::Expected<std::string>> WrongTypeReply;
|
||||
WrongSignature(Foo{2}, capture(WrongTypeReply));
|
||||
EXPECT_THAT(RawOutgoing.take("wrongSignature"),
|
||||
ElementsAre(llvm::json::Value(2)));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*WrongTypeReply,
|
||||
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());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2"));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::FailedWithMessage("Params=2"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.hasValue() && Actual->DefLoc.hasValue()) {
|
||||
EXPECT_EQ(Expected->DefLoc.has_value(), Actual->DefLoc.has_value());
|
||||
if (Expected->DefLoc && Actual->DefLoc) {
|
||||
EXPECT_EQ(Expected->DefLoc->LineNumber, Actual->DefLoc->LineNumber);
|
||||
EXPECT_EQ(Expected->DefLoc->Filename, Actual->DefLoc->Filename);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -34,8 +34,8 @@ public:
|
|||
assert(Call != nullptr && "Did not find node \"foo\"");
|
||||
auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar",
|
||||
{"b", "some_alias"});
|
||||
if (Hint.hasValue())
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
if (Hint)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;
|
||||
|
||||
diag(Call->getBeginLoc(), "insert call") << FixItHint::CreateInsertion(
|
||||
Call->getBeginLoc(),
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -37,8 +37,8 @@ public:
|
|||
auto Hint =
|
||||
Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");
|
||||
|
||||
if (Hint.hasValue())
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
if (Hint)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;
|
||||
|
||||
diag(Call->getBeginLoc(), "insert call")
|
||||
<< clang::FixItHint::CreateReplacement(
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
}
|
||||
|
||||
void setSwiftPrivate(llvm::Optional<bool> Private) {
|
||||
SwiftPrivateSpecified = Private.hasValue();
|
||||
SwiftPrivate = Private.hasValue() ? *Private : 0;
|
||||
SwiftPrivateSpecified = Private.has_value();
|
||||
SwiftPrivate = Private.value_or(0);
|
||||
}
|
||||
|
||||
friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);
|
||||
|
|
|
@ -520,15 +520,15 @@ let Class = PropertyTypeCase<APValue, "LValue"> in {
|
|||
if (hasBase) {
|
||||
if (isTypeInfo) {
|
||||
base = APValue::LValueBase::getTypeInfo(
|
||||
TypeInfoLValue(typeInfo.getValue().getTypePtr()), type.getValue());
|
||||
TypeInfoLValue(typeInfo->getTypePtr()), *type);
|
||||
elemTy = base.getTypeInfoType();
|
||||
} else if (isExpr) {
|
||||
base = APValue::LValueBase(cast<Expr>(stmt.getValue()),
|
||||
callIndex.getValue(), version.getValue());
|
||||
base = APValue::LValueBase(cast<Expr>(*stmt),
|
||||
*callIndex, *version);
|
||||
elemTy = base.get<const Expr *>()->getType();
|
||||
} else {
|
||||
base = APValue::LValueBase(cast<ValueDecl>(decl.getValue()),
|
||||
callIndex.getValue(), version.getValue());
|
||||
base = APValue::LValueBase(cast<ValueDecl>(*decl),
|
||||
*callIndex, *version);
|
||||
elemTy = base.get<const ValueDecl *>()->getType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -544,8 +544,8 @@ public:
|
|||
/// flag may have been previously set, at which point it will not
|
||||
/// be reset unless one specifies to do so.
|
||||
void setPrunable(bool isPrunable, bool override = false) {
|
||||
if (IsPrunable.hasValue() && !override)
|
||||
return;
|
||||
if (IsPrunable && !override)
|
||||
return;
|
||||
IsPrunable = isPrunable;
|
||||
}
|
||||
|
||||
|
|
|
@ -1766,9 +1766,9 @@ public:
|
|||
template <typename T>
|
||||
friend const SemaDiagnosticBuilder &
|
||||
operator<<(const SemaDiagnosticBuilder &Diag, const T &Value) {
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
if (Diag.ImmediateDiag)
|
||||
*Diag.ImmediateDiag << Value;
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
else if (Diag.PartialDiagId)
|
||||
Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
|
||||
<< Value;
|
||||
return Diag;
|
||||
|
@ -1780,26 +1780,26 @@ public:
|
|||
template <typename T, typename = typename std::enable_if<
|
||||
!std::is_lvalue_reference<T>::value>::type>
|
||||
const SemaDiagnosticBuilder &operator<<(T &&V) const {
|
||||
if (ImmediateDiag.hasValue())
|
||||
if (ImmediateDiag)
|
||||
*ImmediateDiag << std::move(V);
|
||||
else if (PartialDiagId.hasValue())
|
||||
else if (PartialDiagId)
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second << std::move(V);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend const SemaDiagnosticBuilder &
|
||||
operator<<(const SemaDiagnosticBuilder &Diag, const PartialDiagnostic &PD) {
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
if (Diag.ImmediateDiag)
|
||||
PD.Emit(*Diag.ImmediateDiag);
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
else if (Diag.PartialDiagId)
|
||||
Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second = PD;
|
||||
return Diag;
|
||||
}
|
||||
|
||||
void AddFixItHint(const FixItHint &Hint) const {
|
||||
if (ImmediateDiag.hasValue())
|
||||
if (ImmediateDiag)
|
||||
ImmediateDiag->AddFixItHint(Hint);
|
||||
else if (PartialDiagId.hasValue())
|
||||
else if (PartialDiagId)
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second.AddFixItHint(Hint);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -1016,9 +1017,8 @@ public:
|
|||
}
|
||||
|
||||
SVal getObjectUnderConstruction() const {
|
||||
return ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),
|
||||
getLocationContext())
|
||||
.getValue();
|
||||
return *ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),
|
||||
getLocationContext());
|
||||
}
|
||||
|
||||
/// Number of non-placement arguments to the call. It is equal to 2 for
|
||||
|
|
|
@ -53,25 +53,17 @@ 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; }
|
||||
|
||||
/// Return true if the constraint is perfectly constrained to 'false'.
|
||||
bool isConstrainedFalse() const {
|
||||
return Val.hasValue() && !Val.getValue();
|
||||
}
|
||||
bool isConstrainedFalse() const { return Val && !*Val; }
|
||||
|
||||
/// 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 {
|
||||
|
|
|
@ -341,10 +341,10 @@ protected:
|
|||
addStateConstraints(NewState);
|
||||
|
||||
Optional<bool> res = Solver->check();
|
||||
if (!res.hasValue())
|
||||
if (!res)
|
||||
Cached[hash] = ConditionTruthVal();
|
||||
else
|
||||
Cached[hash] = ConditionTruthVal(res.getValue());
|
||||
Cached[hash] = ConditionTruthVal(*res);
|
||||
|
||||
return Cached[hash];
|
||||
}
|
||||
|
|
|
@ -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 == 0; }
|
||||
bool isVector() const { return Scale && *Scale != 0; }
|
||||
bool isVector(unsigned Width) const {
|
||||
return isVector() && ElementBitwidth == Width;
|
||||
}
|
||||
|
|
|
@ -94,9 +94,9 @@ 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());
|
||||
Directives->value());
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -168,24 +168,24 @@ OMPDeclareTargetDeclAttr::getActiveAttr(const ValueDecl *VD) {
|
|||
llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy>
|
||||
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->getMapType();
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.value()->getMapType();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr::DevTypeTy>
|
||||
OMPDeclareTargetDeclAttr::getDeviceType(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->getDevType();
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.value()->getDevType();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
llvm::Optional<SourceLocation>
|
||||
OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->getRange().getBegin();
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.value()->getRange().getBegin();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
|
|
|
@ -397,9 +397,9 @@ bool Parser::parseIdentifierPrefixImpl(VariantValue *Value) {
|
|||
assert(NamedValue.isMatcher());
|
||||
llvm::Optional<DynTypedMatcher> Result =
|
||||
NamedValue.getMatcher().getSingleMatcher();
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound.hasValue()) {
|
||||
if (Bound) {
|
||||
*Value = VariantMatcher::SingleMatcher(*Bound);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -797,9 +797,9 @@ VariantMatcher Registry::constructBoundMatcher(MatcherCtor Ctor,
|
|||
if (Out.isNull()) return Out;
|
||||
|
||||
llvm::Optional<DynTypedMatcher> Result = Out.getSingleMatcher();
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound.hasValue()) {
|
||||
if (Bound) {
|
||||
return VariantMatcher::SingleMatcher(*Bound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -697,8 +697,8 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)
|
|||
|
||||
Stmt *BodyFarm::getBody(const FunctionDecl *D) {
|
||||
Optional<Stmt *> &Val = Bodies[D];
|
||||
if (Val.hasValue())
|
||||
return Val.getValue();
|
||||
if (Val)
|
||||
return *Val;
|
||||
|
||||
Val = nullptr;
|
||||
|
||||
|
@ -872,8 +872,8 @@ Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) {
|
|||
return nullptr;
|
||||
|
||||
Optional<Stmt *> &Val = Bodies[D];
|
||||
if (Val.hasValue())
|
||||
return Val.getValue();
|
||||
if (Val)
|
||||
return *Val;
|
||||
Val = nullptr;
|
||||
|
||||
// For now, we only synthesize getters.
|
||||
|
|
|
@ -31,13 +31,10 @@ buildStmtToBasicBlockMap(const CFG &Cfg) {
|
|||
if (Block == nullptr)
|
||||
continue;
|
||||
|
||||
for (const CFGElement &Element : *Block) {
|
||||
auto Stmt = Element.getAs<CFGStmt>();
|
||||
if (!Stmt.hasValue())
|
||||
continue;
|
||||
for (const CFGElement &Element : *Block)
|
||||
if (auto Stmt = Element.getAs<CFGStmt>())
|
||||
StmtToBlock[Stmt->getStmt()] = Block;
|
||||
|
||||
StmtToBlock[Stmt.getValue().getStmt()] = Block;
|
||||
}
|
||||
if (const Stmt *TerminatorStmt = Block->getTerminatorStmt())
|
||||
StmtToBlock[TerminatorStmt] = Block;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
auto BlockIT = CFCtx.getStmtToBlock().find(&ignoreCFGOmittedNodes(S));
|
||||
assert(BlockIT != CFCtx.getStmtToBlock().end());
|
||||
const auto &State = BlockToState[BlockIT->getSecond()->getBlockID()];
|
||||
assert(State.hasValue());
|
||||
return &State.getValue().Env;
|
||||
assert(State);
|
||||
return &State->Env;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -209,10 +209,10 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
|||
// loop back edge to `Block`.
|
||||
const llvm::Optional<TypeErasedDataflowAnalysisState> &MaybePredState =
|
||||
BlockStates[Pred->getBlockID()];
|
||||
if (!MaybePredState.hasValue())
|
||||
if (!MaybePredState)
|
||||
continue;
|
||||
|
||||
TypeErasedDataflowAnalysisState PredState = MaybePredState.getValue();
|
||||
TypeErasedDataflowAnalysisState PredState = *MaybePredState;
|
||||
if (ApplyBuiltinTransfer) {
|
||||
if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
|
||||
const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
|
||||
|
@ -222,14 +222,14 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
|||
}
|
||||
}
|
||||
|
||||
if (MaybeState.hasValue()) {
|
||||
if (MaybeState) {
|
||||
Analysis.joinTypeErased(MaybeState->Lattice, PredState.Lattice);
|
||||
MaybeState->Env.join(PredState.Env, Analysis);
|
||||
} else {
|
||||
MaybeState = std::move(PredState);
|
||||
}
|
||||
}
|
||||
if (!MaybeState.hasValue()) {
|
||||
if (!MaybeState) {
|
||||
// FIXME: Consider passing `Block` to `Analysis.typeErasedInitialElement()`
|
||||
// to enable building analyses like computation of dominators that
|
||||
// initialize the state of each basic block differently.
|
||||
|
@ -367,8 +367,8 @@ runTypeErasedDataflowAnalysis(const ControlFlowContext &CFCtx,
|
|||
TypeErasedDataflowAnalysisState NewBlockState =
|
||||
transferBlock(CFCtx, BlockStates, *Block, InitEnv, Analysis);
|
||||
|
||||
if (OldBlockState.hasValue() &&
|
||||
Analysis.isEqualTypeErased(OldBlockState.getValue().Lattice,
|
||||
if (OldBlockState &&
|
||||
Analysis.isEqualTypeErased(OldBlockState->Lattice,
|
||||
NewBlockState.Lattice) &&
|
||||
OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis)) {
|
||||
// The state of `Block` didn't change after transfer so there's no need to
|
||||
|
|
|
@ -319,8 +319,8 @@ static Optional<bool> comparePath(const PathPieces &X, const PathPieces &Y) {
|
|||
|
||||
for ( ; X_I != X_end && Y_I != Y_end; ++X_I, ++Y_I) {
|
||||
Optional<bool> b = comparePiece(**X_I, **Y_I);
|
||||
if (b.hasValue())
|
||||
return b.getValue();
|
||||
if (b)
|
||||
return *b;
|
||||
}
|
||||
|
||||
return None;
|
||||
|
@ -396,8 +396,8 @@ static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y) {
|
|||
return (*XI) < (*YI);
|
||||
}
|
||||
Optional<bool> b = comparePath(X.path, Y.path);
|
||||
assert(b.hasValue());
|
||||
return b.getValue();
|
||||
assert(b);
|
||||
return *b;
|
||||
}
|
||||
|
||||
void PathDiagnosticConsumer::FlushDiagnostics(
|
||||
|
|
|
@ -148,8 +148,8 @@ public:
|
|||
Value getValue(const CFGBlock *block, const CFGBlock *dstBlock,
|
||||
const VarDecl *vd) {
|
||||
const Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
|
||||
assert(idx.hasValue());
|
||||
return getValueVector(block)[idx.getValue()];
|
||||
assert(idx);
|
||||
return getValueVector(block)[*idx];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,8 +209,8 @@ void CFGBlockValues::resetScratch() {
|
|||
|
||||
ValueVector::reference CFGBlockValues::operator[](const VarDecl *vd) {
|
||||
const Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
|
||||
assert(idx.hasValue());
|
||||
return scratch[idx.getValue()];
|
||||
assert(idx);
|
||||
return scratch[*idx];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------====//
|
||||
|
|
|
@ -251,8 +251,8 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
|
|||
.Case("riscv64", Is64Bit)
|
||||
.Case("64bit", Is64Bit)
|
||||
.Default(None);
|
||||
if (Result.hasValue())
|
||||
return Result.getValue();
|
||||
if (Result)
|
||||
return *Result;
|
||||
|
||||
if (ISAInfo->isSupportedExtensionFeature(Feature))
|
||||
return ISAInfo->hasExtension(Feature);
|
||||
|
|
|
@ -1782,15 +1782,15 @@ namespace {
|
|||
if (!StartIndex)
|
||||
StartIndex = FieldIndex;
|
||||
} else if (StartIndex) {
|
||||
EHStack.pushCleanup<SanitizeDtorFieldRange>(
|
||||
NormalAndEHCleanup, DD, StartIndex.getValue(), FieldIndex);
|
||||
EHStack.pushCleanup<SanitizeDtorFieldRange>(NormalAndEHCleanup, DD,
|
||||
*StartIndex, FieldIndex);
|
||||
StartIndex = None;
|
||||
}
|
||||
}
|
||||
void End() {
|
||||
if (StartIndex)
|
||||
EHStack.pushCleanup<SanitizeDtorFieldRange>(NormalAndEHCleanup, DD,
|
||||
StartIndex.getValue(), -1);
|
||||
*StartIndex, -1);
|
||||
}
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
|
|
@ -2826,12 +2826,12 @@ bool CodeGenModule::isProfileInstrExcluded(llvm::Function *Fn,
|
|||
CodeGenOptions::ProfileInstrKind Kind = getCodeGenOpts().getProfileInstr();
|
||||
// First, check the function name.
|
||||
Optional<bool> V = ProfileList.isFunctionExcluded(Fn->getName(), Kind);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return *V;
|
||||
// Next, check the source location.
|
||||
if (Loc.isValid()) {
|
||||
Optional<bool> V = ProfileList.isLocationExcluded(Loc, Kind);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return *V;
|
||||
}
|
||||
// If location is unknown, this may be a compiler-generated function. Assume
|
||||
|
|
|
@ -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) {
|
||||
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
|
||||
OffloadAction::DeviceDependences DDep;
|
||||
DDep.add(*CudaDeviceActions[I], *ToolChains.front(), GpuArchList[I],
|
||||
|
|
|
@ -475,9 +475,9 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
D.Diag(diag::warn_drv_avr_stdlib_not_linked);
|
||||
}
|
||||
|
||||
if (SectionAddressData.hasValue()) {
|
||||
std::string DataSectionArg = std::string("-Tdata=0x") +
|
||||
llvm::utohexstr(SectionAddressData.getValue());
|
||||
if (SectionAddressData) {
|
||||
std::string DataSectionArg =
|
||||
std::string("-Tdata=0x") + llvm::utohexstr(*SectionAddressData);
|
||||
CmdArgs.push_back(Args.MakeArgString(DataSectionArg));
|
||||
} else {
|
||||
// We do not have an entry for this CPU in the address mapping table yet.
|
||||
|
|
|
@ -2340,8 +2340,8 @@ void Clang::AddHexagonTargetArgs(const ArgList &Args,
|
|||
|
||||
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
|
||||
CmdArgs.push_back("-mllvm");
|
||||
CmdArgs.push_back(Args.MakeArgString("-hexagon-small-data-threshold=" +
|
||||
Twine(G.getValue())));
|
||||
CmdArgs.push_back(
|
||||
Args.MakeArgString("-hexagon-small-data-threshold=" + Twine(*G)));
|
||||
}
|
||||
|
||||
if (!Args.hasArg(options::OPT_fno_short_enums))
|
||||
|
|
|
@ -2086,8 +2086,8 @@ void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
|
||||
if (BiarchSibling.hasValue()) {
|
||||
M = BiarchSibling.getValue();
|
||||
if (BiarchSibling) {
|
||||
M = *BiarchSibling;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -340,8 +340,8 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
|
|||
CmdArgs.push_back("-pie");
|
||||
|
||||
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
|
||||
CmdArgs.push_back(Args.MakeArgString("-G" + Twine(G.getValue())));
|
||||
UseG0 = G.getValue() == 0;
|
||||
CmdArgs.push_back(Args.MakeArgString("-G" + Twine(*G)));
|
||||
UseG0 = *G == 0;
|
||||
}
|
||||
|
||||
CmdArgs.push_back("-o");
|
||||
|
|
|
@ -725,11 +725,11 @@ static bool getLiteralInfo(SourceRange literalRange,
|
|||
break;
|
||||
}
|
||||
|
||||
if (!UpperU.hasValue() && !UpperL.hasValue())
|
||||
if (!UpperU && !UpperL)
|
||||
UpperU = UpperL = true;
|
||||
else if (UpperU.hasValue() && !UpperL.hasValue())
|
||||
else if (UpperU && !UpperL)
|
||||
UpperL = UpperU;
|
||||
else if (UpperL.hasValue() && !UpperU.hasValue())
|
||||
else if (UpperL && !UpperU)
|
||||
UpperU = UpperL;
|
||||
|
||||
Info.U = *UpperU ? "U" : "u";
|
||||
|
|
|
@ -31,14 +31,14 @@ namespace {
|
|||
/// at position \p Key.
|
||||
void serializeObject(Object &Paren, StringRef Key, Optional<Object> Obj) {
|
||||
if (Obj)
|
||||
Paren[Key] = std::move(Obj.getValue());
|
||||
Paren[Key] = std::move(*Obj);
|
||||
}
|
||||
|
||||
/// Helper function to inject a JSON array \p Array into object \p Paren at
|
||||
/// position \p Key.
|
||||
void serializeArray(Object &Paren, StringRef Key, Optional<Array> Array) {
|
||||
if (Array)
|
||||
Paren[Key] = std::move(Array.getValue());
|
||||
Paren[Key] = std::move(*Array);
|
||||
}
|
||||
|
||||
/// Serialize a \c VersionTuple \p V with the Symbol Graph semantic version
|
||||
|
|
|
@ -115,9 +115,9 @@ bool CompilerInstance::createTarget() {
|
|||
auto TO = std::make_shared<TargetOptions>();
|
||||
TO->Triple = llvm::Triple::normalize(getFrontendOpts().AuxTriple);
|
||||
if (getFrontendOpts().AuxTargetCPU)
|
||||
TO->CPU = getFrontendOpts().AuxTargetCPU.getValue();
|
||||
TO->CPU = *getFrontendOpts().AuxTargetCPU;
|
||||
if (getFrontendOpts().AuxTargetFeatures)
|
||||
TO->FeaturesAsWritten = getFrontendOpts().AuxTargetFeatures.getValue();
|
||||
TO->FeaturesAsWritten = *getFrontendOpts().AuxTargetFeatures;
|
||||
TO->HostTriple = getTarget().getTriple().str();
|
||||
setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO));
|
||||
}
|
||||
|
|
|
@ -1951,8 +1951,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
|
|||
<< "-fdiagnostics-hotness-threshold=";
|
||||
} else {
|
||||
Opts.DiagnosticsHotnessThreshold = *ResultOrErr;
|
||||
if ((!Opts.DiagnosticsHotnessThreshold.hasValue() ||
|
||||
Opts.DiagnosticsHotnessThreshold.getValue() > 0) &&
|
||||
if ((!Opts.DiagnosticsHotnessThreshold ||
|
||||
*Opts.DiagnosticsHotnessThreshold > 0) &&
|
||||
!UsingProfile)
|
||||
Diags.Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
|
||||
<< "-fdiagnostics-hotness-threshold=";
|
||||
|
@ -1968,8 +1968,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
|
|||
<< "-fdiagnostics-misexpect-tolerance=";
|
||||
} else {
|
||||
Opts.DiagnosticsMisExpectTolerance = *ResultOrErr;
|
||||
if ((!Opts.DiagnosticsMisExpectTolerance.hasValue() ||
|
||||
Opts.DiagnosticsMisExpectTolerance.getValue() > 0) &&
|
||||
if ((!Opts.DiagnosticsMisExpectTolerance ||
|
||||
*Opts.DiagnosticsMisExpectTolerance > 0) &&
|
||||
!UsingProfile)
|
||||
Diags.Report(diag::warn_drv_diagnostics_misexpect_requires_pgo)
|
||||
<< "-fdiagnostics-misexpect-tolerance=";
|
||||
|
@ -2578,10 +2578,10 @@ static void GenerateFrontendArgs(const FrontendOptions &Opts,
|
|||
for (const auto &ModuleFile : Opts.ModuleFiles)
|
||||
GenerateArg(Args, OPT_fmodule_file, ModuleFile, SA);
|
||||
|
||||
if (Opts.AuxTargetCPU.hasValue())
|
||||
if (Opts.AuxTargetCPU)
|
||||
GenerateArg(Args, OPT_aux_target_cpu, *Opts.AuxTargetCPU, SA);
|
||||
|
||||
if (Opts.AuxTargetFeatures.hasValue())
|
||||
if (Opts.AuxTargetFeatures)
|
||||
for (const auto &Feature : *Opts.AuxTargetFeatures)
|
||||
GenerateArg(Args, OPT_aux_target_feature, Feature, SA);
|
||||
|
||||
|
|
|
@ -831,12 +831,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
|||
VersionTuple tuple = LangOpts.ObjCRuntime.getVersion();
|
||||
|
||||
unsigned minor = 0;
|
||||
if (tuple.getMinor().hasValue())
|
||||
minor = tuple.getMinor().getValue();
|
||||
if (tuple.getMinor())
|
||||
minor = *tuple.getMinor();
|
||||
|
||||
unsigned subminor = 0;
|
||||
if (tuple.getSubminor().hasValue())
|
||||
subminor = tuple.getSubminor().getValue();
|
||||
if (tuple.getSubminor())
|
||||
subminor = *tuple.getSubminor();
|
||||
|
||||
Builder.defineMacro("__OBJFW_RUNTIME_ABI__",
|
||||
Twine(tuple.getMajor() * 10000 + minor * 100 +
|
||||
|
|
|
@ -549,8 +549,8 @@ Scanner::tryLexIdentifierOrSkipLine(const char *&First, const char *const End) {
|
|||
|
||||
StringRef Scanner::lexIdentifier(const char *&First, const char *const End) {
|
||||
Optional<StringRef> Id = tryLexIdentifierOrSkipLine(First, End);
|
||||
assert(Id.hasValue() && "expected identifier token");
|
||||
return Id.getValue();
|
||||
assert(Id && "expected identifier token");
|
||||
return *Id;
|
||||
}
|
||||
|
||||
bool Scanner::isNextIdentifierOrSkipLine(StringRef Id, const char *&First,
|
||||
|
|
|
@ -209,12 +209,11 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
|
|||
}
|
||||
|
||||
VisibilityMacroDirective *VisMD = cast<VisibilityMacroDirective>(MD);
|
||||
if (!isPublic.hasValue())
|
||||
if (!isPublic)
|
||||
isPublic = VisMD->isPublic();
|
||||
}
|
||||
|
||||
return DefInfo(nullptr, UndefLoc,
|
||||
!isPublic.hasValue() || isPublic.getValue());
|
||||
return DefInfo(nullptr, UndefLoc, !isPublic || *isPublic);
|
||||
}
|
||||
|
||||
const MacroDirective::DefInfo
|
||||
|
|
|
@ -1219,8 +1219,8 @@ void ModuleMap::resolveHeaderDirectives(
|
|||
Module *Mod, llvm::Optional<const FileEntry *> File) const {
|
||||
bool NeedsFramework = false;
|
||||
SmallVector<Module::UnresolvedHeaderDirective, 1> NewHeaders;
|
||||
const auto Size = File ? File.getValue()->getSize() : 0;
|
||||
const auto ModTime = File ? File.getValue()->getModificationTime() : 0;
|
||||
const auto Size = File ? File.value()->getSize() : 0;
|
||||
const auto ModTime = File ? File.value()->getModificationTime() : 0;
|
||||
|
||||
for (auto &Header : Mod->UnresolvedHeaders) {
|
||||
if (File && ((Header.ModTime && Header.ModTime != ModTime) ||
|
||||
|
|
|
@ -1325,11 +1325,11 @@ already_lexed:
|
|||
|
||||
// The last ')' has been reached; return the value if one found or
|
||||
// a diagnostic and a dummy value.
|
||||
if (Result.hasValue()) {
|
||||
OS << Result.getValue();
|
||||
if (Result) {
|
||||
OS << *Result;
|
||||
// For strict conformance to __has_cpp_attribute rules, use 'L'
|
||||
// suffix for dated literals.
|
||||
if (Result.getValue() > 1)
|
||||
if (*Result > 1)
|
||||
OS << 'L';
|
||||
} else {
|
||||
OS << 0;
|
||||
|
|
|
@ -114,8 +114,8 @@ bool PreprocessingRecord::isEntityInFileID(iterator PPEI, FileID FID) {
|
|||
// deserializing it.
|
||||
Optional<bool> IsInFile =
|
||||
ExternalSource->isPreprocessedEntityInFileID(LoadedIndex, FID);
|
||||
if (IsInFile.hasValue())
|
||||
return IsInFile.getValue();
|
||||
if (IsInFile)
|
||||
return *IsInFile;
|
||||
|
||||
// The external source did not provide a definite answer, go and deserialize
|
||||
// the entity to check it.
|
||||
|
|
|
@ -1873,14 +1873,13 @@ void Parser::ParseOMPDeclareTargetClauses(
|
|||
if (IsDeviceTypeClause) {
|
||||
Optional<SimpleClauseData> DevTypeData =
|
||||
parseOpenMPSimpleClause(*this, OMPC_device_type);
|
||||
if (DevTypeData.hasValue()) {
|
||||
if (DevTypeData) {
|
||||
if (DeviceTypeLoc.isValid()) {
|
||||
// We already saw another device_type clause, diagnose it.
|
||||
Diag(DevTypeData.getValue().Loc,
|
||||
diag::warn_omp_more_one_device_type_clause);
|
||||
Diag(DevTypeData->Loc, diag::warn_omp_more_one_device_type_clause);
|
||||
break;
|
||||
}
|
||||
switch (static_cast<OpenMPDeviceType>(DevTypeData.getValue().Type)) {
|
||||
switch (static_cast<OpenMPDeviceType>(DevTypeData->Type)) {
|
||||
case OMPC_DEVICE_TYPE_any:
|
||||
DTCI.DT = OMPDeclareTargetDeclAttr::DT_Any;
|
||||
break;
|
||||
|
@ -2313,9 +2312,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();
|
||||
|
@ -3620,20 +3619,18 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind,
|
|||
if (!Val || ParseOnly)
|
||||
return nullptr;
|
||||
if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
|
||||
(static_cast<DefaultKind>(Val.getValue().Type) == OMP_DEFAULT_private ||
|
||||
static_cast<DefaultKind>(Val.getValue().Type) ==
|
||||
OMP_DEFAULT_firstprivate)) {
|
||||
Diag(Val.getValue().LOpen, diag::err_omp_invalid_dsa)
|
||||
<< getOpenMPClauseName(static_cast<DefaultKind>(Val.getValue().Type) ==
|
||||
(static_cast<DefaultKind>(Val->Type) == OMP_DEFAULT_private ||
|
||||
static_cast<DefaultKind>(Val->Type) == OMP_DEFAULT_firstprivate)) {
|
||||
Diag(Val->LOpen, diag::err_omp_invalid_dsa)
|
||||
<< getOpenMPClauseName(static_cast<DefaultKind>(Val->Type) ==
|
||||
OMP_DEFAULT_private
|
||||
? OMPC_private
|
||||
: OMPC_firstprivate)
|
||||
<< getOpenMPClauseName(OMPC_default) << "5.1";
|
||||
return nullptr;
|
||||
}
|
||||
return Actions.ActOnOpenMPSimpleClause(
|
||||
Kind, Val.getValue().Type, Val.getValue().TypeLoc, Val.getValue().LOpen,
|
||||
Val.getValue().Loc, Val.getValue().RLoc);
|
||||
return Actions.ActOnOpenMPSimpleClause(Kind, Val->Type, Val->TypeLoc,
|
||||
Val->LOpen, Val->Loc, Val->RLoc);
|
||||
}
|
||||
|
||||
/// Parsing of OpenMP clauses like 'ordered'.
|
||||
|
|
|
@ -381,13 +381,12 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = BaseMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
InferredTarget.getValue(), BaseMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
*InferredTarget, BaseMethodTarget, InferredTarget.getPointer());
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
diag::note_implicit_member_target_infer_collision)
|
||||
<< (unsigned)CSM << InferredTarget.getValue() << BaseMethodTarget;
|
||||
<< (unsigned)CSM << *InferredTarget << BaseMethodTarget;
|
||||
}
|
||||
MemberDecl->addAttr(CUDAInvalidTargetAttr::CreateImplicit(Context));
|
||||
return true;
|
||||
|
@ -425,14 +424,12 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = FieldMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
InferredTarget.getValue(), FieldMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
*InferredTarget, FieldMethodTarget, InferredTarget.getPointer());
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
diag::note_implicit_member_target_infer_collision)
|
||||
<< (unsigned)CSM << InferredTarget.getValue()
|
||||
<< FieldMethodTarget;
|
||||
<< (unsigned)CSM << *InferredTarget << FieldMethodTarget;
|
||||
}
|
||||
MemberDecl->addAttr(CUDAInvalidTargetAttr::CreateImplicit(Context));
|
||||
return true;
|
||||
|
@ -444,10 +441,10 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
// If no target was inferred, mark this member as __host__ __device__;
|
||||
// it's the least restrictive option that can be invoked from any target.
|
||||
bool NeedsH = true, NeedsD = true;
|
||||
if (InferredTarget.hasValue()) {
|
||||
if (InferredTarget.getValue() == CFT_Device)
|
||||
if (InferredTarget) {
|
||||
if (*InferredTarget == CFT_Device)
|
||||
NeedsH = false;
|
||||
else if (InferredTarget.getValue() == CFT_Host)
|
||||
else if (*InferredTarget == CFT_Host)
|
||||
NeedsD = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1873,9 +1873,9 @@ static ExprResult SemaBuiltinLaunder(Sema &S, CallExpr *TheCall) {
|
|||
return 2;
|
||||
return llvm::Optional<unsigned>{};
|
||||
}();
|
||||
if (DiagSelect.hasValue()) {
|
||||
if (DiagSelect) {
|
||||
S.Diag(TheCall->getBeginLoc(), diag::err_builtin_launder_invalid_arg)
|
||||
<< DiagSelect.getValue() << TheCall->getSourceRange();
|
||||
<< *DiagSelect << TheCall->getSourceRange();
|
||||
return ExprError();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -15444,9 +15444,9 @@ void Sema::AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(
|
|||
// (3.1) If the allocation function takes an argument of type
|
||||
// std::align_val_t, the storage will have the alignment
|
||||
// specified by the value of this argument.
|
||||
if (AlignmentParam.hasValue() && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
if (AlignmentParam && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
FD->addAttr(AllocAlignAttr::CreateImplicit(
|
||||
Context, ParamIdx(AlignmentParam.getValue(), FD), FD->getLocation()));
|
||||
Context, ParamIdx(*AlignmentParam, FD), FD->getLocation()));
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
|
@ -19102,12 +19102,12 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD,
|
|||
// #pragma omp declare target to(*) device_type(*).
|
||||
// Therefore DevTy having no value does not imply host. The emission status
|
||||
// will be checked again at the end of compilation unit with Final = true.
|
||||
if (DevTy.hasValue())
|
||||
if (DevTy)
|
||||
if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
|
||||
return FunctionEmissionStatus::OMPDiscarded;
|
||||
// If we have an explicit value for the device type, or we are in a target
|
||||
// declare context, we need to emit all extern and used symbols.
|
||||
if (isInOpenMPDeclareTargetContext() || DevTy.hasValue())
|
||||
if (isInOpenMPDeclareTargetContext() || DevTy)
|
||||
if (IsEmittedForExternalSymbol())
|
||||
return FunctionEmissionStatus::Emitted;
|
||||
// Device mode only emits what it must, if it wasn't tagged yet and needed,
|
||||
|
|
|
@ -2673,19 +2673,19 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
|
|||
if (IOSToWatchOSMapping) {
|
||||
if (auto MappedVersion = IOSToWatchOSMapping->map(
|
||||
Version, MinimumWatchOSVersion, None)) {
|
||||
return MappedVersion.getValue();
|
||||
return *MappedVersion;
|
||||
}
|
||||
}
|
||||
|
||||
auto Major = Version.getMajor();
|
||||
auto NewMajor = Major >= 9 ? Major - 7 : 0;
|
||||
if (NewMajor >= 2) {
|
||||
if (Version.getMinor().hasValue()) {
|
||||
if (Version.getSubminor().hasValue())
|
||||
return VersionTuple(NewMajor, Version.getMinor().getValue(),
|
||||
Version.getSubminor().getValue());
|
||||
if (Version.getMinor()) {
|
||||
if (Version.getSubminor())
|
||||
return VersionTuple(NewMajor, *Version.getMinor(),
|
||||
*Version.getSubminor());
|
||||
else
|
||||
return VersionTuple(NewMajor, Version.getMinor().getValue());
|
||||
return VersionTuple(NewMajor, *Version.getMinor());
|
||||
}
|
||||
return VersionTuple(NewMajor);
|
||||
}
|
||||
|
|
|
@ -2274,10 +2274,10 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
|
|||
|
||||
// How many bytes do we want to allocate here?
|
||||
llvm::Optional<llvm::APInt> AllocationSize;
|
||||
if (!ArraySize.hasValue() && !AllocType->isDependentType()) {
|
||||
if (!ArraySize && !AllocType->isDependentType()) {
|
||||
// For non-array operator new, we only want to allocate one element.
|
||||
AllocationSize = SingleEltSize;
|
||||
} else if (KnownArraySize.hasValue() && !AllocType->isDependentType()) {
|
||||
} else if (KnownArraySize && !AllocType->isDependentType()) {
|
||||
// For array operator new, only deal with static array size case.
|
||||
bool Overflow;
|
||||
AllocationSize = llvm::APInt(SizeTyWidth, *KnownArraySize)
|
||||
|
|
|
@ -822,29 +822,29 @@ 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.
|
||||
std::pair<const Expr *, OMPOrderedClause *> getOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Top = getTopOfStackOrNull())
|
||||
if (Top->OrderedRegion.hasValue())
|
||||
return Top->OrderedRegion.getValue();
|
||||
if (Top->OrderedRegion)
|
||||
return *Top->OrderedRegion;
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
/// Returns true, if parent region is ordered (has associated
|
||||
/// '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.
|
||||
std::pair<const Expr *, OMPOrderedClause *>
|
||||
getParentOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Parent = getSecondOnStackOrNull())
|
||||
if (Parent->OrderedRegion.hasValue())
|
||||
return Parent->OrderedRegion.getValue();
|
||||
if (Parent->OrderedRegion)
|
||||
return *Parent->OrderedRegion;
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
/// Marks current region as nowait (it has a 'nowait' clause).
|
||||
|
@ -7653,9 +7653,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));
|
||||
|
@ -7761,21 +7761,20 @@ bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
|
|||
bool IsConstZero = Result && !Result->getBoolValue();
|
||||
|
||||
// != with increment is treated as <; != with decrement is treated as >
|
||||
if (!TestIsLessOp.hasValue())
|
||||
if (!TestIsLessOp)
|
||||
TestIsLessOp = IsConstPos || (IsUnsigned && !Subtract);
|
||||
if (UB &&
|
||||
(IsConstZero || (TestIsLessOp.getValue()
|
||||
? (IsConstNeg || (IsUnsigned && Subtract))
|
||||
: (IsConstPos || (IsUnsigned && !Subtract))))) {
|
||||
if (UB && (IsConstZero ||
|
||||
(*TestIsLessOp ? (IsConstNeg || (IsUnsigned && Subtract))
|
||||
: (IsConstPos || (IsUnsigned && !Subtract))))) {
|
||||
SemaRef.Diag(NewStep->getExprLoc(),
|
||||
diag::err_omp_loop_incr_not_compatible)
|
||||
<< LCDecl << TestIsLessOp.getValue() << NewStep->getSourceRange();
|
||||
<< LCDecl << *TestIsLessOp << NewStep->getSourceRange();
|
||||
SemaRef.Diag(ConditionLoc,
|
||||
diag::note_omp_loop_cond_requres_compatible_incr)
|
||||
<< TestIsLessOp.getValue() << ConditionSrcRange;
|
||||
<< *TestIsLessOp << ConditionSrcRange;
|
||||
return true;
|
||||
}
|
||||
if (TestIsLessOp.getValue() == Subtract) {
|
||||
if (*TestIsLessOp == Subtract) {
|
||||
NewStep =
|
||||
SemaRef.CreateBuiltinUnaryOp(NewStep->getExprLoc(), UO_Minus, NewStep)
|
||||
.get();
|
||||
|
@ -8530,8 +8529,8 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
|
|||
UBVal = MinUB.get();
|
||||
}
|
||||
}
|
||||
Expr *UBExpr = TestIsLessOp.getValue() ? UBVal : LBVal;
|
||||
Expr *LBExpr = TestIsLessOp.getValue() ? LBVal : UBVal;
|
||||
Expr *UBExpr = *TestIsLessOp ? UBVal : LBVal;
|
||||
Expr *LBExpr = *TestIsLessOp ? LBVal : UBVal;
|
||||
Expr *Upper = tryBuildCapture(SemaRef, UBExpr, Captures).get();
|
||||
Expr *Lower = tryBuildCapture(SemaRef, LBExpr, Captures).get();
|
||||
if (!Upper || !Lower)
|
||||
|
@ -8594,12 +8593,12 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
|
|||
// init value.
|
||||
Expr *MinExpr = nullptr;
|
||||
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();
|
||||
Expr *LBExpr = *TestIsLessOp ? LB : UB;
|
||||
Expr *UBExpr = *TestIsLessOp ? UB : LB;
|
||||
bool LBNonRect =
|
||||
*TestIsLessOp ? InitDependOnLC.has_value() : CondDependOnLC.has_value();
|
||||
bool UBNonRect =
|
||||
*TestIsLessOp ? CondDependOnLC.has_value() : InitDependOnLC.has_value();
|
||||
Expr *Lower =
|
||||
LBNonRect ? LBExpr : tryBuildCapture(SemaRef, LBExpr, Captures).get();
|
||||
Expr *Upper =
|
||||
|
@ -8721,11 +8720,11 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
|
|||
if (!NewLB.isUsable() || !NewUB.isUsable())
|
||||
return nullptr;
|
||||
|
||||
ExprResult CondExpr = SemaRef.BuildBinOp(
|
||||
S, DefaultLoc,
|
||||
TestIsLessOp.getValue() ? (TestIsStrictOp ? BO_LT : BO_LE)
|
||||
: (TestIsStrictOp ? BO_GT : BO_GE),
|
||||
NewLB.get(), NewUB.get());
|
||||
ExprResult CondExpr =
|
||||
SemaRef.BuildBinOp(S, DefaultLoc,
|
||||
*TestIsLessOp ? (TestIsStrictOp ? BO_LT : BO_LE)
|
||||
: (TestIsStrictOp ? BO_GT : BO_GE),
|
||||
NewLB.get(), NewUB.get());
|
||||
if (CondExpr.isUsable()) {
|
||||
if (!SemaRef.Context.hasSameUnqualifiedType(CondExpr.get()->getType(),
|
||||
SemaRef.Context.BoolTy))
|
||||
|
@ -8800,12 +8799,10 @@ Expr *OpenMPIterationSpaceChecker::buildOrderedLoopData(
|
|||
!SemaRef.getLangOpts().CPlusPlus)
|
||||
return nullptr;
|
||||
// Upper - Lower
|
||||
Expr *Upper = TestIsLessOp.getValue()
|
||||
? Cnt
|
||||
: tryBuildCapture(SemaRef, LB, Captures).get();
|
||||
Expr *Lower = TestIsLessOp.getValue()
|
||||
? tryBuildCapture(SemaRef, LB, Captures).get()
|
||||
: Cnt;
|
||||
Expr *Upper =
|
||||
*TestIsLessOp ? Cnt : tryBuildCapture(SemaRef, LB, Captures).get();
|
||||
Expr *Lower =
|
||||
*TestIsLessOp ? tryBuildCapture(SemaRef, LB, Captures).get() : Cnt;
|
||||
if (!Upper || !Lower)
|
||||
return nullptr;
|
||||
|
||||
|
@ -22180,27 +22177,27 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
|
|||
auto *VD = cast<ValueDecl>(ND);
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getDevType() != DTCI.DT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
if (ActiveAttr && (*ActiveAttr)->getDevType() != DTCI.DT &&
|
||||
(*ActiveAttr)->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_device_type_mismatch)
|
||||
<< OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(DTCI.DT)
|
||||
<< OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(
|
||||
ActiveAttr.getValue()->getDevType());
|
||||
ActiveAttr.value()->getDevType());
|
||||
return;
|
||||
}
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getMapType() != MT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
if (ActiveAttr && (*ActiveAttr)->getMapType() != MT &&
|
||||
(*ActiveAttr)->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_declare_target_to_and_link) << ND;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() == Level)
|
||||
if (ActiveAttr && (*ActiveAttr)->getLevel() == Level)
|
||||
return;
|
||||
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = *DTCI.Indirect;
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
}
|
||||
|
@ -22294,13 +22291,13 @@ void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
|
|||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
unsigned Level = DeclareTargetNesting.size();
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() >= Level)
|
||||
if (ActiveAttr && (*ActiveAttr)->getLevel() >= Level)
|
||||
return;
|
||||
DeclareTargetContextInfo &DTCI = DeclareTargetNesting.back();
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = *DTCI.Indirect;
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
}
|
||||
|
|
|
@ -469,8 +469,8 @@ static void instantiateOMPDeclareVariantAttr(
|
|||
if (!DeclVarData)
|
||||
return;
|
||||
|
||||
E = DeclVarData.getValue().second;
|
||||
FD = DeclVarData.getValue().first;
|
||||
E = DeclVarData->second;
|
||||
FD = DeclVarData->first;
|
||||
|
||||
if (auto *VariantDRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) {
|
||||
if (auto *VariantFD = dyn_cast<FunctionDecl>(VariantDRE->getDecl())) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -766,10 +766,10 @@ void VariadicMethodTypeChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
|||
continue;
|
||||
|
||||
// Generate only one error node to use for all bug reports.
|
||||
if (!errorNode.hasValue())
|
||||
if (!errorNode)
|
||||
errorNode = C.generateNonFatalErrorNode();
|
||||
|
||||
if (!errorNode.getValue())
|
||||
if (!*errorNode)
|
||||
continue;
|
||||
|
||||
SmallString<128> sbuf;
|
||||
|
@ -786,8 +786,8 @@ void VariadicMethodTypeChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
|||
ArgTy.print(os, C.getLangOpts());
|
||||
os << "'";
|
||||
|
||||
auto R = std::make_unique<PathSensitiveBugReport>(*BT, os.str(),
|
||||
errorNode.getValue());
|
||||
auto R =
|
||||
std::make_unique<PathSensitiveBugReport>(*BT, os.str(), *errorNode);
|
||||
R->addRange(msg.getArgSourceRange(I));
|
||||
C.emitReport(std::move(R));
|
||||
}
|
||||
|
|
|
@ -272,12 +272,12 @@ ProgramStateRef GTestChecker::assumeValuesEqual(SVal Val1, SVal Val2,
|
|||
CheckerContext &C) {
|
||||
auto DVal1 = Val1.getAs<DefinedOrUnknownSVal>();
|
||||
auto DVal2 = Val2.getAs<DefinedOrUnknownSVal>();
|
||||
if (!DVal1.hasValue() || !DVal2.hasValue())
|
||||
if (!DVal1 || !DVal2)
|
||||
return State;
|
||||
|
||||
auto ValuesEqual =
|
||||
C.getSValBuilder().evalEQ(State, *DVal1, *DVal2).getAs<DefinedSVal>();
|
||||
if (!ValuesEqual.hasValue())
|
||||
if (!ValuesEqual)
|
||||
return State;
|
||||
|
||||
State = C.getConstraintManager().assume(State, *ValuesEqual, true);
|
||||
|
|
|
@ -1190,8 +1190,8 @@ MallocChecker::performKernelMalloc(const CallEvent &Call, CheckerContext &C,
|
|||
|
||||
NonLoc Flags = V.castAs<NonLoc>();
|
||||
NonLoc ZeroFlag = C.getSValBuilder()
|
||||
.makeIntVal(KernelZeroFlagVal.getValue(), FlagsEx->getType())
|
||||
.castAs<NonLoc>();
|
||||
.makeIntVal(*KernelZeroFlagVal, FlagsEx->getType())
|
||||
.castAs<NonLoc>();
|
||||
SVal MaskedFlagsUC = C.getSValBuilder().evalBinOpNN(State, BO_And,
|
||||
Flags, ZeroFlag,
|
||||
FlagsEx->getType());
|
||||
|
@ -1238,8 +1238,8 @@ void MallocChecker::checkKernelMalloc(const CallEvent &Call,
|
|||
ProgramStateRef State = C.getState();
|
||||
llvm::Optional<ProgramStateRef> MaybeState =
|
||||
performKernelMalloc(Call, C, State);
|
||||
if (MaybeState.hasValue())
|
||||
State = MaybeState.getValue();
|
||||
if (MaybeState)
|
||||
State = *MaybeState;
|
||||
else
|
||||
State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State,
|
||||
AF_Malloc);
|
||||
|
@ -3571,13 +3571,13 @@ void MallocChecker::printState(raw_ostream &Out, ProgramStateRef State,
|
|||
const RefState *RefS = State->get<RegionState>(I.getKey());
|
||||
AllocationFamily Family = RefS->getAllocationFamily();
|
||||
Optional<MallocChecker::CheckKind> CheckKind = getCheckIfTracked(Family);
|
||||
if (!CheckKind.hasValue())
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
if (!CheckKind)
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
|
||||
I.getKey()->dumpToStream(Out);
|
||||
Out << " : ";
|
||||
I.getData().dump(Out);
|
||||
if (CheckKind.hasValue())
|
||||
if (CheckKind)
|
||||
Out << " (" << CheckNames[*CheckKind].getName() << ")";
|
||||
Out << NL;
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ void NonNullParamChecker::checkPreCall(const CallEvent &Call,
|
|||
if (!DV)
|
||||
continue;
|
||||
|
||||
assert(!HasRefTypeParam || isa<Loc>(DV.getValue()));
|
||||
assert(!HasRefTypeParam || isa<Loc>(*DV));
|
||||
|
||||
// Process the case when the argument is not a location.
|
||||
if (ExpectedToBeNonNull && !isa<Loc>(DV.getValue())) {
|
||||
if (ExpectedToBeNonNull && !isa<Loc>(*DV)) {
|
||||
// If the argument is a union type, we want to handle a potential
|
||||
// transparent_union GCC extension.
|
||||
if (!ArgE)
|
||||
|
|
|
@ -234,7 +234,8 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext &C,
|
|||
}
|
||||
NonLoc oflags = V.castAs<NonLoc>();
|
||||
NonLoc ocreateFlag = C.getSValBuilder()
|
||||
.makeIntVal(Val_O_CREAT.getValue(), oflagsEx->getType()).castAs<NonLoc>();
|
||||
.makeIntVal(*Val_O_CREAT, oflagsEx->getType())
|
||||
.castAs<NonLoc>();
|
||||
SVal maskedFlagsUC = C.getSValBuilder().evalBinOpNN(state, BO_And,
|
||||
oflags, ocreateFlag,
|
||||
oflagsEx->getType());
|
||||
|
|
|
@ -77,8 +77,8 @@ AnalyzerOptions::getExplorationStrategy() const {
|
|||
.Case("bfs_block_dfs_contents",
|
||||
ExplorationStrategyKind::BFSBlockDFSContents)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "User mode is invalid.");
|
||||
return K.getValue();
|
||||
assert(K && "User mode is invalid.");
|
||||
return *K;
|
||||
}
|
||||
|
||||
CTUPhase1InliningKind AnalyzerOptions::getCTUPhase1Inlining() const {
|
||||
|
@ -88,8 +88,8 @@ CTUPhase1InliningKind AnalyzerOptions::getCTUPhase1Inlining() const {
|
|||
.Case("small", CTUPhase1InliningKind::Small)
|
||||
.Case("all", CTUPhase1InliningKind::All)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "CTU inlining mode is invalid.");
|
||||
return K.getValue();
|
||||
assert(K && "CTU inlining mode is invalid.");
|
||||
return *K;
|
||||
}
|
||||
|
||||
IPAKind AnalyzerOptions::getIPAMode() const {
|
||||
|
@ -100,9 +100,9 @@ IPAKind AnalyzerOptions::getIPAMode() const {
|
|||
.Case("dynamic", IPAK_DynamicDispatch)
|
||||
.Case("dynamic-bifurcate", IPAK_DynamicDispatchBifurcate)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "IPA Mode is invalid.");
|
||||
assert(K && "IPA Mode is invalid.");
|
||||
|
||||
return K.getValue();
|
||||
return *K;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -2949,8 +2949,8 @@ PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
|
|||
|
||||
PathDiagnosticLocation Loc(Cond, SM, LCtx);
|
||||
auto event = std::make_shared<PathDiagnosticEventPiece>(Loc, Message);
|
||||
if (shouldPrune.hasValue())
|
||||
event->setPrunable(shouldPrune.getValue());
|
||||
if (shouldPrune)
|
||||
event->setPrunable(*shouldPrune);
|
||||
return event;
|
||||
}
|
||||
|
||||
|
@ -3084,9 +3084,9 @@ bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream &Out,
|
|||
Out << (TookTrue ? "not equal to 0" : "0");
|
||||
} else {
|
||||
if (Ty->isBooleanType())
|
||||
Out << (IntValue.getValue()->getBoolValue() ? "true" : "false");
|
||||
Out << (IntValue.value()->getBoolValue() ? "true" : "false");
|
||||
else
|
||||
Out << *IntValue.getValue();
|
||||
Out << *IntValue.value();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3279,10 +3279,10 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor(
|
|||
|
||||
// And check for satisfiability
|
||||
Optional<bool> IsSAT = RefutationSolver->check();
|
||||
if (!IsSAT.hasValue())
|
||||
if (!IsSAT)
|
||||
return;
|
||||
|
||||
if (!IsSAT.getValue())
|
||||
if (!*IsSAT)
|
||||
BR.markInvalid("Infeasible constraints", EndPathNode->getLocationContext());
|
||||
}
|
||||
|
||||
|
|
|
@ -1015,8 +1015,8 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
|
|||
|
||||
// Check if this function has been marked as non-inlinable.
|
||||
Optional<bool> MayInline = Engine.FunctionSummaries->mayInline(D);
|
||||
if (MayInline.hasValue()) {
|
||||
if (!MayInline.getValue())
|
||||
if (MayInline) {
|
||||
if (!*MayInline)
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
|
|
@ -407,11 +407,11 @@ void PlistPrinter::ReportMacroExpansions(raw_ostream &o, unsigned indent) {
|
|||
|
||||
// Output the macro name.
|
||||
Indent(o, indent) << "<key>name</key>";
|
||||
EmitString(o, MacroName.getValue()) << '\n';
|
||||
EmitString(o, *MacroName) << '\n';
|
||||
|
||||
// Output what it expands into.
|
||||
Indent(o, indent) << "<key>expansion</key>";
|
||||
EmitString(o, ExpansionText.getValue()) << '\n';
|
||||
EmitString(o, *ExpansionText) << '\n';
|
||||
|
||||
// Finish up.
|
||||
--indent;
|
||||
|
|
|
@ -114,11 +114,11 @@ bool RVVType::verifyType() const {
|
|||
return false;
|
||||
if (isScalar())
|
||||
return true;
|
||||
if (!Scale.hasValue())
|
||||
if (!Scale)
|
||||
return false;
|
||||
if (isFloat() && ElementBitwidth == 8)
|
||||
return false;
|
||||
unsigned V = Scale.getValue();
|
||||
unsigned V = *Scale;
|
||||
switch (ElementBitwidth) {
|
||||
case 1:
|
||||
case 8:
|
||||
|
@ -799,10 +799,10 @@ RVVType::computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
|
|||
RVVTypes Types;
|
||||
for (const PrototypeDescriptor &Proto : Prototype) {
|
||||
auto T = computeType(BT, Log2LMUL, Proto);
|
||||
if (!T.hasValue())
|
||||
if (!T)
|
||||
return llvm::None;
|
||||
// Record legal type index
|
||||
Types.push_back(T.getValue());
|
||||
Types.push_back(*T);
|
||||
}
|
||||
return Types;
|
||||
}
|
||||
|
|
|
@ -179,9 +179,9 @@ static std::string getReplacementErrString(replacement_error Err) {
|
|||
|
||||
std::string ReplacementError::message() const {
|
||||
std::string Message = getReplacementErrString(Err);
|
||||
if (NewReplacement.hasValue())
|
||||
if (NewReplacement)
|
||||
Message += "\nNew replacement: " + NewReplacement->toString();
|
||||
if (ExistingReplacement.hasValue())
|
||||
if (ExistingReplacement)
|
||||
Message += "\nExisting replacement: " + ExistingReplacement->toString();
|
||||
return Message;
|
||||
}
|
||||
|
|
|
@ -406,18 +406,18 @@ int clang_main(int Argc, char **Argv) {
|
|||
if (ClangCLMode) {
|
||||
// Arguments in "CL" are prepended.
|
||||
llvm::Optional<std::string> OptCL = llvm::sys::Process::GetEnv("CL");
|
||||
if (OptCL.hasValue()) {
|
||||
if (OptCL) {
|
||||
SmallVector<const char *, 8> PrependedOpts;
|
||||
getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts);
|
||||
getCLEnvVarOptions(*OptCL, Saver, PrependedOpts);
|
||||
|
||||
// Insert right after the program name to prepend to the argument list.
|
||||
Args.insert(Args.begin() + 1, PrependedOpts.begin(), PrependedOpts.end());
|
||||
}
|
||||
// Arguments in "_CL_" are appended.
|
||||
llvm::Optional<std::string> Opt_CL_ = llvm::sys::Process::GetEnv("_CL_");
|
||||
if (Opt_CL_.hasValue()) {
|
||||
if (Opt_CL_) {
|
||||
SmallVector<const char *, 8> AppendedOpts;
|
||||
getCLEnvVarOptions(Opt_CL_.getValue(), Saver, AppendedOpts);
|
||||
getCLEnvVarOptions(*Opt_CL_, Saver, AppendedOpts);
|
||||
|
||||
// Insert at the end of the argument list to append.
|
||||
Args.append(AppendedOpts.begin(), AppendedOpts.end());
|
||||
|
|
|
@ -536,9 +536,9 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
|
|||
TLEnd = CXXUnit->top_level_end();
|
||||
TL != TLEnd; ++TL) {
|
||||
const Optional<bool> V = handleDeclForVisitation(*TL);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
return V.getValue();
|
||||
return *V;
|
||||
}
|
||||
} else if (VisitDeclContext(
|
||||
CXXUnit->getASTContext().getTranslationUnitDecl()))
|
||||
|
@ -641,9 +641,9 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
|
|||
if (OMD->isSynthesizedAccessorStub())
|
||||
continue;
|
||||
const Optional<bool> V = handleDeclForVisitation(D);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
return V.getValue();
|
||||
return *V;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -675,9 +675,9 @@ Optional<bool> CursorVisitor::handleDeclForVisitation(const Decl *D) {
|
|||
}
|
||||
|
||||
const Optional<bool> V = shouldVisitCursor(Cursor);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
return None;
|
||||
if (!V.getValue())
|
||||
if (!*V)
|
||||
return false;
|
||||
if (Visit(Cursor, true))
|
||||
return true;
|
||||
|
@ -1074,9 +1074,9 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
|
|||
I != E; ++I) {
|
||||
CXCursor Cursor = MakeCXCursor(*I, TU, RegionOfInterest);
|
||||
const Optional<bool> &V = shouldVisitCursor(Cursor);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
if (!V.getValue())
|
||||
if (!*V)
|
||||
return false;
|
||||
if (Visit(Cursor, true))
|
||||
return true;
|
||||
|
@ -8178,13 +8178,13 @@ static CXVersion convertVersion(VersionTuple In) {
|
|||
Out.Major = In.getMajor();
|
||||
|
||||
Optional<unsigned> Minor = In.getMinor();
|
||||
if (Minor.hasValue())
|
||||
if (Minor)
|
||||
Out.Minor = *Minor;
|
||||
else
|
||||
return Out;
|
||||
|
||||
Optional<unsigned> Subminor = In.getSubminor();
|
||||
if (Subminor.hasValue())
|
||||
if (Subminor)
|
||||
Out.Subminor = *Subminor;
|
||||
|
||||
return Out;
|
||||
|
|
|
@ -449,27 +449,27 @@ TEST(ParserTest, ParseMultiline) {
|
|||
)
|
||||
)matcher";
|
||||
Diagnostics Error;
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error));
|
||||
}
|
||||
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
@ -181,14 +181,14 @@ EMPTY zz
|
|||
// A b cd ef gh
|
||||
// zz
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(3, 10)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(3, 10)).getValue());
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(3, 10)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(3, 10)));
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(3, 19)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(3, 19)).getValue());
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(3, 19)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(3, 19)));
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 1)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 1)).getValue());
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(4, 1)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(4, 1)));
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, TransitiveExpansions) {
|
||||
|
@ -200,10 +200,10 @@ TEST_F(MacroExpansionContextTest, TransitiveExpansions) {
|
|||
// After preprocessing:
|
||||
// A b cd ) 1 ef gh
|
||||
|
||||
EXPECT_EQ("WOOF", Ctx->getOriginalText(at(4, 10)).getValue());
|
||||
EXPECT_EQ("WOOF", *Ctx->getOriginalText(at(4, 10)));
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 18)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 18)).getValue());
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(4, 18)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(4, 18)));
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, MacroFunctions) {
|
||||
|
@ -219,17 +219,17 @@ TEST_F(MacroExpansionContextTest, MacroFunctions) {
|
|||
// WOOF( ) ) ) 1
|
||||
// bar barr( ) ) ) 1( ) ) ) 1),,),')
|
||||
|
||||
EXPECT_EQ("$$ ef ()))1", Ctx->getExpandedText(at(4, 10)).getValue());
|
||||
EXPECT_EQ("WOOF($$ ef)", Ctx->getOriginalText(at(4, 10)).getValue());
|
||||
EXPECT_EQ("$$ ef ()))1", *Ctx->getExpandedText(at(4, 10)));
|
||||
EXPECT_EQ("WOOF($$ ef)", *Ctx->getOriginalText(at(4, 10)));
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 22)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 22)).getValue());
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 22)).value());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 22)).value());
|
||||
|
||||
EXPECT_EQ("WOOF ()))1", Ctx->getExpandedText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("WOOF(WOOF)", Ctx->getOriginalText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("WOOF ()))1", Ctx->getExpandedText(at(5, 3)).value());
|
||||
EXPECT_EQ("WOOF(WOOF)", Ctx->getOriginalText(at(5, 3)).value());
|
||||
|
||||
EXPECT_EQ("bar barr ()))1()))1", Ctx->getExpandedText(at(6, 3)).getValue());
|
||||
EXPECT_EQ("WOOF(WOOF(bar barr))", Ctx->getOriginalText(at(6, 3)).getValue());
|
||||
EXPECT_EQ("bar barr ()))1()))1", Ctx->getExpandedText(at(6, 3)).value());
|
||||
EXPECT_EQ("WOOF(WOOF(bar barr))", Ctx->getOriginalText(at(6, 3)).value());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, VariadicMacros) {
|
||||
|
@ -251,24 +251,23 @@ TEST_F(MacroExpansionContextTest, VariadicMacros) {
|
|||
// fprintf (stderr, "success!\n" );
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n",))",
|
||||
Ctx->getExpandedText(at(3, 3)).getValue());
|
||||
Ctx->getExpandedText(at(3, 3)).value());
|
||||
EXPECT_EQ(R"(eprintf("success!\n", ))",
|
||||
Ctx->getOriginalText(at(3, 3)).getValue());
|
||||
Ctx->getOriginalText(at(3, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n",))",
|
||||
Ctx->getExpandedText(at(4, 3)).getValue());
|
||||
EXPECT_EQ(R"(eprintf("success!\n"))",
|
||||
Ctx->getOriginalText(at(4, 3)).getValue());
|
||||
Ctx->getExpandedText(at(4, 3)).value());
|
||||
EXPECT_EQ(R"(eprintf("success!\n"))", Ctx->getOriginalText(at(4, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n"))",
|
||||
Ctx->getExpandedText(at(8, 3)).getValue());
|
||||
Ctx->getExpandedText(at(8, 3)).value());
|
||||
EXPECT_EQ(R"(eprintf2("success!\n", ))",
|
||||
Ctx->getOriginalText(at(8, 3)).getValue());
|
||||
Ctx->getOriginalText(at(8, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n"))",
|
||||
Ctx->getExpandedText(at(9, 3)).getValue());
|
||||
Ctx->getExpandedText(at(9, 3)).value());
|
||||
EXPECT_EQ(R"(eprintf2("success!\n"))",
|
||||
Ctx->getOriginalText(at(9, 3)).getValue());
|
||||
Ctx->getOriginalText(at(9, 3)).value());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, ConcatenationMacros) {
|
||||
|
@ -286,12 +285,12 @@ TEST_F(MacroExpansionContextTest, ConcatenationMacros) {
|
|||
// };
|
||||
|
||||
EXPECT_EQ(R"({"quit",quit_command })",
|
||||
Ctx->getExpandedText(at(4, 5)).getValue());
|
||||
EXPECT_EQ("COMMAND(quit)", Ctx->getOriginalText(at(4, 5)).getValue());
|
||||
Ctx->getExpandedText(at(4, 5)).value());
|
||||
EXPECT_EQ("COMMAND(quit)", Ctx->getOriginalText(at(4, 5)).value());
|
||||
|
||||
EXPECT_EQ(R"({"help",help_command })",
|
||||
Ctx->getExpandedText(at(5, 5)).getValue());
|
||||
EXPECT_EQ("COMMAND(help)", Ctx->getOriginalText(at(5, 5)).getValue());
|
||||
Ctx->getExpandedText(at(5, 5)).value());
|
||||
EXPECT_EQ("COMMAND(help)", Ctx->getOriginalText(at(5, 5)).value());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, StringizingMacros) {
|
||||
|
@ -316,14 +315,14 @@ TEST_F(MacroExpansionContextTest, StringizingMacros) {
|
|||
|
||||
EXPECT_EQ(
|
||||
R"(do {if (x ==0)fprintf (stderr ,"Warning: ""x == 0""\n");}while (0))",
|
||||
Ctx->getExpandedText(at(6, 3)).getValue());
|
||||
EXPECT_EQ("WARN_IF (x == 0)", Ctx->getOriginalText(at(6, 3)).getValue());
|
||||
Ctx->getExpandedText(at(6, 3)).value());
|
||||
EXPECT_EQ("WARN_IF (x == 0)", Ctx->getOriginalText(at(6, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"("foo")", Ctx->getExpandedText(at(11, 3)).getValue());
|
||||
EXPECT_EQ("str (foo)", Ctx->getOriginalText(at(11, 3)).getValue());
|
||||
EXPECT_EQ(R"("foo")", Ctx->getExpandedText(at(11, 3)).value());
|
||||
EXPECT_EQ("str (foo)", Ctx->getOriginalText(at(11, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"("4")", Ctx->getExpandedText(at(12, 3)).getValue());
|
||||
EXPECT_EQ("xstr (foo)", Ctx->getOriginalText(at(12, 3)).getValue());
|
||||
EXPECT_EQ(R"("4")", Ctx->getExpandedText(at(12, 3)).value());
|
||||
EXPECT_EQ("xstr (foo)", Ctx->getOriginalText(at(12, 3)).value());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, StringizingVariadicMacros) {
|
||||
|
@ -352,18 +351,18 @@ TEST_F(MacroExpansionContextTest, StringizingVariadicMacros) {
|
|||
|
||||
EXPECT_EQ("zz !apple !x *apple !x !**y (apple )zz !apple !x *apple !x !**y "
|
||||
"(appleapple ))))",
|
||||
Ctx->getExpandedText(at(11, 3)).getValue());
|
||||
EXPECT_EQ("q(g)", Ctx->getOriginalText(at(11, 3)).getValue());
|
||||
Ctx->getExpandedText(at(11, 3)).value());
|
||||
EXPECT_EQ("q(g)", Ctx->getOriginalText(at(11, 3)).value());
|
||||
|
||||
EXPECT_EQ(R"res("apple"(apple )"apple"(appleapple )))))res",
|
||||
Ctx->getExpandedText(at(12, 3)).getValue());
|
||||
EXPECT_EQ("q(xstr)", Ctx->getOriginalText(at(12, 3)).getValue());
|
||||
Ctx->getExpandedText(at(12, 3)).value());
|
||||
EXPECT_EQ("q(xstr)", Ctx->getOriginalText(at(12, 3)).value());
|
||||
|
||||
EXPECT_EQ("zz !*)!x )!**y ", Ctx->getExpandedText(at(13, 3)).getValue());
|
||||
EXPECT_EQ("g(RParen2x)", Ctx->getOriginalText(at(13, 3)).getValue());
|
||||
EXPECT_EQ("zz !*)!x )!**y ", Ctx->getExpandedText(at(13, 3)).value());
|
||||
EXPECT_EQ("g(RParen2x)", Ctx->getOriginalText(at(13, 3)).value());
|
||||
|
||||
EXPECT_EQ("!))*))", Ctx->getExpandedText(at(14, 3)).getValue());
|
||||
EXPECT_EQ("f( RParen2x )", Ctx->getOriginalText(at(14, 3)).getValue());
|
||||
EXPECT_EQ("!))*))", Ctx->getExpandedText(at(14, 3)).value());
|
||||
EXPECT_EQ("f( RParen2x )", Ctx->getOriginalText(at(14, 3)).value());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, RedefUndef) {
|
||||
|
@ -381,15 +380,15 @@ TEST_F(MacroExpansionContextTest, RedefUndef) {
|
|||
// Hi(Hi)
|
||||
|
||||
// FIXME: Extra space follows every identifier.
|
||||
EXPECT_EQ("Welcome Adam ", Ctx->getExpandedText(at(3, 3)).getValue());
|
||||
EXPECT_EQ("Hi(Adam)", Ctx->getOriginalText(at(3, 3)).getValue());
|
||||
EXPECT_EQ("Welcome Adam ", Ctx->getExpandedText(at(3, 3)).value());
|
||||
EXPECT_EQ("Hi(Adam)", Ctx->getOriginalText(at(3, 3)).value());
|
||||
|
||||
EXPECT_EQ("Willkommen ", Ctx->getExpandedText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("Hi", Ctx->getOriginalText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("Willkommen ", Ctx->getExpandedText(at(5, 3)).value());
|
||||
EXPECT_EQ("Hi", Ctx->getOriginalText(at(5, 3)).value());
|
||||
|
||||
// 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) {
|
||||
|
@ -411,12 +410,11 @@ TEST_F(MacroExpansionContextTest, UnbalacedParenthesis) {
|
|||
// fun();
|
||||
// int x = ((1, fun(), 1, fun(), 1 ));
|
||||
|
||||
EXPECT_EQ("fun ()", Ctx->getExpandedText(at(8, 3)).getValue());
|
||||
EXPECT_EQ("applyInt )", Ctx->getOriginalText(at(8, 3)).getValue());
|
||||
EXPECT_EQ("fun ()", Ctx->getExpandedText(at(8, 3)).value());
|
||||
EXPECT_EQ("applyInt )", Ctx->getOriginalText(at(8, 3)).value());
|
||||
|
||||
EXPECT_EQ("((1,fun (),1,fun (),1",
|
||||
Ctx->getExpandedText(at(13, 12)).getValue());
|
||||
EXPECT_EQ("f(f(1))", Ctx->getOriginalText(at(13, 12)).getValue());
|
||||
EXPECT_EQ("((1,fun (),1,fun (),1", Ctx->getExpandedText(at(13, 12)).value());
|
||||
EXPECT_EQ("f(f(1))", Ctx->getOriginalText(at(13, 12)).value());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -258,12 +258,12 @@ 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());
|
||||
if (TestConsumer.result().hasValue()) {
|
||||
EXPECT_TRUE(TestConsumer.result().has_value());
|
||||
if (TestConsumer.result()) {
|
||||
EXPECT_TRUE(*TestConsumer.result());
|
||||
}
|
||||
if ((TestConsumer.result().hasValue() && !TestConsumer.result().getValue()) ||
|
||||
!TestConsumer.result().hasValue())
|
||||
if ((TestConsumer.result() && !*TestConsumer.result()) ||
|
||||
!TestConsumer.result())
|
||||
TestConsumer.printUnmetExpectations(llvm::outs());
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -200,9 +200,9 @@ 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 &FE = *FoundFile;
|
||||
auto FI = Search.getExistingFileInfo(FE);
|
||||
EXPECT_TRUE(FI);
|
||||
EXPECT_TRUE(FI->IsValid);
|
||||
|
@ -269,9 +269,9 @@ 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 &FE = *FoundFile;
|
||||
auto FI = Search.getExistingFileInfo(FE);
|
||||
EXPECT_TRUE(FI);
|
||||
EXPECT_TRUE(FI->IsValid);
|
||||
|
|
|
@ -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 *DRecordType = dyn_cast<RecordType>(LDT);
|
||||
|
|
|
@ -118,18 +118,18 @@ static bool checkReplacementError(llvm::Error &&Error,
|
|||
OS << "Unexpected error code: " << int(RE.get()) << "\n";
|
||||
if (ExpectedExisting != RE.getExistingReplacement()) {
|
||||
OS << "Expected Existing != Actual Existing.\n";
|
||||
if (ExpectedExisting.hasValue())
|
||||
if (ExpectedExisting)
|
||||
OS << "Expected existing replacement: " << ExpectedExisting->toString()
|
||||
<< "\n";
|
||||
if (RE.getExistingReplacement().hasValue())
|
||||
if (RE.getExistingReplacement())
|
||||
OS << "Actual existing replacement: "
|
||||
<< RE.getExistingReplacement()->toString() << "\n";
|
||||
}
|
||||
if (ExpectedNew != RE.getNewReplacement()) {
|
||||
OS << "Expected New != Actual New.\n";
|
||||
if (ExpectedNew.hasValue())
|
||||
if (ExpectedNew)
|
||||
OS << "Expected new replacement: " << ExpectedNew->toString() << "\n";
|
||||
if (RE.getNewReplacement().hasValue())
|
||||
if (RE.getNewReplacement())
|
||||
OS << "Actual new replacement: " << RE.getNewReplacement()->toString()
|
||||
<< "\n";
|
||||
}
|
||||
|
|
|
@ -217,22 +217,22 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
|||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Int8, Log2LMUL,
|
||||
PrototypeDescriptor::Mask);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
if (T)
|
||||
printType(*T);
|
||||
}
|
||||
// Print RVV int/float types.
|
||||
for (char I : StringRef("csil")) {
|
||||
BasicType BT = ParseBasicType(I);
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BT, Log2LMUL, PrototypeDescriptor::Vector);
|
||||
if (T.hasValue()) {
|
||||
printType(T.getValue());
|
||||
if (T) {
|
||||
printType(*T);
|
||||
auto UT = RVVType::computeType(
|
||||
BT, Log2LMUL,
|
||||
PrototypeDescriptor(BaseTypeModifier::Vector,
|
||||
VectorTypeModifier::NoModifier,
|
||||
TypeModifier::UnsignedInteger));
|
||||
printType(UT.getValue());
|
||||
printType(*UT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,8 +240,8 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
|||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float16, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
if (T)
|
||||
printType(*T);
|
||||
}
|
||||
OS << "#endif\n";
|
||||
|
||||
|
@ -249,8 +249,8 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
|||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float32, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
if (T)
|
||||
printType(*T);
|
||||
}
|
||||
OS << "#endif\n";
|
||||
|
||||
|
@ -258,8 +258,8 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
|||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float64, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
if (T)
|
||||
printType(*T);
|
||||
}
|
||||
OS << "#endif\n\n";
|
||||
|
||||
|
|
|
@ -446,7 +446,9 @@ public:
|
|||
/// `load` must be a LHS array_load. Returns `llvm::None` on error.
|
||||
llvm::Optional<size_t> findArgPosition(fir::ArrayLoadOp load);
|
||||
|
||||
bool isLHS(fir::ArrayLoadOp load) { return findArgPosition(load).hasValue(); }
|
||||
bool isLHS(fir::ArrayLoadOp load) {
|
||||
return findArgPosition(load).has_value();
|
||||
}
|
||||
|
||||
/// `load` must be a LHS array_load. Determine the threaded inner argument
|
||||
/// corresponding to this load.
|
||||
|
@ -465,15 +467,15 @@ public:
|
|||
|
||||
llvm::Optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
|
||||
assert(i < lhsBases.size());
|
||||
if (lhsBases[counter].hasValue())
|
||||
return findBinding(lhsBases[counter].getValue());
|
||||
if (lhsBases[counter])
|
||||
return findBinding(*lhsBases[counter]);
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
/// Return the outermost loop in this FORALL nest.
|
||||
fir::DoLoopOp getOuterLoop() {
|
||||
assert(outerLoop.hasValue());
|
||||
return outerLoop.getValue();
|
||||
assert(outerLoop);
|
||||
return *outerLoop;
|
||||
}
|
||||
|
||||
/// Return the statement context for the entire, outermost FORALL construct.
|
||||
|
|
|
@ -2227,10 +2227,10 @@ private:
|
|||
llvm_unreachable("unknown category");
|
||||
}
|
||||
if (lhsIsWholeAllocatable)
|
||||
fir::factory::finalizeRealloc(
|
||||
*builder, loc, lhsMutableBox.getValue(),
|
||||
/*lbounds=*/llvm::None, /*takeLboundsIfRealloc=*/false,
|
||||
lhsRealloc.getValue());
|
||||
fir::factory::finalizeRealloc(*builder, loc, *lhsMutableBox,
|
||||
/*lbounds=*/llvm::None,
|
||||
/*takeLboundsIfRealloc=*/false,
|
||||
*lhsRealloc);
|
||||
},
|
||||
|
||||
// [2] User defined assignment. If the context is a scalar
|
||||
|
|
|
@ -2607,9 +2607,9 @@ public:
|
|||
funcSymbolAttr, operands);
|
||||
|
||||
if (caller.mustSaveResult())
|
||||
builder.create<fir::SaveResultOp>(
|
||||
loc, call.getResult(0), fir::getBase(allocatedResult.getValue()),
|
||||
arrayResultShape, resultLengths);
|
||||
builder.create<fir::SaveResultOp>(loc, call.getResult(0),
|
||||
fir::getBase(*allocatedResult),
|
||||
arrayResultShape, resultLengths);
|
||||
|
||||
if (allocatedResult) {
|
||||
allocatedResult->match(
|
||||
|
@ -4110,10 +4110,10 @@ private:
|
|||
mlir::Value{});
|
||||
}
|
||||
} else if (isBoundsRemap()) {
|
||||
auto lbs = lbounds.getValue();
|
||||
auto lbs = *lbounds;
|
||||
if (lbs.size() > 0) {
|
||||
// Rebox the value with user-specified shift and shape.
|
||||
auto shapeShiftArgs = flatZip(lbs, ubounds.getValue());
|
||||
auto shapeShiftArgs = flatZip(lbs, *ubounds);
|
||||
auto shapeTy = fir::ShapeShiftType::get(eleTy.getContext(), lbs.size());
|
||||
mlir::Value shapeShift =
|
||||
builder.create<fir::ShapeShiftOp>(loc, shapeTy, shapeShiftArgs);
|
||||
|
@ -4185,8 +4185,8 @@ private:
|
|||
auto [iterSpace, insPt] = genIterSpace(resultTy);
|
||||
auto exv = f(iterSpace);
|
||||
iterSpace.setElement(std::move(exv));
|
||||
auto lambda = ccStoreToDest.hasValue()
|
||||
? ccStoreToDest.getValue()
|
||||
auto lambda = ccStoreToDest
|
||||
? *ccStoreToDest
|
||||
: defaultStoreToDestination(/*substring=*/nullptr);
|
||||
mlir::Value updVal = fir::getBase(lambda(iterSpace));
|
||||
finalizeElementCtx();
|
||||
|
@ -4522,8 +4522,8 @@ private:
|
|||
}
|
||||
|
||||
// Generate the lazy mask allocation, if one was given.
|
||||
if (ccPrelude.hasValue())
|
||||
ccPrelude.getValue()(shape);
|
||||
if (ccPrelude)
|
||||
ccPrelude.value()(shape);
|
||||
|
||||
// Now handle the implicit loops.
|
||||
mlir::Value inner = explicitSpaceIsActive()
|
||||
|
@ -4582,8 +4582,8 @@ private:
|
|||
fir::ArrayLoadOp
|
||||
createAndLoadSomeArrayTemp(mlir::Type type,
|
||||
llvm::ArrayRef<mlir::Value> shape) {
|
||||
if (ccLoadDest.hasValue())
|
||||
return ccLoadDest.getValue()(shape);
|
||||
if (ccLoadDest)
|
||||
return ccLoadDest.value()(shape);
|
||||
auto seqTy = type.dyn_cast<fir::SequenceType>();
|
||||
assert(seqTy && "must be an array");
|
||||
mlir::Location loc = getLoc();
|
||||
|
@ -5810,8 +5810,8 @@ private:
|
|||
// always loaded at the beginning of the statement and merged at the
|
||||
// end.
|
||||
destination = arrLoad;
|
||||
auto lambda = ccStoreToDest.hasValue()
|
||||
? ccStoreToDest.getValue()
|
||||
auto lambda = ccStoreToDest
|
||||
? ccStoreToDest.value()
|
||||
: defaultStoreToDestination(components.substring);
|
||||
return [=](IterSpace iters) -> ExtValue { return lambda(iters); };
|
||||
}
|
||||
|
@ -6464,8 +6464,8 @@ private:
|
|||
|
||||
// Return the continuation.
|
||||
if (fir::isa_char(seqTy.getEleTy())) {
|
||||
if (charLen.hasValue()) {
|
||||
auto len = builder.create<fir::LoadOp>(loc, charLen.getValue());
|
||||
if (charLen) {
|
||||
auto len = builder.create<fir::LoadOp>(loc, charLen.value());
|
||||
return genarr(fir::CharArrayBoxValue{mem, len, extents});
|
||||
}
|
||||
return genarr(fir::CharArrayBoxValue{mem, zero, extents});
|
||||
|
@ -7181,14 +7181,14 @@ private:
|
|||
|
||||
void setUnordered(bool b) { unordered = b; }
|
||||
|
||||
inline bool isPointerAssignment() const { return lbounds.hasValue(); }
|
||||
inline bool isPointerAssignment() const { return lbounds.has_value(); }
|
||||
|
||||
inline bool isBoundsSpec() const {
|
||||
return isPointerAssignment() && !ubounds.hasValue();
|
||||
return isPointerAssignment() && !ubounds.has_value();
|
||||
}
|
||||
|
||||
inline bool isBoundsRemap() const {
|
||||
return isPointerAssignment() && ubounds.hasValue();
|
||||
return isPointerAssignment() && ubounds.has_value();
|
||||
}
|
||||
|
||||
void setPointerAssignmentBounds(
|
||||
|
@ -7515,8 +7515,8 @@ void Fortran::lower::createArrayLoads(
|
|||
auto genLoad = [&](const auto *x) -> fir::ArrayLoadOp {
|
||||
return genArrayLoad(loc, converter, builder, x, symMap, stmtCtx);
|
||||
};
|
||||
if (esp.lhsBases[counter].hasValue()) {
|
||||
auto &base = esp.lhsBases[counter].getValue();
|
||||
if (esp.lhsBases[counter]) {
|
||||
auto &base = *esp.lhsBases[counter];
|
||||
auto load = std::visit(genLoad, base);
|
||||
esp.initialArgs.push_back(load);
|
||||
esp.resetInnerArgs();
|
||||
|
@ -7535,13 +7535,13 @@ void Fortran::lower::createArrayMergeStores(
|
|||
// Gen the fir.array_merge_store ops for all LHS arrays.
|
||||
for (auto i : llvm::enumerate(esp.getOuterLoop().getResults()))
|
||||
if (llvm::Optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
|
||||
fir::ArrayLoadOp load = ldOpt.getValue();
|
||||
fir::ArrayLoadOp load = *ldOpt;
|
||||
builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
|
||||
load.getMemref(), load.getSlice(),
|
||||
load.getTypeparams());
|
||||
}
|
||||
if (esp.loopCleanup.hasValue()) {
|
||||
esp.loopCleanup.getValue()(builder);
|
||||
if (esp.loopCleanup) {
|
||||
esp.loopCleanup.value()(builder);
|
||||
esp.loopCleanup = llvm::None;
|
||||
}
|
||||
esp.initialArgs.clear();
|
||||
|
|
|
@ -195,12 +195,12 @@ lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
|
|||
isPresentCheck(2) &&
|
||||
"only ISHFTC SIZE arg is expected to be dynamically optional here");
|
||||
assert(retTy && "ISFHTC must have a return type");
|
||||
mlir::Type resultType = retTy.getValue();
|
||||
mlir::Type resultType = *retTy;
|
||||
llvm::SmallVector<fir::ExtendedValue> args;
|
||||
args.push_back(getOperand(0));
|
||||
args.push_back(getOperand(1));
|
||||
args.push_back(builder
|
||||
.genIfOp(loc, {resultType}, isPresentCheck(2).getValue(),
|
||||
.genIfOp(loc, {resultType}, *isPresentCheck(2),
|
||||
/*withElseRegion=*/true)
|
||||
.genThen([&]() {
|
||||
fir::ExtendedValue sizeExv = getOperand(2);
|
||||
|
|
|
@ -862,12 +862,12 @@ void Fortran::lower::ExplicitIterSpace::conditionalCleanup() {
|
|||
|
||||
llvm::Optional<size_t>
|
||||
Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) {
|
||||
if (lhsBases[counter].hasValue()) {
|
||||
auto ld = loadBindings.find(lhsBases[counter].getValue());
|
||||
if (lhsBases[counter]) {
|
||||
auto ld = loadBindings.find(*lhsBases[counter]);
|
||||
llvm::Optional<size_t> optPos;
|
||||
if (ld != loadBindings.end() && ld->second == load)
|
||||
optPos = static_cast<size_t>(0u);
|
||||
assert(optPos.hasValue() && "load does not correspond to lhs");
|
||||
assert(optPos && "load does not correspond to lhs");
|
||||
return optPos;
|
||||
}
|
||||
return llvm::None;
|
||||
|
@ -919,8 +919,8 @@ Fortran::lower::operator<<(llvm::raw_ostream &s,
|
|||
s << "LHS bases:\n";
|
||||
for (const llvm::Optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
|
||||
e.lhsBases)
|
||||
if (u.hasValue())
|
||||
dump(u.getValue());
|
||||
if (u)
|
||||
dump(*u);
|
||||
s << "RHS bases:\n";
|
||||
for (const llvm::SmallVector<Fortran::lower::ExplicitIterSpace::ArrayBases>
|
||||
&bases : e.rhsBases) {
|
||||
|
|
|
@ -252,11 +252,11 @@ public:
|
|||
auto toTy = typeConverter.convertType(unwrapRefType(ty));
|
||||
bool isPinned = mem.getPinned();
|
||||
llvm::StringRef uniqName;
|
||||
if (mem.getUniqName().hasValue())
|
||||
uniqName = mem.getUniqName().getValue();
|
||||
if (mem.getUniqName())
|
||||
uniqName = mem.getUniqName().value();
|
||||
llvm::StringRef bindcName;
|
||||
if (mem.getBindcName().hasValue())
|
||||
bindcName = mem.getBindcName().getValue();
|
||||
if (mem.getBindcName())
|
||||
bindcName = mem.getBindcName().value();
|
||||
rewriter.replaceOpWithNewOp<AllocaOp>(
|
||||
mem, toTy, uniqName, bindcName, isPinned, mem.getTypeparams(),
|
||||
mem.getShape());
|
||||
|
@ -267,11 +267,11 @@ public:
|
|||
rewriter.setInsertionPoint(mem);
|
||||
auto toTy = typeConverter.convertType(unwrapRefType(ty));
|
||||
llvm::StringRef uniqName;
|
||||
if (mem.getUniqName().hasValue())
|
||||
uniqName = mem.getUniqName().getValue();
|
||||
if (mem.getUniqName())
|
||||
uniqName = mem.getUniqName().value();
|
||||
llvm::StringRef bindcName;
|
||||
if (mem.getBindcName().hasValue())
|
||||
bindcName = mem.getBindcName().getValue();
|
||||
if (mem.getBindcName())
|
||||
bindcName = mem.getBindcName().value();
|
||||
rewriter.replaceOpWithNewOp<AllocMemOp>(
|
||||
mem, toTy, uniqName, bindcName, mem.getTypeparams(),
|
||||
mem.getShape());
|
||||
|
|
|
@ -2636,9 +2636,9 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
|
|||
auto loc = global.getLoc();
|
||||
mlir::Attribute initAttr;
|
||||
if (global.getInitVal())
|
||||
initAttr = global.getInitVal().getValue();
|
||||
initAttr = *global.getInitVal();
|
||||
auto linkage = convertLinkage(global.getLinkName());
|
||||
auto isConst = global.getConstant().hasValue();
|
||||
auto isConst = global.getConstant().has_value();
|
||||
auto g = rewriter.create<mlir::LLVM::GlobalOp>(
|
||||
loc, tyAttr, isConst, linkage, global.getSymName(), initAttr);
|
||||
auto &gr = g.getInitializerRegion();
|
||||
|
@ -2692,8 +2692,8 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
|
|||
// enumeration.
|
||||
mlir::LLVM::Linkage
|
||||
convertLinkage(llvm::Optional<llvm::StringRef> optLinkage) const {
|
||||
if (optLinkage.hasValue()) {
|
||||
auto name = optLinkage.getValue();
|
||||
if (optLinkage) {
|
||||
auto name = *optLinkage;
|
||||
if (name == "internal")
|
||||
return mlir::LLVM::Linkage::Internal;
|
||||
if (name == "linkonce")
|
||||
|
@ -2749,9 +2749,9 @@ static void genCondBrOp(mlir::Location loc, mlir::Value cmp, mlir::Block *dest,
|
|||
llvm::Optional<mlir::ValueRange> destOps,
|
||||
mlir::ConversionPatternRewriter &rewriter,
|
||||
mlir::Block *newBlock) {
|
||||
if (destOps.hasValue())
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, destOps.getValue(),
|
||||
newBlock, mlir::ValueRange());
|
||||
if (destOps)
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, *destOps, newBlock,
|
||||
mlir::ValueRange());
|
||||
else
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, newBlock);
|
||||
}
|
||||
|
@ -2759,9 +2759,8 @@ static void genCondBrOp(mlir::Location loc, mlir::Value cmp, mlir::Block *dest,
|
|||
template <typename A, typename B>
|
||||
static void genBrOp(A caseOp, mlir::Block *dest, llvm::Optional<B> destOps,
|
||||
mlir::ConversionPatternRewriter &rewriter) {
|
||||
if (destOps.hasValue())
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, destOps.getValue(),
|
||||
dest);
|
||||
if (destOps)
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
|
||||
else
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, llvm::None, dest);
|
||||
}
|
||||
|
@ -2884,15 +2883,14 @@ static void selectMatchAndRewrite(fir::LLVMTypeConverter &lowering, OP select,
|
|||
const mlir::Attribute &attr = cases[t];
|
||||
if (auto intAttr = attr.template dyn_cast<mlir::IntegerAttr>()) {
|
||||
destinations.push_back(dest);
|
||||
destinationsOperands.push_back(destOps.hasValue() ? *destOps
|
||||
: mlir::ValueRange{});
|
||||
destinationsOperands.push_back(destOps ? *destOps : mlir::ValueRange{});
|
||||
caseValues.push_back(intAttr.getInt());
|
||||
continue;
|
||||
}
|
||||
assert(attr.template dyn_cast_or_null<mlir::UnitAttr>());
|
||||
assert((t + 1 == conds) && "unit must be last");
|
||||
defaultDestination = dest;
|
||||
defaultOperands = destOps.hasValue() ? *destOps : mlir::ValueRange{};
|
||||
defaultOperands = destOps ? *destOps : mlir::ValueRange{};
|
||||
}
|
||||
|
||||
// LLVM::SwitchOp takes a i32 type for the selector.
|
||||
|
|
|
@ -316,9 +316,9 @@ public:
|
|||
newOpers.insert(newOpers.end(), trailingOpers.begin(), trailingOpers.end());
|
||||
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
|
||||
fir::CallOp newCall;
|
||||
if (callOp.getCallee().hasValue()) {
|
||||
newCall = rewriter->create<A>(loc, callOp.getCallee().getValue(),
|
||||
newResTys, newOpers);
|
||||
if (callOp.getCallee()) {
|
||||
newCall =
|
||||
rewriter->create<A>(loc, *callOp.getCallee(), newResTys, newOpers);
|
||||
} else {
|
||||
// Force new type on the input operand.
|
||||
newOpers[0].setType(mlir::FunctionType::get(
|
||||
|
|
|
@ -616,10 +616,10 @@ mlir::FunctionType fir::CallOp::getFunctionType() {
|
|||
}
|
||||
|
||||
void fir::CallOp::print(mlir::OpAsmPrinter &p) {
|
||||
bool isDirect = getCallee().hasValue();
|
||||
bool isDirect = getCallee().has_value();
|
||||
p << ' ';
|
||||
if (isDirect)
|
||||
p << getCallee().getValue();
|
||||
p << *getCallee();
|
||||
else
|
||||
p << getOperand(0);
|
||||
p << '(' << (*this)->getOperands().drop_front(isDirect ? 0 : 1) << ')';
|
||||
|
@ -700,9 +700,8 @@ static void printCmpOp(mlir::OpAsmPrinter &p, OPTY op) {
|
|||
op->template getAttrOfType<mlir::IntegerAttr>(
|
||||
OPTY::getPredicateAttrName())
|
||||
.getInt());
|
||||
assert(predSym.hasValue() && "invalid symbol value for predicate");
|
||||
p << '"' << mlir::arith::stringifyCmpFPredicate(predSym.getValue()) << '"'
|
||||
<< ", ";
|
||||
assert(predSym && "invalid symbol value for predicate");
|
||||
p << '"' << mlir::arith::stringifyCmpFPredicate(*predSym) << '"' << ", ";
|
||||
p.printOperand(op.getLhs());
|
||||
p << ", ";
|
||||
p.printOperand(op.getRhs());
|
||||
|
@ -777,8 +776,8 @@ void fir::buildCmpCOp(mlir::OpBuilder &builder, mlir::OperationState &result,
|
|||
mlir::arith::CmpFPredicate
|
||||
fir::CmpcOp::getPredicateByName(llvm::StringRef name) {
|
||||
auto pred = mlir::arith::symbolizeCmpFPredicate(name);
|
||||
assert(pred.hasValue() && "invalid predicate name");
|
||||
return pred.getValue();
|
||||
assert(pred && "invalid predicate name");
|
||||
return *pred;
|
||||
}
|
||||
|
||||
void fir::CmpcOp::print(mlir::OpAsmPrinter &p) { printCmpOp(p, *this); }
|
||||
|
@ -1074,7 +1073,7 @@ mlir::ParseResult fir::DispatchTableOp::parse(mlir::OpAsmParser &parser,
|
|||
// Parse the optional table body.
|
||||
mlir::Region *body = result.addRegion();
|
||||
mlir::OptionalParseResult parseResult = parser.parseOptionalRegion(*body);
|
||||
if (parseResult.hasValue() && failed(*parseResult))
|
||||
if (parseResult.has_value() && failed(*parseResult))
|
||||
return mlir::failure();
|
||||
|
||||
fir::DispatchTableOp::ensureTerminator(*body, parser.getBuilder(),
|
||||
|
@ -1256,15 +1255,15 @@ mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser,
|
|||
// Parse the optional initializer body.
|
||||
auto parseResult =
|
||||
parser.parseOptionalRegion(*result.addRegion(), /*arguments=*/{});
|
||||
if (parseResult.hasValue() && mlir::failed(*parseResult))
|
||||
if (parseResult.has_value() && mlir::failed(*parseResult))
|
||||
return mlir::failure();
|
||||
}
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
void fir::GlobalOp::print(mlir::OpAsmPrinter &p) {
|
||||
if (getLinkName().hasValue())
|
||||
p << ' ' << getLinkName().getValue();
|
||||
if (getLinkName())
|
||||
p << ' ' << *getLinkName();
|
||||
p << ' ';
|
||||
p.printAttributeWithoutType(getSymrefAttr());
|
||||
if (auto val = getValueOrNull())
|
||||
|
|
|
@ -120,7 +120,7 @@ mlir::Type fir::parseFirType(FIROpsDialect *dialect,
|
|||
return {};
|
||||
mlir::Type genType;
|
||||
auto parseResult = generatedTypeParser(parser, typeTag, genType);
|
||||
if (parseResult.hasValue())
|
||||
if (parseResult.has_value())
|
||||
return genType;
|
||||
parser.emitError(parser.getNameLoc(), "unknown fir type: ") << typeTag;
|
||||
return {};
|
||||
|
|
|
@ -51,8 +51,8 @@ convertToStringRef(llvm::ArrayRef<std::string> from) {
|
|||
inline llvm::Optional<llvm::StringRef>
|
||||
convertToStringRef(const llvm::Optional<std::string> &from) {
|
||||
llvm::Optional<llvm::StringRef> to;
|
||||
if (from.hasValue())
|
||||
to = from.getValue();
|
||||
if (from)
|
||||
to = *from;
|
||||
return to;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue