Skip to content

Commit

Permalink
[StaticAnalyzer] Use std::optional in BugReporter.cpp (NFC)
Browse files Browse the repository at this point in the history
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
  • Loading branch information
kazutakahirata committed Dec 11, 2022
1 parent ec94a5b commit 602af71
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clang/lib/StaticAnalyzer/Core/BugReporter.cpp
Expand Up @@ -1569,8 +1569,8 @@ static void simplifySimpleBranches(PathPieces &pieces) {
/// std::nullopt.
///
/// Note that this does not do a precise user-visible character or column count.
static Optional<size_t> getLengthOnSingleLine(const SourceManager &SM,
SourceRange Range) {
static std::optional<size_t> getLengthOnSingleLine(const SourceManager &SM,
SourceRange Range) {
SourceRange ExpansionRange(SM.getExpansionLoc(Range.getBegin()),
SM.getExpansionRange(Range.getEnd()).getEnd());

Expand Down Expand Up @@ -1598,8 +1598,8 @@ static Optional<size_t> getLengthOnSingleLine(const SourceManager &SM,
}

/// \sa getLengthOnSingleLine(SourceManager, SourceRange)
static Optional<size_t> getLengthOnSingleLine(const SourceManager &SM,
const Stmt *S) {
static std::optional<size_t> getLengthOnSingleLine(const SourceManager &SM,
const Stmt *S) {
return getLengthOnSingleLine(SM, S->getSourceRange());
}

Expand Down Expand Up @@ -1658,9 +1658,9 @@ static void removeContextCycles(PathPieces &Path, const SourceManager &SM) {

if (s1Start && s2Start && s1Start == s2End && s2Start == s1End) {
const size_t MAX_SHORT_LINE_LENGTH = 80;
Optional<size_t> s1Length = getLengthOnSingleLine(SM, s1Start);
std::optional<size_t> s1Length = getLengthOnSingleLine(SM, s1Start);
if (s1Length && *s1Length <= MAX_SHORT_LINE_LENGTH) {
Optional<size_t> s2Length = getLengthOnSingleLine(SM, s2Start);
std::optional<size_t> s2Length = getLengthOnSingleLine(SM, s2Start);
if (s2Length && *s2Length <= MAX_SHORT_LINE_LENGTH) {
Path.erase(I);
I = Path.erase(NextI);
Expand Down Expand Up @@ -1719,7 +1719,7 @@ static void removePunyEdges(PathPieces &path, const SourceManager &SM,
std::swap(SecondLoc, FirstLoc);

SourceRange EdgeRange(FirstLoc, SecondLoc);
Optional<size_t> ByteWidth = getLengthOnSingleLine(SM, EdgeRange);
std::optional<size_t> ByteWidth = getLengthOnSingleLine(SM, EdgeRange);

// If the statements are on different lines, continue.
if (!ByteWidth)
Expand Down

0 comments on commit 602af71

Please sign in to comment.