[clang] 37a3e98 - [clang] Use std::nullopt instead of None in comments (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 18:39:07 PST 2022


Author: Kazu Hirata
Date: 2022-12-09T18:39:01-08:00
New Revision: 37a3e98c841e5d33f7e77e97dfb058965105eb4b

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

LOG: [clang] Use std::nullopt instead of None 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/ASTImporter.h
    clang/include/clang/Basic/DarwinSDKInfo.h
    clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
    clang/include/clang/Sema/Scope.h
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
    clang/lib/CodeGen/CGObjC.cpp
    clang/lib/Driver/OffloadBundler.cpp
    clang/lib/Driver/ToolChains/Hexagon.cpp
    clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
    clang/lib/Lex/DependencyDirectivesScanner.cpp
    clang/lib/Sema/SemaAvailability.cpp
    clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
    clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
    clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
    clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/ASTImporter.h b/clang/include/clang/AST/ASTImporter.h
index f03a76bdeb443..a6bb0e8aa9506 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/AST/ASTImporter.h
@@ -577,7 +577,7 @@ class TypeSourceInfo;
     /// Determine the index of a field in its parent record.
     /// F should be a field (or indirect field) declaration.
     /// \returns The index of the field in its parent context (starting from 0).
-    /// On error `None` is returned (parent context is non-record).
+    /// On error `std::nullopt` is returned (parent context is non-record).
     static llvm::Optional<unsigned> getFieldIndex(Decl *F);
   };
 

diff  --git a/clang/include/clang/Basic/DarwinSDKInfo.h b/clang/include/clang/Basic/DarwinSDKInfo.h
index eed7668c5218c..6a13ddd9d522e 100644
--- a/clang/include/clang/Basic/DarwinSDKInfo.h
+++ b/clang/include/clang/Basic/DarwinSDKInfo.h
@@ -160,8 +160,8 @@ class DarwinSDKInfo {
 
 /// Parse the SDK information from the SDKSettings.json file.
 ///
-/// \returns an error if the SDKSettings.json file is invalid, None if the
-/// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
+/// \returns an error if the SDKSettings.json file is invalid, std::nullopt if
+/// the SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
 Expected<std::optional<DarwinSDKInfo>>
 parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath);
 

