[clang] e955e4f - [clang] Replace None with std::nullopt in comments (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Thu May 4 22:42:58 PDT 2023


Author: Kazu Hirata
Date: 2023-05-04T22:42:52-07:00
New Revision: e955e4fba60e6d93b66903687c1dd7a34435d33c

URL: https://github.com/llvm/llvm-project/commit/e955e4fba60e6d93b66903687c1dd7a34435d33c
DIFF: https://github.com/llvm/llvm-project/commit/e955e4fba60e6d93b66903687c1dd7a34435d33c.diff

LOG: [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

Added: 
    

Modified: 
    clang/include/clang/AST/ExprCXX.h
    clang/include/clang/Basic/DiagnosticError.h
    clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
    clang/include/clang/Lex/Lexer.h
    clang/lib/Analysis/UnsafeBufferUsage.cpp
    clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
    clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
    clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 724904b4d2041..16f54d753d42f 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -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;
@@ -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;

diff  --git a/clang/include/clang/Basic/DiagnosticError.h b/clang/include/clang/Basic/DiagnosticError.h
index 3660bd1b3b3d8..744f7fe19db79 100644
--- a/clang/include/clang/Basic/DiagnosticError.h
+++ b/clang/include/clang/Basic/DiagnosticError.h
@@ -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) {

diff  --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 55c7bb32054bc..6639082bbf332 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -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);
 

diff  --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h
index 8c2923b0150a0..98d34b783f084 100644
--- a/clang/include/clang/Lex/Lexer.h
+++ b/clang/include/clang/Lex/Lexer.h
@@ -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);

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 3b58a51195f80..7871fed519b98 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -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;

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index a275d36286d3b..5de99384449a4 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<bool> 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 bc51b5c59d19f..ed95887a45f1a 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<int64_t> Value;
 
   constexpr ValueLattice()

diff  --git a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
index 4b6f575641c5c..b76ce4fa42642 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<VarValue> Data;
 
   static constexpr ConstantPropagationLattice bottom() {


        


More information about the cfe-commits mailing list