forked from OSchip/llvm-project
Revert "Don't use Optional::hasValue (NFC)"
This reverts commit aa8feeefd3
.
This commit is contained in:
parent
aa8feeefd3
commit
3b7c3a654c
|
@ -653,10 +653,10 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
|
|||
|
||||
if (I.DefLoc) {
|
||||
if (!CDCtx.RepositoryUrl)
|
||||
Out.emplace_back(writeFileDefinition(*I.DefLoc));
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
else
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
}
|
||||
|
||||
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));
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
else
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
}
|
||||
|
||||
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));
|
||||
Out.emplace_back(writeFileDefinition(I.DefLoc.getValue()));
|
||||
else
|
||||
Out.emplace_back(
|
||||
writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
|
||||
Out.emplace_back(writeFileDefinition(
|
||||
I.DefLoc.getValue(), StringRef{CDCtx.RepositoryUrl.getValue()}));
|
||||
}
|
||||
|
||||
std::string Description;
|
||||
|
|
|
@ -817,8 +817,8 @@ void NotNullTerminatedResultCheck::check(
|
|||
++It;
|
||||
}
|
||||
|
||||
if (AreSafeFunctionsWanted)
|
||||
UseSafeFunctions = *AreSafeFunctionsWanted;
|
||||
if (AreSafeFunctionsWanted.hasValue())
|
||||
UseSafeFunctions = AreSafeFunctionsWanted.getValue();
|
||||
}
|
||||
|
||||
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)
|
||||
WantDiags =
|
||||
*Params.wantDiagnostics ? WantDiagnostics::Yes : WantDiagnostics::No;
|
||||
if (Params.wantDiagnostics.hasValue())
|
||||
WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
|
||||
: WantDiagnostics::No;
|
||||
|
||||
PathRef File = Params.textDocument.uri.file();
|
||||
auto Code = Server->getDraft(File);
|
||||
|
|
|
@ -411,9 +411,10 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
|
|||
clang::clangd::trace::Span Tracer("Completion results callback");
|
||||
CB(std::move(Result));
|
||||
}
|
||||
if (SpecFuzzyFind && SpecFuzzyFind->NewReq) {
|
||||
if (SpecFuzzyFind && SpecFuzzyFind->NewReq.hasValue()) {
|
||||
std::lock_guard<std::mutex> Lock(CachedCompletionFuzzyFindRequestMutex);
|
||||
CachedCompletionFuzzyFindRequestByFile[File] = *SpecFuzzyFind->NewReq;
|
||||
CachedCompletionFuzzyFindRequestByFile[File] =
|
||||
SpecFuzzyFind->NewReq.getValue();
|
||||
}
|
||||
// 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,9 +391,11 @@ 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; });
|
||||
std::stable_partition(Completion.Includes.begin(),
|
||||
Completion.Includes.end(),
|
||||
[](const CodeCompletion::IncludeCandidate &I) {
|
||||
return !I.Insertion.hasValue();
|
||||
});
|
||||
}
|
||||
|
||||
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.has_value() +
|
||||
External.Server.has_value() + *External.IsNone;
|
||||
unsigned SourceCount = External.File.hasValue() +
|
||||
External.Server.hasValue() + *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 && "Initialized twice");
|
||||
assert(!Fac.hasValue() && "Initialized twice");
|
||||
Fac.emplace(F);
|
||||
}
|
||||
|
||||
FeatureModule::Facilities &FeatureModule::facilities() {
|
||||
assert(Fac && "Not initialized yet");
|
||||
assert(Fac.hasValue() && "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.has_value())) {
|
||||
if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) {
|
||||
if (!IO.outputting())
|
||||
Variant.Symbol.emplace();
|
||||
MappingTraits<Symbol>::mapping(IO, *Variant.Symbol);
|
||||
} else if (IO.mapTag("!Refs", Variant.Refs.has_value())) {
|
||||
} else if (IO.mapTag("!Refs", Variant.Refs.hasValue())) {
|
||||
if (!IO.outputting())
|
||||
Variant.Refs.emplace();
|
||||
MappingTraits<RefBundle>::mapping(IO, *Variant.Refs);
|
||||
} else if (IO.mapTag("!Relations", Variant.Relation.has_value())) {
|
||||
} else if (IO.mapTag("!Relations", Variant.Relation.hasValue())) {
|
||||
if (!IO.outputting())
|
||||
Variant.Relation.emplace();
|
||||
MappingTraits<Relation>::mapping(IO, *Variant.Relation);
|
||||
} else if (IO.mapTag("!Source", Variant.Source.has_value())) {
|
||||
} else if (IO.mapTag("!Source", Variant.Source.hasValue())) {
|
||||
if (!IO.outputting())
|
||||
Variant.Source.emplace();
|
||||
MappingTraits<IncludeGraphNode>::mapping(IO, *Variant.Source);
|
||||
} else if (IO.mapTag("!Cmd", Variant.Cmd.has_value())) {
|
||||
} else if (IO.mapTag("!Cmd", Variant.Cmd.hasValue())) {
|
||||
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.value());
|
||||
EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
|
||||
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.value());
|
||||
EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
|
||||
}
|
||||
|
||||
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.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));
|
||||
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));
|
||||
}
|
||||
|
||||
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.value()->File, val("foo"));
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->MountPoint, val("baz"));
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->File, val("foo"));
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->MountPoint, val("baz"));
|
||||
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
|
||||
EXPECT_THAT(*Results[0].Index.External.value()->Server, val("bar"));
|
||||
EXPECT_THAT(*Results[0].Index.External.getValue()->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")).has_value());
|
||||
EXPECT_TRUE(StatCache.lookup(testPath("y")).has_value());
|
||||
EXPECT_TRUE(StatCache.lookup(testPath("x")).hasValue());
|
||||
EXPECT_TRUE(StatCache.lookup(testPath("y")).hasValue());
|
||||
// Main file is not cached.
|
||||
EXPECT_FALSE(StatCache.lookup(testPath("main")).has_value());
|
||||
EXPECT_FALSE(StatCache.lookup(testPath("main")).hasValue());
|
||||
|
||||
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.has_value());
|
||||
EXPECT_THAT(Commands->CommandLine, Contains("-DFOO"));
|
||||
ASSERT_TRUE(Commands.hasValue());
|
||||
EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
|
||||
// Make sure we pick the right working directory.
|
||||
EXPECT_EQ(testPath("x"), Commands->Directory);
|
||||
EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
|
||||
}
|
||||
|
||||
MATCHER_P(hasArg, Flag, "") {
|
||||
if (!arg) {
|
||||
if (!arg.hasValue()) {
|
||||
*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.has_value());
|
||||
ASSERT_EQ(*PathResult, FooH);
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), FooH);
|
||||
|
||||
PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None));
|
||||
EXPECT_TRUE(PathResult.has_value());
|
||||
ASSERT_EQ(*PathResult, FooCpp);
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), 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.has_value());
|
||||
ASSERT_EQ(*PathResult, FooHH);
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), 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.has_value());
|
||||
ASSERT_EQ(*PathResult, Foo2HH);
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), 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.has_value());
|
||||
ASSERT_EQ(*PathResult, Foo3HXX);
|
||||
EXPECT_TRUE(PathResult.hasValue());
|
||||
ASSERT_EQ(PathResult.getValue(), Foo3HXX);
|
||||
|
||||
// Test if asking for a corresponding file that doesn't exist returns an empty
|
||||
// string.
|
||||
PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None));
|
||||
EXPECT_FALSE(PathResult.has_value());
|
||||
EXPECT_FALSE(PathResult.hasValue());
|
||||
}
|
||||
|
||||
MATCHER_P(declNamed, Name, "") {
|
||||
|
|
|
@ -93,18 +93,19 @@ TEST(LSPBinderTest, IncomingCalls) {
|
|||
|
||||
auto &RawPlusOne = RawHandlers.MethodHandlers["plusOne"];
|
||||
RawPlusOne(1, capture(Reply));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(2));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
|
||||
RawPlusOne("foo", capture(Reply));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(
|
||||
*Reply, llvm::FailedWithMessage(HasSubstr(
|
||||
"failed to decode plusOne request: expected integer")));
|
||||
Reply.getValue(),
|
||||
llvm::FailedWithMessage(
|
||||
HasSubstr("failed to decode plusOne request: expected integer")));
|
||||
|
||||
auto &RawFail = RawHandlers.MethodHandlers["fail"];
|
||||
RawFail(2, capture(Reply));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::FailedWithMessage("X=2"));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("X=2"));
|
||||
|
||||
auto &RawNotify = RawHandlers.NotificationHandlers["notify"];
|
||||
RawNotify(42);
|
||||
|
@ -116,8 +117,8 @@ TEST(LSPBinderTest, IncomingCalls) {
|
|||
|
||||
auto &RawCmdPlusOne = RawHandlers.CommandHandlers["cmdPlusOne"];
|
||||
RawCmdPlusOne(1, capture(Reply));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(2));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
|
||||
|
||||
// None of this generated any outgoing traffic.
|
||||
EXPECT_THAT(RawOutgoing.Received, IsEmpty());
|
||||
|
@ -138,23 +139,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.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::HasValue(Foo{2}));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), 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.has_value());
|
||||
EXPECT_THAT_EXPECTED(*WrongTypeReply,
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
|
||||
llvm::FailedWithMessage(
|
||||
HasSubstr("failed to decode wrongSignature reply")));
|
||||
|
||||
Fail(Foo{2}, capture(Reply));
|
||||
EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2)));
|
||||
ASSERT_TRUE(Reply.has_value());
|
||||
EXPECT_THAT_EXPECTED(*Reply, llvm::FailedWithMessage("Params=2"));
|
||||
ASSERT_TRUE(Reply.hasValue());
|
||||
EXPECT_THAT_EXPECTED(Reply.getValue(), 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.has_value());
|
||||
ASSERT_TRUE(BaseOptions.Checks.hasValue());
|
||||
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.has_value());
|
||||
ASSERT_TRUE(Sub1Options.Checks.hasValue());
|
||||
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.has_value());
|
||||
ASSERT_TRUE(Sub2Options.Checks.hasValue());
|
||||
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)
|
||||
if (RID.hasValue())
|
||||
return false;
|
||||
RID = A.getReduceRule();
|
||||
}
|
||||
if (!RID)
|
||||
if (!RID.hasValue())
|
||||
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.has_value(), Actual->DefLoc.has_value());
|
||||
if (Expected->DefLoc && Actual->DefLoc) {
|
||||
EXPECT_EQ(Expected->DefLoc.hasValue(), Actual->DefLoc.hasValue());
|
||||
if (Expected->DefLoc.hasValue() && Actual->DefLoc.hasValue()) {
|
||||
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.has_value());
|
||||
ASSERT_TRUE(Options.ExtraArgs.hasValue());
|
||||
EXPECT_EQ("arg1,arg2,arg3,arg4", llvm::join(Options.ExtraArgs->begin(),
|
||||
Options.ExtraArgs->end(), ","));
|
||||
ASSERT_TRUE(Options.ExtraArgsBefore.has_value());
|
||||
ASSERT_TRUE(Options.ExtraArgsBefore.hasValue());
|
||||
EXPECT_EQ("arg-before1,arg-before2,arg-before3,arg-before4",
|
||||
llvm::join(Options.ExtraArgsBefore->begin(),
|
||||
Options.ExtraArgsBefore->end(), ","));
|
||||
ASSERT_TRUE(Options.UseColor.has_value());
|
||||
ASSERT_TRUE(Options.UseColor.hasValue());
|
||||
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").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid1").hasValue());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").hasValue());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").hasValue());
|
||||
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").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").hasValue());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").hasValue());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").hasValue());
|
||||
EXPECT_FALSE(
|
||||
TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").has_value());
|
||||
TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").hasValue());
|
||||
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").hasValue());
|
||||
|
||||
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").has_value());
|
||||
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").hasValue());
|
||||
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)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;
|
||||
if (Hint.hasValue())
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
|
||||
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.has_value());
|
||||
ASSERT_TRUE(File1Options.Checks.hasValue());
|
||||
EXPECT_EQ(*File1Options.Checks, "-*,clang-diagnostic-*,readability-*");
|
||||
ASSERT_TRUE(File2Options.Checks.has_value());
|
||||
ASSERT_TRUE(File2Options.Checks.hasValue());
|
||||
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)
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;
|
||||
if (Hint.hasValue())
|
||||
diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
|
||||
|
||||
diag(Call->getBeginLoc(), "insert call")
|
||||
<< clang::FixItHint::CreateReplacement(
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
}
|
||||
|
||||
void setSwiftPrivate(llvm::Optional<bool> Private) {
|
||||
SwiftPrivateSpecified = Private.has_value();
|
||||
SwiftPrivate = Private.value_or(0);
|
||||
SwiftPrivateSpecified = Private.hasValue();
|
||||
SwiftPrivate = Private.hasValue() ? *Private : 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->getTypePtr()), *type);
|
||||
TypeInfoLValue(typeInfo.getValue().getTypePtr()), type.getValue());
|
||||
elemTy = base.getTypeInfoType();
|
||||
} else if (isExpr) {
|
||||
base = APValue::LValueBase(cast<Expr>(*stmt),
|
||||
*callIndex, *version);
|
||||
base = APValue::LValueBase(cast<Expr>(stmt.getValue()),
|
||||
callIndex.getValue(), version.getValue());
|
||||
elemTy = base.get<const Expr *>()->getType();
|
||||
} else {
|
||||
base = APValue::LValueBase(cast<ValueDecl>(*decl),
|
||||
*callIndex, *version);
|
||||
base = APValue::LValueBase(cast<ValueDecl>(decl.getValue()),
|
||||
callIndex.getValue(), version.getValue());
|
||||
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 && !override)
|
||||
return;
|
||||
if (IsPrunable.hasValue() && !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)
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
*Diag.ImmediateDiag << Value;
|
||||
else if (Diag.PartialDiagId)
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
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)
|
||||
if (ImmediateDiag.hasValue())
|
||||
*ImmediateDiag << std::move(V);
|
||||
else if (PartialDiagId)
|
||||
else if (PartialDiagId.hasValue())
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second << std::move(V);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend const SemaDiagnosticBuilder &
|
||||
operator<<(const SemaDiagnosticBuilder &Diag, const PartialDiagnostic &PD) {
|
||||
if (Diag.ImmediateDiag)
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
PD.Emit(*Diag.ImmediateDiag);
|
||||
else if (Diag.PartialDiagId)
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second = PD;
|
||||
return Diag;
|
||||
}
|
||||
|
||||
void AddFixItHint(const FixItHint &Hint) const {
|
||||
if (ImmediateDiag)
|
||||
if (ImmediateDiag.hasValue())
|
||||
ImmediateDiag->AddFixItHint(Hint);
|
||||
else if (PartialDiagId)
|
||||
else if (PartialDiagId.hasValue())
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second.AddFixItHint(Hint);
|
||||
}
|
||||
|
||||
|
|
|
@ -414,8 +414,7 @@ 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())
|
||||
.has_value();
|
||||
getState(), {getOriginExpr(), Index}, getLocationContext()).hasValue();
|
||||
}
|
||||
|
||||
/// Some calls have parameter numbering mismatched from argument numbering.
|
||||
|
@ -1017,8 +1016,9 @@ public:
|
|||
}
|
||||
|
||||
SVal getObjectUnderConstruction() const {
|
||||
return *ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),
|
||||
getLocationContext());
|
||||
return ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),
|
||||
getLocationContext())
|
||||
.getValue();
|
||||
}
|
||||
|
||||
/// Number of non-placement arguments to the call. It is equal to 2 for
|
||||
|
|
|
@ -53,17 +53,25 @@ public:
|
|||
}
|
||||
|
||||
/// Return true if the constraint is perfectly constrained to 'true'.
|
||||
bool isConstrainedTrue() const { return Val && *Val; }
|
||||
bool isConstrainedTrue() const {
|
||||
return Val.hasValue() && Val.getValue();
|
||||
}
|
||||
|
||||
/// Return true if the constraint is perfectly constrained to 'false'.
|
||||
bool isConstrainedFalse() const { return Val && !*Val; }
|
||||
bool isConstrainedFalse() const {
|
||||
return Val.hasValue() && !Val.getValue();
|
||||
}
|
||||
|
||||
/// Return true if the constrained is perfectly constrained.
|
||||
bool isConstrained() const { return Val.has_value(); }
|
||||
bool isConstrained() const {
|
||||
return Val.hasValue();
|
||||
}
|
||||
|
||||
/// Return true if the constrained is underconstrained and we do not know
|
||||
/// if the constraint is true of value.
|
||||
bool isUnderconstrained() const { return !Val.has_value(); }
|
||||
bool isUnderconstrained() const {
|
||||
return !Val.hasValue();
|
||||
}
|
||||
};
|
||||
|
||||
class ConstraintManager {
|
||||
|
|
|
@ -341,10 +341,10 @@ protected:
|
|||
addStateConstraints(NewState);
|
||||
|
||||
Optional<bool> res = Solver->check();
|
||||
if (!res)
|
||||
if (!res.hasValue())
|
||||
Cached[hash] = ConditionTruthVal();
|
||||
else
|
||||
Cached[hash] = ConditionTruthVal(*res);
|
||||
Cached[hash] = ConditionTruthVal(res.getValue());
|
||||
|
||||
return Cached[hash];
|
||||
}
|
||||
|
|
|
@ -209,8 +209,8 @@ public:
|
|||
}
|
||||
|
||||
bool isValid() const { return Valid; }
|
||||
bool isScalar() const { return Scale && *Scale == 0; }
|
||||
bool isVector() const { return Scale && *Scale != 0; }
|
||||
bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
|
||||
bool isVector() const { return Scale.hasValue() && Scale.getValue() != 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->has_value())
|
||||
if (Directives->hasValue())
|
||||
return ArrayRef<dependency_directives_scan::Directive>(
|
||||
Directives->value());
|
||||
Directives->getValue());
|
||||
}
|
||||
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)
|
||||
return ActiveAttr.value()->getMapType();
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->getMapType();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr::DevTypeTy>
|
||||
OMPDeclareTargetDeclAttr::getDeviceType(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.value()->getDevType();
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->getDevType();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
llvm::Optional<SourceLocation>
|
||||
OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.value()->getRange().getBegin();
|
||||
if (ActiveAttr.hasValue())
|
||||
return ActiveAttr.getValue()->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) {
|
||||
if (Result.hasValue()) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound) {
|
||||
if (Bound.hasValue()) {
|
||||
*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) {
|
||||
if (Result.hasValue()) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound) {
|
||||
if (Bound.hasValue()) {
|
||||
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)
|
||||
return *Val;
|
||||
if (Val.hasValue())
|
||||
return Val.getValue();
|
||||
|
||||
Val = nullptr;
|
||||
|
||||
|
@ -872,8 +872,8 @@ Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) {
|
|||
return nullptr;
|
||||
|
||||
Optional<Stmt *> &Val = Bodies[D];
|
||||
if (Val)
|
||||
return *Val;
|
||||
if (Val.hasValue())
|
||||
return Val.getValue();
|
||||
Val = nullptr;
|
||||
|
||||
// For now, we only synthesize getters.
|
||||
|
|
|
@ -31,10 +31,13 @@ buildStmtToBasicBlockMap(const CFG &Cfg) {
|
|||
if (Block == nullptr)
|
||||
continue;
|
||||
|
||||
for (const CFGElement &Element : *Block)
|
||||
if (auto Stmt = Element.getAs<CFGStmt>())
|
||||
StmtToBlock[Stmt->getStmt()] = Block;
|
||||
for (const CFGElement &Element : *Block) {
|
||||
auto Stmt = Element.getAs<CFGStmt>();
|
||||
if (!Stmt.hasValue())
|
||||
continue;
|
||||
|
||||
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);
|
||||
return &State->Env;
|
||||
assert(State.hasValue());
|
||||
return &State.getValue().Env;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -209,10 +209,10 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
|||
// loop back edge to `Block`.
|
||||
const llvm::Optional<TypeErasedDataflowAnalysisState> &MaybePredState =
|
||||
BlockStates[Pred->getBlockID()];
|
||||
if (!MaybePredState)
|
||||
if (!MaybePredState.hasValue())
|
||||
continue;
|
||||
|
||||
TypeErasedDataflowAnalysisState PredState = *MaybePredState;
|
||||
TypeErasedDataflowAnalysisState PredState = MaybePredState.getValue();
|
||||
if (ApplyBuiltinTransfer) {
|
||||
if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
|
||||
const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
|
||||
|
@ -222,14 +222,14 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
|||
}
|
||||
}
|
||||
|
||||
if (MaybeState) {
|
||||
if (MaybeState.hasValue()) {
|
||||
Analysis.joinTypeErased(MaybeState->Lattice, PredState.Lattice);
|
||||
MaybeState->Env.join(PredState.Env, Analysis);
|
||||
} else {
|
||||
MaybeState = std::move(PredState);
|
||||
}
|
||||
}
|
||||
if (!MaybeState) {
|
||||
if (!MaybeState.hasValue()) {
|
||||
// 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 &&
|
||||
Analysis.isEqualTypeErased(OldBlockState->Lattice,
|
||||
if (OldBlockState.hasValue() &&
|
||||
Analysis.isEqualTypeErased(OldBlockState.getValue().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)
|
||||
return *b;
|
||||
if (b.hasValue())
|
||||
return b.getValue();
|
||||
}
|
||||
|
||||
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);
|
||||
return *b;
|
||||
assert(b.hasValue());
|
||||
return b.getValue();
|
||||
}
|
||||
|
||||
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);
|
||||
return getValueVector(block)[*idx];
|
||||
assert(idx.hasValue());
|
||||
return getValueVector(block)[idx.getValue()];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,8 +209,8 @@ void CFGBlockValues::resetScratch() {
|
|||
|
||||
ValueVector::reference CFGBlockValues::operator[](const VarDecl *vd) {
|
||||
const Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
|
||||
assert(idx);
|
||||
return scratch[*idx];
|
||||
assert(idx.hasValue());
|
||||
return scratch[idx.getValue()];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------====//
|
||||
|
|
|
@ -251,8 +251,8 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
|
|||
.Case("riscv64", Is64Bit)
|
||||
.Case("64bit", Is64Bit)
|
||||
.Default(None);
|
||||
if (Result)
|
||||
return *Result;
|
||||
if (Result.hasValue())
|
||||
return Result.getValue();
|
||||
|
||||
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, FieldIndex);
|
||||
EHStack.pushCleanup<SanitizeDtorFieldRange>(
|
||||
NormalAndEHCleanup, DD, StartIndex.getValue(), FieldIndex);
|
||||
StartIndex = None;
|
||||
}
|
||||
}
|
||||
void End() {
|
||||
if (StartIndex)
|
||||
EHStack.pushCleanup<SanitizeDtorFieldRange>(NormalAndEHCleanup, DD,
|
||||
*StartIndex, -1);
|
||||
StartIndex.getValue(), -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)
|
||||
if (V.hasValue())
|
||||
return *V;
|
||||
// Next, check the source location.
|
||||
if (Loc.isValid()) {
|
||||
Optional<bool> V = ProfileList.isLocationExcluded(Loc, Kind);
|
||||
if (V)
|
||||
if (V.hasValue())
|
||||
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 &&
|
||||
*BundleOutput) {
|
||||
if (CompileDeviceOnly && CurPhase == FinalPhase &&
|
||||
BundleOutput.hasValue() && BundleOutput.getValue()) {
|
||||
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) {
|
||||
std::string DataSectionArg =
|
||||
std::string("-Tdata=0x") + llvm::utohexstr(*SectionAddressData);
|
||||
if (SectionAddressData.hasValue()) {
|
||||
std::string DataSectionArg = std::string("-Tdata=0x") +
|
||||
llvm::utohexstr(SectionAddressData.getValue());
|
||||
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)));
|
||||
CmdArgs.push_back(Args.MakeArgString("-hexagon-small-data-threshold=" +
|
||||
Twine(G.getValue())));
|
||||
}
|
||||
|
||||
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) {
|
||||
M = *BiarchSibling;
|
||||
if (BiarchSibling.hasValue()) {
|
||||
M = BiarchSibling.getValue();
|
||||
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)));
|
||||
UseG0 = *G == 0;
|
||||
CmdArgs.push_back(Args.MakeArgString("-G" + Twine(G.getValue())));
|
||||
UseG0 = G.getValue() == 0;
|
||||
}
|
||||
|
||||
CmdArgs.push_back("-o");
|
||||
|
|
|
@ -725,11 +725,11 @@ static bool getLiteralInfo(SourceRange literalRange,
|
|||
break;
|
||||
}
|
||||
|
||||
if (!UpperU && !UpperL)
|
||||
if (!UpperU.hasValue() && !UpperL.hasValue())
|
||||
UpperU = UpperL = true;
|
||||
else if (UpperU && !UpperL)
|
||||
else if (UpperU.hasValue() && !UpperL.hasValue())
|
||||
UpperL = UpperU;
|
||||
else if (UpperL && !UpperU)
|
||||
else if (UpperL.hasValue() && !UpperU.hasValue())
|
||||
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);
|
||||
Paren[Key] = std::move(Obj.getValue());
|
||||
}
|
||||
|
||||
/// 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);
|
||||
Paren[Key] = std::move(Array.getValue());
|
||||
}
|
||||
|
||||
/// 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;
|
||||
TO->CPU = getFrontendOpts().AuxTargetCPU.getValue();
|
||||
if (getFrontendOpts().AuxTargetFeatures)
|
||||
TO->FeaturesAsWritten = *getFrontendOpts().AuxTargetFeatures;
|
||||
TO->FeaturesAsWritten = getFrontendOpts().AuxTargetFeatures.getValue();
|
||||
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 ||
|
||||
*Opts.DiagnosticsHotnessThreshold > 0) &&
|
||||
if ((!Opts.DiagnosticsHotnessThreshold.hasValue() ||
|
||||
Opts.DiagnosticsHotnessThreshold.getValue() > 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 ||
|
||||
*Opts.DiagnosticsMisExpectTolerance > 0) &&
|
||||
if ((!Opts.DiagnosticsMisExpectTolerance.hasValue() ||
|
||||
Opts.DiagnosticsMisExpectTolerance.getValue() > 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)
|
||||
if (Opts.AuxTargetCPU.hasValue())
|
||||
GenerateArg(Args, OPT_aux_target_cpu, *Opts.AuxTargetCPU, SA);
|
||||
|
||||
if (Opts.AuxTargetFeatures)
|
||||
if (Opts.AuxTargetFeatures.hasValue())
|
||||
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())
|
||||
minor = *tuple.getMinor();
|
||||
if (tuple.getMinor().hasValue())
|
||||
minor = tuple.getMinor().getValue();
|
||||
|
||||
unsigned subminor = 0;
|
||||
if (tuple.getSubminor())
|
||||
subminor = *tuple.getSubminor();
|
||||
if (tuple.getSubminor().hasValue())
|
||||
subminor = tuple.getSubminor().getValue();
|
||||
|
||||
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 && "expected identifier token");
|
||||
return *Id;
|
||||
assert(Id.hasValue() && "expected identifier token");
|
||||
return Id.getValue();
|
||||
}
|
||||
|
||||
bool Scanner::isNextIdentifierOrSkipLine(StringRef Id, const char *&First,
|
||||
|
|
|
@ -209,11 +209,12 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
|
|||
}
|
||||
|
||||
VisibilityMacroDirective *VisMD = cast<VisibilityMacroDirective>(MD);
|
||||
if (!isPublic)
|
||||
if (!isPublic.hasValue())
|
||||
isPublic = VisMD->isPublic();
|
||||
}
|
||||
|
||||
return DefInfo(nullptr, UndefLoc, !isPublic || *isPublic);
|
||||
return DefInfo(nullptr, UndefLoc,
|
||||
!isPublic.hasValue() || isPublic.getValue());
|
||||
}
|
||||
|
||||
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.value()->getSize() : 0;
|
||||
const auto ModTime = File ? File.value()->getModificationTime() : 0;
|
||||
const auto Size = File ? File.getValue()->getSize() : 0;
|
||||
const auto ModTime = File ? File.getValue()->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) {
|
||||
OS << *Result;
|
||||
if (Result.hasValue()) {
|
||||
OS << Result.getValue();
|
||||
// For strict conformance to __has_cpp_attribute rules, use 'L'
|
||||
// suffix for dated literals.
|
||||
if (*Result > 1)
|
||||
if (Result.getValue() > 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)
|
||||
return *IsInFile;
|
||||
if (IsInFile.hasValue())
|
||||
return IsInFile.getValue();
|
||||
|
||||
// The external source did not provide a definite answer, go and deserialize
|
||||
// the entity to check it.
|
||||
|
|
|
@ -1873,13 +1873,14 @@ void Parser::ParseOMPDeclareTargetClauses(
|
|||
if (IsDeviceTypeClause) {
|
||||
Optional<SimpleClauseData> DevTypeData =
|
||||
parseOpenMPSimpleClause(*this, OMPC_device_type);
|
||||
if (DevTypeData) {
|
||||
if (DevTypeData.hasValue()) {
|
||||
if (DeviceTypeLoc.isValid()) {
|
||||
// We already saw another device_type clause, diagnose it.
|
||||
Diag(DevTypeData->Loc, diag::warn_omp_more_one_device_type_clause);
|
||||
Diag(DevTypeData.getValue().Loc,
|
||||
diag::warn_omp_more_one_device_type_clause);
|
||||
break;
|
||||
}
|
||||
switch (static_cast<OpenMPDeviceType>(DevTypeData->Type)) {
|
||||
switch (static_cast<OpenMPDeviceType>(DevTypeData.getValue().Type)) {
|
||||
case OMPC_DEVICE_TYPE_any:
|
||||
DTCI.DT = OMPDeclareTargetDeclAttr::DT_Any;
|
||||
break;
|
||||
|
@ -2312,9 +2313,9 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
|
|||
Sema::DeclareTargetContextInfo DTCI(DKind, DTLoc);
|
||||
if (HasClauses)
|
||||
ParseOMPDeclareTargetClauses(DTCI);
|
||||
bool HasImplicitMappings = DKind == OMPD_begin_declare_target ||
|
||||
!HasClauses ||
|
||||
(DTCI.ExplicitlyMapped.empty() && DTCI.Indirect);
|
||||
bool HasImplicitMappings =
|
||||
DKind == OMPD_begin_declare_target || !HasClauses ||
|
||||
(DTCI.ExplicitlyMapped.empty() && DTCI.Indirect.hasValue());
|
||||
|
||||
// Skip the last annot_pragma_openmp_end.
|
||||
ConsumeAnyToken();
|
||||
|
@ -3619,18 +3620,20 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind,
|
|||
if (!Val || ParseOnly)
|
||||
return nullptr;
|
||||
if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
|
||||
(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) ==
|
||||
(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) ==
|
||||
OMP_DEFAULT_private
|
||||
? OMPC_private
|
||||
: OMPC_firstprivate)
|
||||
<< getOpenMPClauseName(OMPC_default) << "5.1";
|
||||
return nullptr;
|
||||
}
|
||||
return Actions.ActOnOpenMPSimpleClause(Kind, Val->Type, Val->TypeLoc,
|
||||
Val->LOpen, Val->Loc, Val->RLoc);
|
||||
return Actions.ActOnOpenMPSimpleClause(
|
||||
Kind, Val.getValue().Type, Val.getValue().TypeLoc, Val.getValue().LOpen,
|
||||
Val.getValue().Loc, Val.getValue().RLoc);
|
||||
}
|
||||
|
||||
/// Parsing of OpenMP clauses like 'ordered'.
|
||||
|
|
|
@ -381,12 +381,13 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = BaseMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
*InferredTarget, BaseMethodTarget, InferredTarget.getPointer());
|
||||
InferredTarget.getValue(), BaseMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
diag::note_implicit_member_target_infer_collision)
|
||||
<< (unsigned)CSM << *InferredTarget << BaseMethodTarget;
|
||||
<< (unsigned)CSM << InferredTarget.getValue() << BaseMethodTarget;
|
||||
}
|
||||
MemberDecl->addAttr(CUDAInvalidTargetAttr::CreateImplicit(Context));
|
||||
return true;
|
||||
|
@ -424,12 +425,14 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = FieldMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
*InferredTarget, FieldMethodTarget, InferredTarget.getPointer());
|
||||
InferredTarget.getValue(), FieldMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
diag::note_implicit_member_target_infer_collision)
|
||||
<< (unsigned)CSM << *InferredTarget << FieldMethodTarget;
|
||||
<< (unsigned)CSM << InferredTarget.getValue()
|
||||
<< FieldMethodTarget;
|
||||
}
|
||||
MemberDecl->addAttr(CUDAInvalidTargetAttr::CreateImplicit(Context));
|
||||
return true;
|
||||
|
@ -441,10 +444,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) {
|
||||
if (*InferredTarget == CFT_Device)
|
||||
if (InferredTarget.hasValue()) {
|
||||
if (InferredTarget.getValue() == CFT_Device)
|
||||
NeedsH = false;
|
||||
else if (*InferredTarget == CFT_Host)
|
||||
else if (InferredTarget.getValue() == CFT_Host)
|
||||
NeedsD = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1873,9 +1873,9 @@ static ExprResult SemaBuiltinLaunder(Sema &S, CallExpr *TheCall) {
|
|||
return 2;
|
||||
return llvm::Optional<unsigned>{};
|
||||
}();
|
||||
if (DiagSelect) {
|
||||
if (DiagSelect.hasValue()) {
|
||||
S.Diag(TheCall->getBeginLoc(), diag::err_builtin_launder_invalid_arg)
|
||||
<< *DiagSelect << TheCall->getSourceRange();
|
||||
<< DiagSelect.getValue() << 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.has_value(), M.ResultType != nullptr,
|
||||
M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
|
||||
std::make_tuple(M.ArgTypes.hasValue(), M.ResultType != nullptr,
|
||||
M.Operator) > std::make_tuple(O.ArgTypes.hasValue(),
|
||||
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 && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
if (AlignmentParam.hasValue() && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
FD->addAttr(AllocAlignAttr::CreateImplicit(
|
||||
Context, ParamIdx(*AlignmentParam, FD), FD->getLocation()));
|
||||
Context, ParamIdx(AlignmentParam.getValue(), 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)
|
||||
if (DevTy.hasValue())
|
||||
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)
|
||||
if (isInOpenMPDeclareTargetContext() || DevTy.hasValue())
|
||||
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;
|
||||
return MappedVersion.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
auto Major = Version.getMajor();
|
||||
auto NewMajor = Major >= 9 ? Major - 7 : 0;
|
||||
if (NewMajor >= 2) {
|
||||
if (Version.getMinor()) {
|
||||
if (Version.getSubminor())
|
||||
return VersionTuple(NewMajor, *Version.getMinor(),
|
||||
*Version.getSubminor());
|
||||
if (Version.getMinor().hasValue()) {
|
||||
if (Version.getSubminor().hasValue())
|
||||
return VersionTuple(NewMajor, Version.getMinor().getValue(),
|
||||
Version.getSubminor().getValue());
|
||||
else
|
||||
return VersionTuple(NewMajor, *Version.getMinor());
|
||||
return VersionTuple(NewMajor, Version.getMinor().getValue());
|
||||
}
|
||||
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 && !AllocType->isDependentType()) {
|
||||
if (!ArraySize.hasValue() && !AllocType->isDependentType()) {
|
||||
// For non-array operator new, we only want to allocate one element.
|
||||
AllocationSize = SingleEltSize;
|
||||
} else if (KnownArraySize && !AllocType->isDependentType()) {
|
||||
} else if (KnownArraySize.hasValue() && !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.has_value();
|
||||
return Top->OrderedRegion.hasValue();
|
||||
return false;
|
||||
}
|
||||
/// Returns optional parameter for the ordered region.
|
||||
std::pair<const Expr *, OMPOrderedClause *> getOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Top = getTopOfStackOrNull())
|
||||
if (Top->OrderedRegion)
|
||||
return *Top->OrderedRegion;
|
||||
if (Top->OrderedRegion.hasValue())
|
||||
return Top->OrderedRegion.getValue();
|
||||
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.has_value();
|
||||
return Parent->OrderedRegion.hasValue();
|
||||
return false;
|
||||
}
|
||||
/// Returns optional parameter for the ordered region.
|
||||
std::pair<const Expr *, OMPOrderedClause *>
|
||||
getParentOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Parent = getSecondOnStackOrNull())
|
||||
if (Parent->OrderedRegion)
|
||||
return *Parent->OrderedRegion;
|
||||
if (Parent->OrderedRegion.hasValue())
|
||||
return Parent->OrderedRegion.getValue();
|
||||
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.has_value(); }
|
||||
bool doesInitDependOnLC() const { return InitDependOnLC.hasValue(); }
|
||||
/// Returns true if the condition forms non-rectangular loop.
|
||||
bool doesCondDependOnLC() const { return CondDependOnLC.has_value(); }
|
||||
bool doesCondDependOnLC() const { return CondDependOnLC.hasValue(); }
|
||||
/// 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,20 +7761,21 @@ bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
|
|||
bool IsConstZero = Result && !Result->getBoolValue();
|
||||
|
||||
// != with increment is treated as <; != with decrement is treated as >
|
||||
if (!TestIsLessOp)
|
||||
if (!TestIsLessOp.hasValue())
|
||||
TestIsLessOp = IsConstPos || (IsUnsigned && !Subtract);
|
||||
if (UB && (IsConstZero ||
|
||||
(*TestIsLessOp ? (IsConstNeg || (IsUnsigned && Subtract))
|
||||
: (IsConstPos || (IsUnsigned && !Subtract))))) {
|
||||
if (UB &&
|
||||
(IsConstZero || (TestIsLessOp.getValue()
|
||||
? (IsConstNeg || (IsUnsigned && Subtract))
|
||||
: (IsConstPos || (IsUnsigned && !Subtract))))) {
|
||||
SemaRef.Diag(NewStep->getExprLoc(),
|
||||
diag::err_omp_loop_incr_not_compatible)
|
||||
<< LCDecl << *TestIsLessOp << NewStep->getSourceRange();
|
||||
<< LCDecl << TestIsLessOp.getValue() << NewStep->getSourceRange();
|
||||
SemaRef.Diag(ConditionLoc,
|
||||
diag::note_omp_loop_cond_requres_compatible_incr)
|
||||
<< *TestIsLessOp << ConditionSrcRange;
|
||||
<< TestIsLessOp.getValue() << ConditionSrcRange;
|
||||
return true;
|
||||
}
|
||||
if (*TestIsLessOp == Subtract) {
|
||||
if (TestIsLessOp.getValue() == Subtract) {
|
||||
NewStep =
|
||||
SemaRef.CreateBuiltinUnaryOp(NewStep->getExprLoc(), UO_Minus, NewStep)
|
||||
.get();
|
||||
|
@ -8529,8 +8530,8 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
|
|||
UBVal = MinUB.get();
|
||||
}
|
||||
}
|
||||
Expr *UBExpr = *TestIsLessOp ? UBVal : LBVal;
|
||||
Expr *LBExpr = *TestIsLessOp ? LBVal : UBVal;
|
||||
Expr *UBExpr = TestIsLessOp.getValue() ? UBVal : LBVal;
|
||||
Expr *LBExpr = TestIsLessOp.getValue() ? LBVal : UBVal;
|
||||
Expr *Upper = tryBuildCapture(SemaRef, UBExpr, Captures).get();
|
||||
Expr *Lower = tryBuildCapture(SemaRef, LBExpr, Captures).get();
|
||||
if (!Upper || !Lower)
|
||||
|
@ -8593,12 +8594,12 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
|
|||
// init value.
|
||||
Expr *MinExpr = nullptr;
|
||||
Expr *MaxExpr = nullptr;
|
||||
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 *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 *Lower =
|
||||
LBNonRect ? LBExpr : tryBuildCapture(SemaRef, LBExpr, Captures).get();
|
||||
Expr *Upper =
|
||||
|
@ -8720,11 +8721,11 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
|
|||
if (!NewLB.isUsable() || !NewUB.isUsable())
|
||||
return nullptr;
|
||||
|
||||
ExprResult CondExpr =
|
||||
SemaRef.BuildBinOp(S, DefaultLoc,
|
||||
*TestIsLessOp ? (TestIsStrictOp ? BO_LT : BO_LE)
|
||||
: (TestIsStrictOp ? BO_GT : BO_GE),
|
||||
NewLB.get(), NewUB.get());
|
||||
ExprResult CondExpr = SemaRef.BuildBinOp(
|
||||
S, DefaultLoc,
|
||||
TestIsLessOp.getValue() ? (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))
|
||||
|
@ -8799,10 +8800,12 @@ Expr *OpenMPIterationSpaceChecker::buildOrderedLoopData(
|
|||
!SemaRef.getLangOpts().CPlusPlus)
|
||||
return nullptr;
|
||||
// Upper - Lower
|
||||
Expr *Upper =
|
||||
*TestIsLessOp ? Cnt : tryBuildCapture(SemaRef, LB, Captures).get();
|
||||
Expr *Lower =
|
||||
*TestIsLessOp ? tryBuildCapture(SemaRef, LB, Captures).get() : Cnt;
|
||||
Expr *Upper = TestIsLessOp.getValue()
|
||||
? Cnt
|
||||
: tryBuildCapture(SemaRef, LB, Captures).get();
|
||||
Expr *Lower = TestIsLessOp.getValue()
|
||||
? tryBuildCapture(SemaRef, LB, Captures).get()
|
||||
: Cnt;
|
||||
if (!Upper || !Lower)
|
||||
return nullptr;
|
||||
|
||||
|
@ -22177,27 +22180,27 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
|
|||
auto *VD = cast<ValueDecl>(ND);
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
if (ActiveAttr && (*ActiveAttr)->getDevType() != DTCI.DT &&
|
||||
(*ActiveAttr)->getLevel() == Level) {
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getDevType() != DTCI.DT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_device_type_mismatch)
|
||||
<< OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(DTCI.DT)
|
||||
<< OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(
|
||||
ActiveAttr.value()->getDevType());
|
||||
ActiveAttr.getValue()->getDevType());
|
||||
return;
|
||||
}
|
||||
if (ActiveAttr && (*ActiveAttr)->getMapType() != MT &&
|
||||
(*ActiveAttr)->getLevel() == Level) {
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getMapType() != MT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_declare_target_to_and_link) << ND;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveAttr && (*ActiveAttr)->getLevel() == Level)
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() == Level)
|
||||
return;
|
||||
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = *DTCI.Indirect;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
}
|
||||
|
@ -22291,13 +22294,13 @@ void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
|
|||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
unsigned Level = DeclareTargetNesting.size();
|
||||
if (ActiveAttr && (*ActiveAttr)->getLevel() >= Level)
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() >= Level)
|
||||
return;
|
||||
DeclareTargetContextInfo &DTCI = DeclareTargetNesting.back();
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = *DTCI.Indirect;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
}
|
||||
|
|
|
@ -469,8 +469,8 @@ static void instantiateOMPDeclareVariantAttr(
|
|||
if (!DeclVarData)
|
||||
return;
|
||||
|
||||
E = DeclVarData->second;
|
||||
FD = DeclVarData->first;
|
||||
E = DeclVarData.getValue().second;
|
||||
FD = DeclVarData.getValue().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.has_value()
|
||||
<< U.FileName;
|
||||
<< WritingModule->getFullModuleName() << U.Size.hasValue()
|
||||
<< 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)
|
||||
if (!errorNode.hasValue())
|
||||
errorNode = C.generateNonFatalErrorNode();
|
||||
|
||||
if (!*errorNode)
|
||||
if (!errorNode.getValue())
|
||||
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);
|
||||
auto R = std::make_unique<PathSensitiveBugReport>(*BT, os.str(),
|
||||
errorNode.getValue());
|
||||
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 || !DVal2)
|
||||
if (!DVal1.hasValue() || !DVal2.hasValue())
|
||||
return State;
|
||||
|
||||
auto ValuesEqual =
|
||||
C.getSValBuilder().evalEQ(State, *DVal1, *DVal2).getAs<DefinedSVal>();
|
||||
if (!ValuesEqual)
|
||||
if (!ValuesEqual.hasValue())
|
||||
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, FlagsEx->getType())
|
||||
.castAs<NonLoc>();
|
||||
.makeIntVal(KernelZeroFlagVal.getValue(), 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)
|
||||
State = *MaybeState;
|
||||
if (MaybeState.hasValue())
|
||||
State = MaybeState.getValue();
|
||||
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)
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
if (!CheckKind.hasValue())
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
|
||||
I.getKey()->dumpToStream(Out);
|
||||
Out << " : ";
|
||||
I.getData().dump(Out);
|
||||
if (CheckKind)
|
||||
if (CheckKind.hasValue())
|
||||
Out << " (" << CheckNames[*CheckKind].getName() << ")";
|
||||
Out << NL;
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ void NonNullParamChecker::checkPreCall(const CallEvent &Call,
|
|||
if (!DV)
|
||||
continue;
|
||||
|
||||
assert(!HasRefTypeParam || isa<Loc>(*DV));
|
||||
assert(!HasRefTypeParam || isa<Loc>(DV.getValue()));
|
||||
|
||||
// Process the case when the argument is not a location.
|
||||
if (ExpectedToBeNonNull && !isa<Loc>(*DV)) {
|
||||
if (ExpectedToBeNonNull && !isa<Loc>(DV.getValue())) {
|
||||
// If the argument is a union type, we want to handle a potential
|
||||
// transparent_union GCC extension.
|
||||
if (!ArgE)
|
||||
|
|
|
@ -234,8 +234,7 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext &C,
|
|||
}
|
||||
NonLoc oflags = V.castAs<NonLoc>();
|
||||
NonLoc ocreateFlag = C.getSValBuilder()
|
||||
.makeIntVal(*Val_O_CREAT, oflagsEx->getType())
|
||||
.castAs<NonLoc>();
|
||||
.makeIntVal(Val_O_CREAT.getValue(), 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 && "User mode is invalid.");
|
||||
return *K;
|
||||
assert(K.hasValue() && "User mode is invalid.");
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
CTUPhase1InliningKind AnalyzerOptions::getCTUPhase1Inlining() const {
|
||||
|
@ -88,8 +88,8 @@ CTUPhase1InliningKind AnalyzerOptions::getCTUPhase1Inlining() const {
|
|||
.Case("small", CTUPhase1InliningKind::Small)
|
||||
.Case("all", CTUPhase1InliningKind::All)
|
||||
.Default(None);
|
||||
assert(K && "CTU inlining mode is invalid.");
|
||||
return *K;
|
||||
assert(K.hasValue() && "CTU inlining mode is invalid.");
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
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 && "IPA Mode is invalid.");
|
||||
assert(K.hasValue() && "IPA Mode is invalid.");
|
||||
|
||||
return *K;
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -2363,15 +2363,15 @@ PathSensitiveBugReport::getInterestingnessKind(const MemRegion *R) const {
|
|||
}
|
||||
|
||||
bool PathSensitiveBugReport::isInteresting(SVal V) const {
|
||||
return getInterestingnessKind(V).has_value();
|
||||
return getInterestingnessKind(V).hasValue();
|
||||
}
|
||||
|
||||
bool PathSensitiveBugReport::isInteresting(SymbolRef sym) const {
|
||||
return getInterestingnessKind(sym).has_value();
|
||||
return getInterestingnessKind(sym).hasValue();
|
||||
}
|
||||
|
||||
bool PathSensitiveBugReport::isInteresting(const MemRegion *R) const {
|
||||
return getInterestingnessKind(R).has_value();
|
||||
return getInterestingnessKind(R).hasValue();
|
||||
}
|
||||
|
||||
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)
|
||||
event->setPrunable(*shouldPrune);
|
||||
if (shouldPrune.hasValue())
|
||||
event->setPrunable(shouldPrune.getValue());
|
||||
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.value()->getBoolValue() ? "true" : "false");
|
||||
Out << (IntValue.getValue()->getBoolValue() ? "true" : "false");
|
||||
else
|
||||
Out << *IntValue.value();
|
||||
Out << *IntValue.getValue();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3279,10 +3279,10 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor(
|
|||
|
||||
// And check for satisfiability
|
||||
Optional<bool> IsSAT = RefutationSolver->check();
|
||||
if (!IsSAT)
|
||||
if (!IsSAT.hasValue())
|
||||
return;
|
||||
|
||||
if (!*IsSAT)
|
||||
if (!IsSAT.getValue())
|
||||
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) {
|
||||
if (!*MayInline)
|
||||
if (MayInline.hasValue()) {
|
||||
if (!MayInline.getValue())
|
||||
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) << '\n';
|
||||
EmitString(o, MacroName.getValue()) << '\n';
|
||||
|
||||
// Output what it expands into.
|
||||
Indent(o, indent) << "<key>expansion</key>";
|
||||
EmitString(o, *ExpansionText) << '\n';
|
||||
EmitString(o, ExpansionText.getValue()) << '\n';
|
||||
|
||||
// Finish up.
|
||||
--indent;
|
||||
|
|
|
@ -114,11 +114,11 @@ bool RVVType::verifyType() const {
|
|||
return false;
|
||||
if (isScalar())
|
||||
return true;
|
||||
if (!Scale)
|
||||
if (!Scale.hasValue())
|
||||
return false;
|
||||
if (isFloat() && ElementBitwidth == 8)
|
||||
return false;
|
||||
unsigned V = *Scale;
|
||||
unsigned V = Scale.getValue();
|
||||
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)
|
||||
if (!T.hasValue())
|
||||
return llvm::None;
|
||||
// Record legal type index
|
||||
Types.push_back(*T);
|
||||
Types.push_back(T.getValue());
|
||||
}
|
||||
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)
|
||||
if (NewReplacement.hasValue())
|
||||
Message += "\nNew replacement: " + NewReplacement->toString();
|
||||
if (ExistingReplacement)
|
||||
if (ExistingReplacement.hasValue())
|
||||
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) {
|
||||
if (OptCL.hasValue()) {
|
||||
SmallVector<const char *, 8> PrependedOpts;
|
||||
getCLEnvVarOptions(*OptCL, Saver, PrependedOpts);
|
||||
getCLEnvVarOptions(OptCL.getValue(), 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_) {
|
||||
if (Opt_CL_.hasValue()) {
|
||||
SmallVector<const char *, 8> AppendedOpts;
|
||||
getCLEnvVarOptions(*Opt_CL_, Saver, AppendedOpts);
|
||||
getCLEnvVarOptions(Opt_CL_.getValue(), 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)
|
||||
if (!V.hasValue())
|
||||
continue;
|
||||
return *V;
|
||||
return V.getValue();
|
||||
}
|
||||
} 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)
|
||||
if (!V.hasValue())
|
||||
continue;
|
||||
return *V;
|
||||
return V.getValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -675,9 +675,9 @@ Optional<bool> CursorVisitor::handleDeclForVisitation(const Decl *D) {
|
|||
}
|
||||
|
||||
const Optional<bool> V = shouldVisitCursor(Cursor);
|
||||
if (!V)
|
||||
if (!V.hasValue())
|
||||
return None;
|
||||
if (!*V)
|
||||
if (!V.getValue())
|
||||
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)
|
||||
if (!V.hasValue())
|
||||
continue;
|
||||
if (!*V)
|
||||
if (!V.getValue())
|
||||
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)
|
||||
if (Minor.hasValue())
|
||||
Out.Minor = *Minor;
|
||||
else
|
||||
return Out;
|
||||
|
||||
Optional<unsigned> Subminor = In.getSubminor();
|
||||
if (Subminor)
|
||||
if (Subminor.hasValue())
|
||||
Out.Subminor = *Subminor;
|
||||
|
||||
return Out;
|
||||
|
|
|
@ -449,27 +449,27 @@ TEST(ParserTest, ParseMultiline) {
|
|||
)
|
||||
)matcher";
|
||||
Diagnostics Error;
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error));
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
|
||||
}
|
||||
|
||||
{
|
||||
Code = R"matcher(decl(decl()
|
||||
, decl()))matcher";
|
||||
Diagnostics Error;
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
|
||||
}
|
||||
|
||||
{
|
||||
Code = R"matcher(decl(decl(),
|
||||
decl()))matcher";
|
||||
Diagnostics Error;
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
|
||||
}
|
||||
|
||||
{
|
||||
Code = "namedDecl(hasName(\"n\"\n))";
|
||||
Diagnostics Error;
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).has_value());
|
||||
EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -40,8 +40,9 @@ isAnnotationDirectlyAfterStatement(const Stmt *Stmt, unsigned AnnotationBegin,
|
|||
auto NextToken =
|
||||
Lexer::findNextToken(Stmt->getEndLoc(), SourceManager, LangOptions);
|
||||
|
||||
while (NextToken && SourceManager.getFileOffset(NextToken->getLocation()) <
|
||||
AnnotationBegin) {
|
||||
while (NextToken.hasValue() &&
|
||||
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].has_value());
|
||||
EXPECT_TRUE(BlockStates[1].has_value());
|
||||
EXPECT_TRUE(BlockStates[0].hasValue());
|
||||
EXPECT_TRUE(BlockStates[1].hasValue());
|
||||
}
|
||||
|
||||
struct NonConvergingLattice {
|
||||
|
|
|
@ -121,14 +121,14 @@ TEST_F(MacroExpansionContextTest, IgnoresPragmas) {
|
|||
EXPECT_EQ("\n=============== ExpansionRanges ===============\n",
|
||||
dumpExpansionRanges(*Ctx));
|
||||
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(2, 1)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 1)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(2, 1)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 1)).hasValue());
|
||||
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(2, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(2, 3)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 3)).hasValue());
|
||||
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 3)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 3)).hasValue());
|
||||
}
|
||||
|
||||
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)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 11)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(2, 11)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(2, 11)).hasValue());
|
||||
|
||||
// The space before the first expansion of EMPTY.
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 9)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 9)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 9)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 9)).hasValue());
|
||||
|
||||
// The beginning of the first expansion of EMPTY.
|
||||
EXPECT_TRUE(Ctx->getExpandedText(at(3, 10)).has_value());
|
||||
EXPECT_TRUE(Ctx->getOriginalText(at(3, 10)).has_value());
|
||||
EXPECT_TRUE(Ctx->getExpandedText(at(3, 10)).hasValue());
|
||||
EXPECT_TRUE(Ctx->getOriginalText(at(3, 10)).hasValue());
|
||||
|
||||
// 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)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 11)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 11)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 11)).hasValue());
|
||||
|
||||
// Same here.
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 12)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 12)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(3, 12)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(3, 12)).hasValue());
|
||||
|
||||
// The beginning of the last expansion of EMPTY.
|
||||
EXPECT_TRUE(Ctx->getExpandedText(at(4, 1)).has_value());
|
||||
EXPECT_TRUE(Ctx->getOriginalText(at(4, 1)).has_value());
|
||||
EXPECT_TRUE(Ctx->getExpandedText(at(4, 1)).hasValue());
|
||||
EXPECT_TRUE(Ctx->getOriginalText(at(4, 1)).hasValue());
|
||||
|
||||
// Same as for the 3:11 case.
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(4, 2)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(4, 2)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(4, 2)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(4, 2)).hasValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, EmptyExpansions) {
|
||||
|
@ -181,14 +181,14 @@ EMPTY zz
|
|||
// A b cd ef gh
|
||||
// zz
|
||||
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(3, 10)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(3, 10)));
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(3, 10)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(3, 10)).getValue());
|
||||
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(3, 19)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(3, 19)));
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(3, 19)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(3, 19)).getValue());
|
||||
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(4, 1)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(4, 1)));
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 1)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 1)).getValue());
|
||||
}
|
||||
|
||||
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)));
|
||||
EXPECT_EQ("WOOF", Ctx->getOriginalText(at(4, 10)).getValue());
|
||||
|
||||
EXPECT_EQ("", *Ctx->getExpandedText(at(4, 18)));
|
||||
EXPECT_EQ("EMPTY", *Ctx->getOriginalText(at(4, 18)));
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 18)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 18)).getValue());
|
||||
}
|
||||
|
||||
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)));
|
||||
EXPECT_EQ("WOOF($$ ef)", *Ctx->getOriginalText(at(4, 10)));
|
||||
EXPECT_EQ("$$ ef ()))1", Ctx->getExpandedText(at(4, 10)).getValue());
|
||||
EXPECT_EQ("WOOF($$ ef)", Ctx->getOriginalText(at(4, 10)).getValue());
|
||||
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 22)).value());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 22)).value());
|
||||
EXPECT_EQ("", Ctx->getExpandedText(at(4, 22)).getValue());
|
||||
EXPECT_EQ("EMPTY", Ctx->getOriginalText(at(4, 22)).getValue());
|
||||
|
||||
EXPECT_EQ("WOOF ()))1", Ctx->getExpandedText(at(5, 3)).value());
|
||||
EXPECT_EQ("WOOF(WOOF)", Ctx->getOriginalText(at(5, 3)).value());
|
||||
EXPECT_EQ("WOOF ()))1", Ctx->getExpandedText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("WOOF(WOOF)", Ctx->getOriginalText(at(5, 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());
|
||||
EXPECT_EQ("bar barr ()))1()))1", Ctx->getExpandedText(at(6, 3)).getValue());
|
||||
EXPECT_EQ("WOOF(WOOF(bar barr))", Ctx->getOriginalText(at(6, 3)).getValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, VariadicMacros) {
|
||||
|
@ -251,23 +251,24 @@ TEST_F(MacroExpansionContextTest, VariadicMacros) {
|
|||
// fprintf (stderr, "success!\n" );
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n",))",
|
||||
Ctx->getExpandedText(at(3, 3)).value());
|
||||
Ctx->getExpandedText(at(3, 3)).getValue());
|
||||
EXPECT_EQ(R"(eprintf("success!\n", ))",
|
||||
Ctx->getOriginalText(at(3, 3)).value());
|
||||
Ctx->getOriginalText(at(3, 3)).getValue());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n",))",
|
||||
Ctx->getExpandedText(at(4, 3)).value());
|
||||
EXPECT_EQ(R"(eprintf("success!\n"))", Ctx->getOriginalText(at(4, 3)).value());
|
||||
Ctx->getExpandedText(at(4, 3)).getValue());
|
||||
EXPECT_EQ(R"(eprintf("success!\n"))",
|
||||
Ctx->getOriginalText(at(4, 3)).getValue());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n"))",
|
||||
Ctx->getExpandedText(at(8, 3)).value());
|
||||
Ctx->getExpandedText(at(8, 3)).getValue());
|
||||
EXPECT_EQ(R"(eprintf2("success!\n", ))",
|
||||
Ctx->getOriginalText(at(8, 3)).value());
|
||||
Ctx->getOriginalText(at(8, 3)).getValue());
|
||||
|
||||
EXPECT_EQ(R"(fprintf (stderr ,"success!\n"))",
|
||||
Ctx->getExpandedText(at(9, 3)).value());
|
||||
Ctx->getExpandedText(at(9, 3)).getValue());
|
||||
EXPECT_EQ(R"(eprintf2("success!\n"))",
|
||||
Ctx->getOriginalText(at(9, 3)).value());
|
||||
Ctx->getOriginalText(at(9, 3)).getValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, ConcatenationMacros) {
|
||||
|
@ -285,12 +286,12 @@ TEST_F(MacroExpansionContextTest, ConcatenationMacros) {
|
|||
// };
|
||||
|
||||
EXPECT_EQ(R"({"quit",quit_command })",
|
||||
Ctx->getExpandedText(at(4, 5)).value());
|
||||
EXPECT_EQ("COMMAND(quit)", Ctx->getOriginalText(at(4, 5)).value());
|
||||
Ctx->getExpandedText(at(4, 5)).getValue());
|
||||
EXPECT_EQ("COMMAND(quit)", Ctx->getOriginalText(at(4, 5)).getValue());
|
||||
|
||||
EXPECT_EQ(R"({"help",help_command })",
|
||||
Ctx->getExpandedText(at(5, 5)).value());
|
||||
EXPECT_EQ("COMMAND(help)", Ctx->getOriginalText(at(5, 5)).value());
|
||||
Ctx->getExpandedText(at(5, 5)).getValue());
|
||||
EXPECT_EQ("COMMAND(help)", Ctx->getOriginalText(at(5, 5)).getValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, StringizingMacros) {
|
||||
|
@ -315,14 +316,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)).value());
|
||||
EXPECT_EQ("WARN_IF (x == 0)", Ctx->getOriginalText(at(6, 3)).value());
|
||||
Ctx->getExpandedText(at(6, 3)).getValue());
|
||||
EXPECT_EQ("WARN_IF (x == 0)", Ctx->getOriginalText(at(6, 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"("foo")", Ctx->getExpandedText(at(11, 3)).getValue());
|
||||
EXPECT_EQ("str (foo)", Ctx->getOriginalText(at(11, 3)).getValue());
|
||||
|
||||
EXPECT_EQ(R"("4")", Ctx->getExpandedText(at(12, 3)).value());
|
||||
EXPECT_EQ("xstr (foo)", Ctx->getOriginalText(at(12, 3)).value());
|
||||
EXPECT_EQ(R"("4")", Ctx->getExpandedText(at(12, 3)).getValue());
|
||||
EXPECT_EQ("xstr (foo)", Ctx->getOriginalText(at(12, 3)).getValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, StringizingVariadicMacros) {
|
||||
|
@ -351,18 +352,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)).value());
|
||||
EXPECT_EQ("q(g)", Ctx->getOriginalText(at(11, 3)).value());
|
||||
Ctx->getExpandedText(at(11, 3)).getValue());
|
||||
EXPECT_EQ("q(g)", Ctx->getOriginalText(at(11, 3)).getValue());
|
||||
|
||||
EXPECT_EQ(R"res("apple"(apple )"apple"(appleapple )))))res",
|
||||
Ctx->getExpandedText(at(12, 3)).value());
|
||||
EXPECT_EQ("q(xstr)", Ctx->getOriginalText(at(12, 3)).value());
|
||||
Ctx->getExpandedText(at(12, 3)).getValue());
|
||||
EXPECT_EQ("q(xstr)", Ctx->getOriginalText(at(12, 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("zz !*)!x )!**y ", Ctx->getExpandedText(at(13, 3)).getValue());
|
||||
EXPECT_EQ("g(RParen2x)", Ctx->getOriginalText(at(13, 3)).getValue());
|
||||
|
||||
EXPECT_EQ("!))*))", Ctx->getExpandedText(at(14, 3)).value());
|
||||
EXPECT_EQ("f( RParen2x )", Ctx->getOriginalText(at(14, 3)).value());
|
||||
EXPECT_EQ("!))*))", Ctx->getExpandedText(at(14, 3)).getValue());
|
||||
EXPECT_EQ("f( RParen2x )", Ctx->getOriginalText(at(14, 3)).getValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, RedefUndef) {
|
||||
|
@ -380,15 +381,15 @@ TEST_F(MacroExpansionContextTest, RedefUndef) {
|
|||
// Hi(Hi)
|
||||
|
||||
// FIXME: Extra space follows every identifier.
|
||||
EXPECT_EQ("Welcome Adam ", Ctx->getExpandedText(at(3, 3)).value());
|
||||
EXPECT_EQ("Hi(Adam)", Ctx->getOriginalText(at(3, 3)).value());
|
||||
EXPECT_EQ("Welcome Adam ", Ctx->getExpandedText(at(3, 3)).getValue());
|
||||
EXPECT_EQ("Hi(Adam)", Ctx->getOriginalText(at(3, 3)).getValue());
|
||||
|
||||
EXPECT_EQ("Willkommen ", Ctx->getExpandedText(at(5, 3)).value());
|
||||
EXPECT_EQ("Hi", Ctx->getOriginalText(at(5, 3)).value());
|
||||
EXPECT_EQ("Willkommen ", Ctx->getExpandedText(at(5, 3)).getValue());
|
||||
EXPECT_EQ("Hi", Ctx->getOriginalText(at(5, 3)).getValue());
|
||||
|
||||
// There was no macro expansion at 7:3, we should expect None.
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(7, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(7, 3)).has_value());
|
||||
EXPECT_FALSE(Ctx->getExpandedText(at(7, 3)).hasValue());
|
||||
EXPECT_FALSE(Ctx->getOriginalText(at(7, 3)).hasValue());
|
||||
}
|
||||
|
||||
TEST_F(MacroExpansionContextTest, UnbalacedParenthesis) {
|
||||
|
@ -410,11 +411,12 @@ TEST_F(MacroExpansionContextTest, UnbalacedParenthesis) {
|
|||
// fun();
|
||||
// int x = ((1, fun(), 1, fun(), 1 ));
|
||||
|
||||
EXPECT_EQ("fun ()", Ctx->getExpandedText(at(8, 3)).value());
|
||||
EXPECT_EQ("applyInt )", Ctx->getOriginalText(at(8, 3)).value());
|
||||
EXPECT_EQ("fun ()", Ctx->getExpandedText(at(8, 3)).getValue());
|
||||
EXPECT_EQ("applyInt )", Ctx->getOriginalText(at(8, 3)).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());
|
||||
EXPECT_EQ("((1,fun (),1,fun (),1",
|
||||
Ctx->getExpandedText(at(13, 12)).getValue());
|
||||
EXPECT_EQ("f(f(1))", Ctx->getOriginalText(at(13, 12)).getValue());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -64,14 +64,14 @@ TEST(DarwinSDKInfo, VersionMappingParseEmpty) {
|
|||
llvm::json::Object Obj({});
|
||||
EXPECT_FALSE(
|
||||
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj, VersionTuple())
|
||||
.has_value());
|
||||
.hasValue());
|
||||
}
|
||||
|
||||
TEST(DarwinSDKInfo, VersionMappingParseError) {
|
||||
llvm::json::Object Obj({{"test", "1.2"}});
|
||||
EXPECT_FALSE(
|
||||
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj, VersionTuple())
|
||||
.has_value());
|
||||
.hasValue());
|
||||
}
|
||||
|
||||
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().has_value());
|
||||
if (TestConsumer.result()) {
|
||||
EXPECT_TRUE(TestConsumer.result().hasValue());
|
||||
if (TestConsumer.result().hasValue()) {
|
||||
EXPECT_TRUE(*TestConsumer.result());
|
||||
}
|
||||
if ((TestConsumer.result() && !*TestConsumer.result()) ||
|
||||
!TestConsumer.result())
|
||||
if ((TestConsumer.result().hasValue() && !TestConsumer.result().getValue()) ||
|
||||
!TestConsumer.result().hasValue())
|
||||
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.has_value());
|
||||
EXPECT_TRUE(FoundFile.hasValue());
|
||||
EXPECT_TRUE(IsFrameworkFound);
|
||||
auto &FE = *FoundFile;
|
||||
auto &FE = FoundFile.getValue();
|
||||
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.has_value());
|
||||
EXPECT_TRUE(FoundFile.hasValue());
|
||||
EXPECT_TRUE(IsMapped);
|
||||
auto &FE = *FoundFile;
|
||||
auto &FE = FoundFile.getValue();
|
||||
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.has_value());
|
||||
ASSERT_TRUE(D.hasValue());
|
||||
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.has_value());
|
||||
ASSERT_TRUE(LD.hasValue());
|
||||
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)
|
||||
if (ExpectedExisting.hasValue())
|
||||
OS << "Expected existing replacement: " << ExpectedExisting->toString()
|
||||
<< "\n";
|
||||
if (RE.getExistingReplacement())
|
||||
if (RE.getExistingReplacement().hasValue())
|
||||
OS << "Actual existing replacement: "
|
||||
<< RE.getExistingReplacement()->toString() << "\n";
|
||||
}
|
||||
if (ExpectedNew != RE.getNewReplacement()) {
|
||||
OS << "Expected New != Actual New.\n";
|
||||
if (ExpectedNew)
|
||||
if (ExpectedNew.hasValue())
|
||||
OS << "Expected new replacement: " << ExpectedNew->toString() << "\n";
|
||||
if (RE.getNewReplacement())
|
||||
if (RE.getNewReplacement().hasValue())
|
||||
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)
|
||||
printType(*T);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
}
|
||||
// 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) {
|
||||
printType(*T);
|
||||
if (T.hasValue()) {
|
||||
printType(T.getValue());
|
||||
auto UT = RVVType::computeType(
|
||||
BT, Log2LMUL,
|
||||
PrototypeDescriptor(BaseTypeModifier::Vector,
|
||||
VectorTypeModifier::NoModifier,
|
||||
TypeModifier::UnsignedInteger));
|
||||
printType(*UT);
|
||||
printType(UT.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
printType(*T);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
}
|
||||
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)
|
||||
printType(*T);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
}
|
||||
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)
|
||||
printType(*T);
|
||||
if (T.hasValue())
|
||||
printType(T.getValue());
|
||||
}
|
||||
OS << "#endif\n\n";
|
||||
|
||||
|
|
|
@ -446,9 +446,7 @@ 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).has_value();
|
||||
}
|
||||
bool isLHS(fir::ArrayLoadOp load) { return findArgPosition(load).hasValue(); }
|
||||
|
||||
/// `load` must be a LHS array_load. Determine the threaded inner argument
|
||||
/// corresponding to this load.
|
||||
|
@ -467,15 +465,15 @@ public:
|
|||
|
||||
llvm::Optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
|
||||
assert(i < lhsBases.size());
|
||||
if (lhsBases[counter])
|
||||
return findBinding(*lhsBases[counter]);
|
||||
if (lhsBases[counter].hasValue())
|
||||
return findBinding(lhsBases[counter].getValue());
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
/// Return the outermost loop in this FORALL nest.
|
||||
fir::DoLoopOp getOuterLoop() {
|
||||
assert(outerLoop);
|
||||
return *outerLoop;
|
||||
assert(outerLoop.hasValue());
|
||||
return outerLoop.getValue();
|
||||
}
|
||||
|
||||
/// 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,
|
||||
/*lbounds=*/llvm::None,
|
||||
/*takeLboundsIfRealloc=*/false,
|
||||
*lhsRealloc);
|
||||
fir::factory::finalizeRealloc(
|
||||
*builder, loc, lhsMutableBox.getValue(),
|
||||
/*lbounds=*/llvm::None, /*takeLboundsIfRealloc=*/false,
|
||||
lhsRealloc.getValue());
|
||||
},
|
||||
|
||||
// [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),
|
||||
arrayResultShape, resultLengths);
|
||||
builder.create<fir::SaveResultOp>(
|
||||
loc, call.getResult(0), fir::getBase(allocatedResult.getValue()),
|
||||
arrayResultShape, resultLengths);
|
||||
|
||||
if (allocatedResult) {
|
||||
allocatedResult->match(
|
||||
|
@ -4110,10 +4110,10 @@ private:
|
|||
mlir::Value{});
|
||||
}
|
||||
} else if (isBoundsRemap()) {
|
||||
auto lbs = *lbounds;
|
||||
auto lbs = lbounds.getValue();
|
||||
if (lbs.size() > 0) {
|
||||
// Rebox the value with user-specified shift and shape.
|
||||
auto shapeShiftArgs = flatZip(lbs, *ubounds);
|
||||
auto shapeShiftArgs = flatZip(lbs, ubounds.getValue());
|
||||
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
|
||||
? *ccStoreToDest
|
||||
auto lambda = ccStoreToDest.hasValue()
|
||||
? ccStoreToDest.getValue()
|
||||
: 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)
|
||||
ccPrelude.value()(shape);
|
||||
if (ccPrelude.hasValue())
|
||||
ccPrelude.getValue()(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)
|
||||
return ccLoadDest.value()(shape);
|
||||
if (ccLoadDest.hasValue())
|
||||
return ccLoadDest.getValue()(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
|
||||
? ccStoreToDest.value()
|
||||
auto lambda = ccStoreToDest.hasValue()
|
||||
? ccStoreToDest.getValue()
|
||||
: 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) {
|
||||
auto len = builder.create<fir::LoadOp>(loc, charLen.value());
|
||||
if (charLen.hasValue()) {
|
||||
auto len = builder.create<fir::LoadOp>(loc, charLen.getValue());
|
||||
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.has_value(); }
|
||||
inline bool isPointerAssignment() const { return lbounds.hasValue(); }
|
||||
|
||||
inline bool isBoundsSpec() const {
|
||||
return isPointerAssignment() && !ubounds.has_value();
|
||||
return isPointerAssignment() && !ubounds.hasValue();
|
||||
}
|
||||
|
||||
inline bool isBoundsRemap() const {
|
||||
return isPointerAssignment() && ubounds.has_value();
|
||||
return isPointerAssignment() && ubounds.hasValue();
|
||||
}
|
||||
|
||||
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]) {
|
||||
auto &base = *esp.lhsBases[counter];
|
||||
if (esp.lhsBases[counter].hasValue()) {
|
||||
auto &base = esp.lhsBases[counter].getValue();
|
||||
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;
|
||||
fir::ArrayLoadOp load = ldOpt.getValue();
|
||||
builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
|
||||
load.getMemref(), load.getSlice(),
|
||||
load.getTypeparams());
|
||||
}
|
||||
if (esp.loopCleanup) {
|
||||
esp.loopCleanup.value()(builder);
|
||||
if (esp.loopCleanup.hasValue()) {
|
||||
esp.loopCleanup.getValue()(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;
|
||||
mlir::Type resultType = retTy.getValue();
|
||||
llvm::SmallVector<fir::ExtendedValue> args;
|
||||
args.push_back(getOperand(0));
|
||||
args.push_back(getOperand(1));
|
||||
args.push_back(builder
|
||||
.genIfOp(loc, {resultType}, *isPresentCheck(2),
|
||||
.genIfOp(loc, {resultType}, isPresentCheck(2).getValue(),
|
||||
/*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]) {
|
||||
auto ld = loadBindings.find(*lhsBases[counter]);
|
||||
if (lhsBases[counter].hasValue()) {
|
||||
auto ld = loadBindings.find(lhsBases[counter].getValue());
|
||||
llvm::Optional<size_t> optPos;
|
||||
if (ld != loadBindings.end() && ld->second == load)
|
||||
optPos = static_cast<size_t>(0u);
|
||||
assert(optPos && "load does not correspond to lhs");
|
||||
assert(optPos.hasValue() && "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)
|
||||
dump(*u);
|
||||
if (u.hasValue())
|
||||
dump(u.getValue());
|
||||
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())
|
||||
uniqName = mem.getUniqName().value();
|
||||
if (mem.getUniqName().hasValue())
|
||||
uniqName = mem.getUniqName().getValue();
|
||||
llvm::StringRef bindcName;
|
||||
if (mem.getBindcName())
|
||||
bindcName = mem.getBindcName().value();
|
||||
if (mem.getBindcName().hasValue())
|
||||
bindcName = mem.getBindcName().getValue();
|
||||
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())
|
||||
uniqName = mem.getUniqName().value();
|
||||
if (mem.getUniqName().hasValue())
|
||||
uniqName = mem.getUniqName().getValue();
|
||||
llvm::StringRef bindcName;
|
||||
if (mem.getBindcName())
|
||||
bindcName = mem.getBindcName().value();
|
||||
if (mem.getBindcName().hasValue())
|
||||
bindcName = mem.getBindcName().getValue();
|
||||
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();
|
||||
initAttr = global.getInitVal().getValue();
|
||||
auto linkage = convertLinkage(global.getLinkName());
|
||||
auto isConst = global.getConstant().has_value();
|
||||
auto isConst = global.getConstant().hasValue();
|
||||
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) {
|
||||
auto name = *optLinkage;
|
||||
if (optLinkage.hasValue()) {
|
||||
auto name = optLinkage.getValue();
|
||||
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)
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, *destOps, newBlock,
|
||||
mlir::ValueRange());
|
||||
if (destOps.hasValue())
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, destOps.getValue(),
|
||||
newBlock, mlir::ValueRange());
|
||||
else
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, newBlock);
|
||||
}
|
||||
|
@ -2759,8 +2759,9 @@ 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)
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
|
||||
if (destOps.hasValue())
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, destOps.getValue(),
|
||||
dest);
|
||||
else
|
||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, llvm::None, dest);
|
||||
}
|
||||
|
@ -2883,14 +2884,15 @@ 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 ? *destOps : mlir::ValueRange{});
|
||||
destinationsOperands.push_back(destOps.hasValue() ? *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 ? *destOps : mlir::ValueRange{};
|
||||
defaultOperands = destOps.hasValue() ? *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()) {
|
||||
newCall =
|
||||
rewriter->create<A>(loc, *callOp.getCallee(), newResTys, newOpers);
|
||||
if (callOp.getCallee().hasValue()) {
|
||||
newCall = rewriter->create<A>(loc, callOp.getCallee().getValue(),
|
||||
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().has_value();
|
||||
bool isDirect = getCallee().hasValue();
|
||||
p << ' ';
|
||||
if (isDirect)
|
||||
p << *getCallee();
|
||||
p << getCallee().getValue();
|
||||
else
|
||||
p << getOperand(0);
|
||||
p << '(' << (*this)->getOperands().drop_front(isDirect ? 0 : 1) << ')';
|
||||
|
@ -700,8 +700,9 @@ static void printCmpOp(mlir::OpAsmPrinter &p, OPTY op) {
|
|||
op->template getAttrOfType<mlir::IntegerAttr>(
|
||||
OPTY::getPredicateAttrName())
|
||||
.getInt());
|
||||
assert(predSym && "invalid symbol value for predicate");
|
||||
p << '"' << mlir::arith::stringifyCmpFPredicate(*predSym) << '"' << ", ";
|
||||
assert(predSym.hasValue() && "invalid symbol value for predicate");
|
||||
p << '"' << mlir::arith::stringifyCmpFPredicate(predSym.getValue()) << '"'
|
||||
<< ", ";
|
||||
p.printOperand(op.getLhs());
|
||||
p << ", ";
|
||||
p.printOperand(op.getRhs());
|
||||
|
@ -776,8 +777,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 && "invalid predicate name");
|
||||
return *pred;
|
||||
assert(pred.hasValue() && "invalid predicate name");
|
||||
return pred.getValue();
|
||||
}
|
||||
|
||||
void fir::CmpcOp::print(mlir::OpAsmPrinter &p) { printCmpOp(p, *this); }
|
||||
|
@ -1073,7 +1074,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.has_value() && failed(*parseResult))
|
||||
if (parseResult.hasValue() && failed(*parseResult))
|
||||
return mlir::failure();
|
||||
|
||||
fir::DispatchTableOp::ensureTerminator(*body, parser.getBuilder(),
|
||||
|
@ -1255,15 +1256,15 @@ mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser,
|
|||
// Parse the optional initializer body.
|
||||
auto parseResult =
|
||||
parser.parseOptionalRegion(*result.addRegion(), /*arguments=*/{});
|
||||
if (parseResult.has_value() && mlir::failed(*parseResult))
|
||||
if (parseResult.hasValue() && mlir::failed(*parseResult))
|
||||
return mlir::failure();
|
||||
}
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
void fir::GlobalOp::print(mlir::OpAsmPrinter &p) {
|
||||
if (getLinkName())
|
||||
p << ' ' << *getLinkName();
|
||||
if (getLinkName().hasValue())
|
||||
p << ' ' << getLinkName().getValue();
|
||||
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.has_value())
|
||||
if (parseResult.hasValue())
|
||||
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)
|
||||
to = *from;
|
||||
if (from.hasValue())
|
||||
to = from.getValue();
|
||||
return to;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue