From e955e4fba60e6d93b66903687c1dd7a34435d33c Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 4 May 2023 22:42:52 -0700 Subject: [PATCH] [clang] Replace None with std::nullopt in comments (NFC) 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 --- clang/include/clang/AST/ExprCXX.h | 4 ++-- clang/include/clang/Basic/DiagnosticError.h | 4 ++-- clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h | 2 +- clang/include/clang/Lex/Lexer.h | 2 +- clang/lib/Analysis/UnsafeBufferUsage.cpp | 2 +- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | 2 +- .../Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp | 3 ++- .../Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 724904b..16f54d7 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -2321,7 +2321,7 @@ public: /// 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 getArraySize() { if (!isArray()) return std::nullopt; @@ -2335,7 +2335,7 @@ public: /// 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 getArraySize() const { if (!isArray()) return std::nullopt; diff --git a/clang/include/clang/Basic/DiagnosticError.h b/clang/include/clang/Basic/DiagnosticError.h index 3660bd1..744f7fe 100644 --- a/clang/include/clang/Basic/DiagnosticError.h +++ b/clang/include/clang/Basic/DiagnosticError.h @@ -35,8 +35,8 @@ public: } /// 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 take(llvm::Error &Err) { std::optional Result; Err = llvm::handleErrors(std::move(Err), [&](DiagnosticError &E) { diff --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h index 55c7bb3..6639082 100644 --- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h +++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h @@ -67,7 +67,7 @@ public: /// /// \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 serializeSingleSymbolSGF(StringRef USR, const APISet &API); diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h index 8c2923b..98d34b7 100644 --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -551,7 +551,7 @@ public: /// 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 findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts); diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp index 3b58a51..7871fed 100644 --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -332,7 +332,7 @@ public: 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 getFixits(const Strategy &) const { return std::nullopt; diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index a275d36..5de9938 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -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 meansEquality(const SymSymExpr *Sym) { switch (Sym->getOpcode()) { case BO_Sub: diff --git a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp index bc51b5c..ed95887 100644 --- a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp @@ -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 Value; constexpr ValueLattice() diff --git a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp index 4b6f575..b76ce4f 100644 --- a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp @@ -59,7 +59,7 @@ struct ConstantPropagationLattice { return Lhs.Var == Rhs.Var && Lhs.Value == Rhs.Value; } }; - // `None` is "bottom". + // `std::nullopt` is "bottom". std::optional Data; static constexpr ConstantPropagationLattice bottom() { -- 2.7.4