aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2022-06-25 11:55:33 -0700
committerKazu Hirata <kazu@google.com>2022-06-25 11:55:33 -0700
commitb8df4093e4d82c67a419911a46b63482043643e5 (patch)
tree21094939ea6c8b726c481d7b28eaf4ea27c64008 /clang/unittests
parent7d101e43cd8afe7368c2180ce33b70b71572e846 (diff)
downloadllvm-b8df4093e4d82c67a419911a46b63482043643e5.zip
llvm-b8df4093e4d82c67a419911a46b63482043643e5.tar.gz
llvm-b8df4093e4d82c67a419911a46b63482043643e5.tar.bz2
[clang, clang-tools-extra] Don't use Optional::{hasValue,getValue} (NFC)
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp2
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp18
-rw-r--r--clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp6
-rw-r--r--clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp4
-rw-r--r--clang/unittests/Analysis/FlowSensitive/TestingSupport.h2
-rw-r--r--clang/unittests/Basic/DarwinSDKInfoTest.cpp4
-rw-r--r--clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp2
-rw-r--r--clang/unittests/Lex/LexerTest.cpp2
-rw-r--r--clang/unittests/Tooling/SourceCodeTest.cpp2
9 files changed, 19 insertions, 23 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
index 6573461..eb9071b 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -277,7 +277,7 @@ TEST(Matcher, matchOverEntireASTContext) {
TEST(DynTypedMatcherTest, TraversalKindForwardsToImpl) {
auto M = DynTypedMatcher(decl());
- EXPECT_FALSE(M.getTraversalKind().hasValue());
+ EXPECT_FALSE(M.getTraversalKind());
M = DynTypedMatcher(traverse(TK_AsIs, decl()));
EXPECT_THAT(M.getTraversalKind(), llvm::ValueIs(TK_AsIs));
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index 255432d..eaba6b7 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -149,7 +149,7 @@ bool matchesRange(SourceRange Range, unsigned StartLine,
llvm::Optional<DynTypedMatcher> getSingleMatcher(const VariantValue &Value) {
llvm::Optional<DynTypedMatcher> Result =
Value.getMatcher().getSingleMatcher();
- EXPECT_TRUE(Result.hasValue());
+ EXPECT_TRUE(Result);
return Result;
}
@@ -280,7 +280,7 @@ TEST(ParserTest, FullParserTest) {
EXPECT_TRUE(matches("unsigned aaaccbb;", M));
Code = "hasInitializer(\n binaryOperator(hasLHS(\"A\")))";
- EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error).hasValue());
+ EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error));
EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
"2:5: Error parsing argument 1 for matcher binaryOperator.\n"
"2:20: Error building matcher hasLHS.\n"
@@ -421,7 +421,7 @@ TEST(ParserTest, ParseMultiline) {
)
)matcher";
Diagnostics Error;
- EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+ EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error));
}
{
@@ -432,7 +432,7 @@ TEST(ParserTest, ParseMultiline) {
)
)matcher";
Diagnostics Error;
- EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+ EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error));
}
{
@@ -440,7 +440,7 @@ TEST(ParserTest, ParseMultiline) {
"paramName")
)matcher";
Diagnostics Error;
- EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+ EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error));
}
{
@@ -481,7 +481,7 @@ decl()))matcher";
("paramName")
)matcher";
M = Parser::parseMatcherExpression(Code, nullptr, &NamedValues, &Error);
- EXPECT_FALSE(M.hasValue());
+ EXPECT_FALSE(M);
EXPECT_EQ("1:15: Malformed bind() expression.", Error.toStringFull());
}
@@ -494,7 +494,7 @@ decl()))matcher";
bind("paramName")
)matcher";
M = Parser::parseMatcherExpression(Code, nullptr, &NamedValues, &Error);
- EXPECT_FALSE(M.hasValue());
+ EXPECT_FALSE(M);
EXPECT_EQ("1:11: Period not followed by valid chained call.",
Error.toStringFull());
}
@@ -506,7 +506,7 @@ decl()))matcher";
()
)matcher";
M = Parser::parseMatcherExpression(Code, nullptr, nullptr, &Error);
- EXPECT_FALSE(M.hasValue());
+ EXPECT_FALSE(M);
EXPECT_EQ("1:8: Error parsing matcher. Found token "
"<NewLine> while looking for '('.",
Error.toStringFull());
@@ -521,7 +521,7 @@ decl()))matcher";
)
)matcher";
M = Parser::parseMatcherExpression(Code, nullptr, nullptr, &Error);
- EXPECT_FALSE(M.hasValue());
+ EXPECT_FALSE(M);
StringRef Expected = R"error(1:1: Error parsing argument 1 for matcher varDecl.
2:3: Matcher not found: doesNotExist)error";
EXPECT_EQ(Expected, Error.toStringFull());
diff --git a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
index 797b284..05cd67e 100644
--- a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
@@ -94,7 +94,7 @@ struct ValueLattice {
};
std::ostream &operator<<(std::ostream &OS, const ValueLattice &L) {
- if (L.Value.hasValue())
+ if (L.Value)
return OS << *L.Value;
switch (L.State) {
case ValueLattice::ValueState::Undefined:
@@ -194,9 +194,7 @@ MATCHER_P(Var, name,
return arg->getName() == name;
}
-MATCHER_P(HasConstantVal, v, "") {
- return arg.Value.hasValue() && *arg.Value == v;
-}
+MATCHER_P(HasConstantVal, v, "") { return arg.Value && *arg.Value == v; }
MATCHER(Varies, "") { return arg == arg.top(); }
diff --git a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
index 842e350..6561385 100644
--- a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -171,9 +171,7 @@ public:
using ::testing::Pair;
using ::testing::UnorderedElementsAre;
-MATCHER_P(HasConstantVal, v, "") {
- return arg.Data.hasValue() && arg.Data->Value == v;
-}
+MATCHER_P(HasConstantVal, v, "") { return arg.Data && arg.Data->Value == v; }
MATCHER(IsUnknown, "") { return arg == arg.bottom(); }
MATCHER(Varies, "") { return arg == arg.top(); }
diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index 957d73f..ce439f5 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -131,7 +131,7 @@ llvm::Error checkDataflow(
std::vector<std::pair<std::string, StateT>> Results;
for (const CFGBlock *Block : CFCtx->getCFG()) {
// Skip blocks that were not evaluated.
- if (!BlockStates[Block->getBlockID()].hasValue())
+ if (!BlockStates[Block->getBlockID()])
continue;
transferBlock(
diff --git a/clang/unittests/Basic/DarwinSDKInfoTest.cpp b/clang/unittests/Basic/DarwinSDKInfoTest.cpp
index aa1feeb..8d720c2 100644
--- a/clang/unittests/Basic/DarwinSDKInfoTest.cpp
+++ b/clang/unittests/Basic/DarwinSDKInfoTest.cpp
@@ -19,7 +19,7 @@ TEST(DarwinSDKInfo, VersionMapping) {
Optional<DarwinSDKInfo::RelatedTargetVersionMapping> Mapping =
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj,
VersionTuple());
- EXPECT_TRUE(Mapping.hasValue());
+ EXPECT_TRUE(Mapping);
EXPECT_EQ(Mapping->getMinimumValue(), VersionTuple(1));
// Exact mapping.
@@ -54,7 +54,7 @@ TEST(DarwinSDKInfo, VersionMappingMissingKey) {
Optional<DarwinSDKInfo::RelatedTargetVersionMapping> Mapping =
DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(Obj,
VersionTuple());
- EXPECT_TRUE(Mapping.hasValue());
+ EXPECT_TRUE(Mapping);
EXPECT_EQ(
Mapping->map(VersionTuple(4), VersionTuple(0, 1), VersionTuple(100)),
None);
diff --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index f0dc55a4..5b76480 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -194,7 +194,7 @@ struct VerifyingConsumer {
if (result())
return *result();
- ResultIsReady.wait(L, [this]() { return result().hasValue(); });
+ ResultIsReady.wait(L, [this]() { return result().has_value(); });
}
return false; // Just to make compiler happy.
}
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index f534de1..0ad644c 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -612,7 +612,7 @@ TEST_F(LexerTest, FindNextToken) {
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
while (true) {
auto T = Lexer::findNextToken(Loc, SourceMgr, LangOpts);
- ASSERT_TRUE(T.hasValue());
+ ASSERT_TRUE(T);
if (T->is(tok::eof))
break;
GeneratedByNextToken.push_back(getSourceText(*T, *T));
diff --git a/clang/unittests/Tooling/SourceCodeTest.cpp b/clang/unittests/Tooling/SourceCodeTest.cpp
index badc6f8..2d4757c 100644
--- a/clang/unittests/Tooling/SourceCodeTest.cpp
+++ b/clang/unittests/Tooling/SourceCodeTest.cpp
@@ -474,7 +474,7 @@ int c = BAR 3.0;
IntLitVisitor Visitor;
Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
- EXPECT_FALSE(getRangeForEdit(Range, *Context).hasValue());
+ EXPECT_FALSE(getRangeForEdit(Range, *Context));
};
Visitor.runOver(Code);
}