Skip to content

Commit

Permalink
[clang] Replace None with std::nullopt in comments (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 May 5, 2023
1 parent eed9932 commit e955e4f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/AST/ExprCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ class CXXNewExpr final

/// This might return std::nullopt even if isArray() returns true,
/// since there might not be an array size expression.
/// If the result is not-None, it will never wrap a nullptr.
/// If the result is not std::nullopt, it will never wrap a nullptr.
std::optional<Expr *> getArraySize() {
if (!isArray())
return std::nullopt;
Expand All @@ -2335,7 +2335,7 @@ class CXXNewExpr final

/// This might return std::nullopt even if isArray() returns true,
/// since there might not be an array size expression.
/// If the result is not-None, it will never wrap a nullptr.
/// If the result is not std::nullopt, it will never wrap a nullptr.
std::optional<const Expr *> getArraySize() const {
if (!isArray())
return std::nullopt;
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/DiagnosticError.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class DiagnosticError : public llvm::ErrorInfo<DiagnosticError> {
}

/// Extracts and returns the diagnostic payload from the given \c Error if
/// the error is a \c DiagnosticError. Returns none if the given error is not
/// a \c DiagnosticError.
/// the error is a \c DiagnosticError. Returns std::nullopt if the given error
/// is not a \c DiagnosticError.
static std::optional<PartialDiagnosticAt> take(llvm::Error &Err) {
std::optional<PartialDiagnosticAt> Result;
Err = llvm::handleErrors(std::move(Err), [&](DiagnosticError &E) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SymbolGraphSerializer : public APISerializer {
///
/// \returns an optional JSON Object representing the payload that libclang
/// expects for providing symbol information for a single symbol. If this is
/// not a known symbol returns \c None.
/// not a known symbol returns \c std::nullopt.
static std::optional<Object> serializeSingleSymbolSGF(StringRef USR,
const APISet &API);

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Lex/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class Lexer : public PreprocessorLexer {

/// Finds the token that comes right after the given location.
///
/// Returns the next token, or none if the location is inside a macro.
/// Returns the next token, or std::nullopt if the location is inside a macro.
static std::optional<Token> findNextToken(SourceLocation Loc,
const SourceManager &SM,
const LangOptions &LangOpts);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class FixableGadget : public Gadget {
bool isWarningGadget() const final { return false; }

/// Returns a fixit that would fix the current gadget according to
/// the current strategy. Returns None if the fix cannot be produced;
/// the current strategy. Returns std::nullopt if the fix cannot be produced;
/// returns an empty list if no fixes are necessary.
virtual std::optional<FixItList> getFixits(const Strategy &) const {
return std::nullopt;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ areFeasible(ConstraintRangeTy Constraints) {
///
/// \returns true if assuming this Sym to be true means equality of operands
/// false if it means disequality of operands
/// None otherwise
/// std::nullopt otherwise
std::optional<bool> meansEquality(const SymSymExpr *Sym) {
switch (Sym->getOpcode()) {
case BO_Sub:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ struct ValueLattice {
// * `Defined` -> top.
ValueState State;

// When `None`, the lattice is either at top or bottom, based on `State`.
// When `std::nullopt`, the lattice is either at top or bottom, based on
// `State`.
std::optional<int64_t> Value;

constexpr ValueLattice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ConstantPropagationLattice {
return Lhs.Var == Rhs.Var && Lhs.Value == Rhs.Value;
}
};
// `None` is "bottom".
// `std::nullopt` is "bottom".
std::optional<VarValue> Data;

static constexpr ConstantPropagationLattice bottom() {
Expand Down

0 comments on commit e955e4f

Please sign in to comment.