diff  --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 7c82c8fa53b95..e20ca85fc8d6e 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -121,8 +121,8 @@ class SymbolGraphSerializer : public APISerializer {
   /// This method also checks if the given \p Record should be skipped during
   /// serialization.
   ///
-  /// \returns \c None if this \p Record should be skipped, or a JSON object
-  /// containing common symbol information of \p Record.
+  /// \returns \c std::nullopt if this \p Record should be skipped, or a JSON
+  /// object containing common symbol information of \p Record.
   template <typename RecordTy>
   Optional<Object> serializeAPIRecord(const RecordTy &Record) const;
 

diff  --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h
index deb011892b850..f8fbc9d27a009 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -215,7 +215,7 @@ class Scope {
   ///  1) pointer to VarDecl that denotes NRVO candidate itself.
   ///  2) nullptr value means that NRVO is not allowed in this scope
   ///     (e.g. return a function parameter).
-  ///  3) None value means that there is no NRVO candidate in this scope
+  ///  3) std::nullopt value means that there is no NRVO candidate in this scope
   ///     (i.e. there are no return statements in this scope).
   Optional<VarDecl *> NRVO;
 

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index a4fa3fbf45dbe..adc3af9e775b9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -235,7 +235,7 @@ class SValBuilder {
   /// Returns the value of \p E, if it can be determined in a non-path-sensitive
   /// manner.
   ///
-  /// If \p E is not a constant or cannot be modeled, returns \c None.
+  /// If \p E is not a constant or cannot be modeled, returns \c std::nullopt.
   Optional<SVal> getConstantVal(const Expr *E);
 
   NonLoc makeCompoundVal(QualType type, llvm::ImmutableList<SVal> vals) {

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index 2ef083aa16467..80db6bf5667e4 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -173,7 +173,7 @@ class StoreManager {
   ///  - We don't know (base is a symbolic region and we don't have
   ///    enough info to determine if the cast will succeed at run time).
   /// The function returns an optional with SVal representing the derived class
-  /// in case of a successful cast and `None` otherwise.
+  /// in case of a successful cast and `std::nullopt` otherwise.
   Optional<SVal> evalBaseToDerived(SVal Base, QualType DerivedPtrType);
 
   const ElementRegion *GetElementZeroRegion(const SubRegion *R, QualType T);

diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 59c359a19de27..961410c5b53ed 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -372,7 +372,7 @@ static const Expr *findWeakLValue(const Expr *E) {
 ///
 /// If the runtime does support a required entrypoint, then this method will
 /// generate a call and return the resulting value.  Otherwise it will return
-/// None and the caller can generate a msgSend instead.
+/// std::nullopt and the caller can generate a msgSend instead.
 static Optional<llvm::Value *>
 tryGenerateSpecializedMessageSend(CodeGenFunction &CGF, QualType ResultType,
                                   llvm::Value *Receiver,

diff  --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index 46c4092cfce94..99f962bba7f5f 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -200,8 +200,8 @@ class FileHandler {
   virtual Error ReadHeader(MemoryBuffer &Input) = 0;
 
   /// Read the marker of the next bundled to be read in the file. The bundle
-  /// name is returned if there is one in the file, or `None` if there are no
-  /// more bundles to be read.
+  /// name is returned if there is one in the file, or `std::nullopt` if there
+  /// are no more bundles to be read.
   virtual Expected<std::optional<StringRef>>
   ReadBundleStart(MemoryBuffer &Input) = 0;
 

diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 86c345013fde3..06b97a10c6a76 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -124,7 +124,7 @@ static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
       [&](auto FlagOn, auto FlagOff,
           unsigned MinVerNum) -> std::optional<StringRef> {
     // Return an std::optional<StringRef>:
-    // - None indicates a verification failure, or that the flag was not
+    // - std::nullopt indicates a verification failure, or that the flag was not
     //   present in Args.
     // - Otherwise the returned value is that name of the feature to add
     //   to Features.

diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 91dc2529a4b4f..cea4d91a84d50 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -56,8 +56,8 @@ void serializeArray(Object &Paren, StringRef Key, Optional<Array> Array) {
 ///   }
 /// \endcode
 ///
-/// \returns \c None if the version \p V is empty, or an \c Object containing
-/// the semantic version representation of \p V.
+/// \returns \c std::nullopt if the version \p V is empty, or an \c Object
+/// containing the semantic version representation of \p V.
 Optional<Object> serializeSemanticVersion(const VersionTuple &V) {
   if (V.empty())
     return std::nullopt;
@@ -142,8 +142,8 @@ Object serializeSourceRange(const PresumedLoc &BeginLoc,
 /// or deprecated, i.e. \c __attribute__((unavailable)) and \c
 /// __attribute__((deprecated)).
 ///
-/// \returns \c None if the symbol has default availability attributes, or
-/// an \c Array containing the formatted availability information.
+/// \returns \c std::nullopt if the symbol has default availability attributes,
+/// or an \c Array containing the formatted availability information.
 Optional<Array> serializeAvailability(const AvailabilitySet &Availabilities) {
   if (Availabilities.isDefault())
     return std::nullopt;
@@ -228,8 +228,8 @@ Object serializeIdentifier(const APIRecord &Record, Language Lang) {
 ///       ^~~~~~~~~~~~~~~~~~~~~~~'         Second line.
 /// \endcode
 ///
-/// \returns \c None if \p Comment is empty, or an \c Object containing the
-/// formatted lines.
+/// \returns \c std::nullopt if \p Comment is empty, or an \c Object containing
+/// the formatted lines.
 Optional<Object> serializeDocComment(const DocComment &Comment) {
   if (Comment.empty())
     return std::nullopt;
@@ -280,8 +280,8 @@ Optional<Object> serializeDocComment(const DocComment &Comment) {
 ///                    ]
 /// \endcode
 ///
-/// \returns \c None if \p DF is empty, or an \c Array containing the formatted
-/// declaration fragments array.
+/// \returns \c std::nullopt if \p DF is empty, or an \c Array containing the
+/// formatted declaration fragments array.
 Optional<Array> serializeDeclarationFragments(const DeclarationFragments &DF) {
   if (DF.getFragments().empty())
     return std::nullopt;
@@ -447,7 +447,7 @@ Optional<Object> serializeFunctionSignatureMixinImpl(const RecordTy &Record,
 ///   - The \c parameters array contains names and declaration fragments of the
 ///     parameters.
 ///
-/// \returns \c None if \p FS is empty, or an \c Object containing the
+/// \returns \c std::nullopt if \p FS is empty, or an \c Object containing the
 /// formatted function signature.
 template <typename RecordTy>
 void serializeFunctionSignatureMixin(Object &Paren, const RecordTy &Record) {

diff  --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp
index 8d33e19f5df0e..a709847a83892 100644
--- a/clang/lib/Lex/DependencyDirectivesScanner.cpp
+++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp
@@ -91,7 +91,7 @@ struct Scanner {
   void skipDirective(StringRef Name, const char *&First, const char *const End);
 
   /// Lexes next token and if it is identifier returns its string, otherwise
-  /// it skips the current line and returns \p None.
+  /// it skips the current line and returns \p std::nullopt.
   ///
   /// In any case (whatever the token kind) \p First and the \p Lexer will
   /// advance beyond the token.

diff  --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index 3a5399a7175fa..b0e99da9dd5f7 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -244,8 +244,8 @@ struct AttributeInsertion {
 /// attribute argument.
 /// \param SlotNames The vector that will be populated with slot names. In case
 /// of unsuccessful parsing can contain invalid data.
-/// \returns A number of method parameters if parsing was successful, None
-/// otherwise.
+/// \returns A number of method parameters if parsing was successful,
+/// std::nullopt otherwise.
 static Optional<unsigned>
 tryParseObjCMethodName(StringRef Name, SmallVectorImpl<StringRef> &SlotNames,
                        const LangOptions &LangOpts) {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h b/clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
index d46a403d59a54..7d87743f8c33f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
+++ b/clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
@@ -49,8 +49,8 @@ llvm::Optional<SVal> getErrnoValue(ProgramStateRef State);
 ErrnoCheckState getErrnoState(ProgramStateRef State);
 
 /// Returns the location that points to the \c MemoryRegion where the 'errno'
-/// value is stored. Returns \c None if 'errno' was not found. Otherwise it
-/// always returns a valid memory region in the system global memory space.
+/// value is stored. Returns \c std::nullopt if 'errno' was not found. Otherwise
+/// it always returns a valid memory region in the system global memory space.
 llvm::Optional<Loc> getErrnoLoc(ProgramStateRef State);
 
 /// Set value of 'errno' to any SVal, if possible.

diff  --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
index 800e6791f028a..216390a15c25d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
@@ -121,7 +121,7 @@ struct DereferenceInfo {
 
 /// Dereferences \p FR and returns with the pointee's region, and whether it
 /// needs to be casted back to it's location type. If for whatever reason
-/// dereferencing fails, returns with None.
+/// dereferencing fails, returns std::nullopt.
 static llvm::Optional<DereferenceInfo> dereference(ProgramStateRef State,
                                                    const FieldRegion *FR);
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 753adea0d14d3..e10ee4ae7a145 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -26,11 +26,11 @@ class Type;
 // Ref<T>.
 
 /// \returns CXXRecordDecl of the base if the type is ref-countable, nullptr if
-/// not, None if inconclusive.
+/// not, std::nullopt if inconclusive.
 llvm::Optional<const clang::CXXRecordDecl *>
 isRefCountable(const clang::CXXBaseSpecifier *Base);
 
-/// \returns true if \p Class is ref-countable, false if not, None if
+/// \returns true if \p Class is ref-countable, false if not, std::nullopt if
 /// inconclusive.
 llvm::Optional<bool> isRefCountable(const clang::CXXRecordDecl *Class);
 
@@ -38,11 +38,11 @@ llvm::Optional<bool> isRefCountable(const clang::CXXRecordDecl *Class);
 bool isRefCounted(const clang::CXXRecordDecl *Class);
 
 /// \returns true if \p Class is ref-countable AND not ref-counted, false if
-/// not, None if inconclusive.
+/// not, std::nullopt if inconclusive.
 llvm::Optional<bool> isUncounted(const clang::CXXRecordDecl *Class);
 
 /// \returns true if \p T is either a raw pointer or reference to an uncounted
-/// class, false if not, None if inconclusive.
+/// class, false if not, std::nullopt if inconclusive.
 llvm::Optional<bool> isUncountedPtr(const clang::Type *T);
 
 /// \returns true if \p F creates ref-countable object from uncounted parameter,

diff  --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 6d6ee55917966..f5959b26dd92c 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -483,8 +483,8 @@ class RegionStoreManager : public StoreManager {
   /// than using a Default binding at the base of the entire region. This is a
   /// heuristic attempting to avoid building long chains of LazyCompoundVals.
   ///
-  /// \returns The updated store bindings, or \c None if binding non-lazily
-  ///          would be too expensive.
+  /// \returns The updated store bindings, or \c std::nullopt if binding
+  ///          non-lazily would be too expensive.
   Optional<RegionBindingsRef> tryBindSmallStruct(RegionBindingsConstRef B,
                                                  const TypedValueRegion *R,
                                                  const RecordDecl *RD,
@@ -1665,7 +1665,7 @@ getElementRegionOffsetsWithBase(const ElementRegion *ER) {
 /// \param ArrayExtents [in] The array of extents.
 /// \param DstOffsets [out]  The array of offsets of type `uint64_t`.
 /// \returns:
-/// - `None` for successful convertion.
+/// - `std::nullopt` for successful convertion.
 /// - `UndefinedVal` or `UnknownVal` otherwise. It's expected that this SVal
 ///   will be returned as a suitable value of the access operation.
 ///   which should be returned as a correct


        


More information about the cfe-commits mailing list