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

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 4 15:57:29 PST 2022


Author: Kazu Hirata
Date: 2022-12-04T15:57:24-08:00
New Revision: 35b4fbb559d909a7edf64412c665e99748398ac4

URL: https://github.com/llvm/llvm-project/commit/35b4fbb559d909a7edf64412c665e99748398ac4
DIFF: https://github.com/llvm/llvm-project/commit/35b4fbb559d909a7edf64412c665e99748398ac4.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/Expr.h
    clang/include/clang/AST/ExprCXX.h
    clang/include/clang/AST/Stmt.h
    clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
    clang/include/clang/Analysis/AnyCall.h
    clang/include/clang/Analysis/MacroExpansionContext.h
    clang/include/clang/Basic/SourceManager.h
    clang/include/clang/Basic/TargetID.h
    clang/include/clang/Basic/TargetInfo.h
    clang/include/clang/Lex/HeaderMap.h
    clang/include/clang/Lex/Preprocessor.h
    clang/include/clang/Sema/Sema.h
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
    clang/include/clang/Tooling/Refactoring/ASTSelection.h
    clang/lib/AST/ExprConstant.cpp
    clang/lib/Analysis/CalledOnceCheck.cpp
    clang/lib/Analysis/MacroExpansionContext.cpp
    clang/lib/Basic/DarwinSDKInfo.cpp
    clang/lib/Basic/Targets/AMDGPU.h
    clang/lib/Basic/Targets/NVPTX.h
    clang/lib/CodeGen/CGExprConstant.cpp
    clang/lib/CodeGen/CoverageMappingGen.cpp
    clang/lib/DirectoryWatcher/DirectoryScanner.h
    clang/lib/Lex/HeaderSearch.cpp
    clang/lib/Lex/PPDirectives.cpp
    clang/lib/Sema/SemaCodeComplete.cpp
    clang/lib/Sema/SemaOverload.cpp
    clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
    clang/lib/StaticAnalyzer/Core/BugReporter.cpp
    clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
    clang/lib/StaticAnalyzer/Core/RegionStore.cpp
    clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
    clang/tools/clang-refactor/TestSupport.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 9bf0318ec9332..bdc1bbdd7d0c3 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -533,8 +533,9 @@ class Expr : public ValueStmt {
       bool IgnoreTemplateOrMacroSubstitution = false) const;
 
   /// isIntegerConstantExpr - Return the value if this expression is a valid
-  /// integer constant expression.  If not a valid i-c-e, return None and fill
-  /// in Loc (if specified) with the location of the invalid expression.
+  /// integer constant expression.  If not a valid i-c-e, return std::nullopt
+  /// and fill in Loc (if specified) with the location of the invalid
+  /// expression.
   ///
   /// Note: This does not perform the implicit conversions required by C++11
   /// [expr.const]p5.

diff  --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 34357347c6fec..81267ff568c5b 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2268,7 +2268,7 @@ class CXXNewExpr final
 
   bool isArray() const { return CXXNewExprBits.IsArray; }
 
-  /// This might return None even if isArray() returns true,
+  /// 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.
   Optional<Expr *> getArraySize() {
@@ -2282,7 +2282,7 @@ class CXXNewExpr final
     return std::nullopt;
   }
 
-  /// This might return None even if isArray() returns true,
+  /// 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.
   Optional<const Expr *> getArraySize() const {

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index c65cdeb574cc9..619d85664476a 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -2140,7 +2140,7 @@ class IfStmt final
   }
 
   /// If this is an 'if constexpr', determine which substatement will be taken.
-  /// Otherwise, or if the condition is value-dependent, returns None.
+  /// Otherwise, or if the condition is value-dependent, returns std::nullopt.
   Optional<const Stmt*> getNondiscardedCase(const ASTContext &Ctx) const;
   Optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx);
 

diff  --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
index 240ee9a89b333..eec9255134de6 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -117,7 +117,7 @@ class VariantMatcher {
 
     /// Constructs a variadic typed matcher from \p InnerMatchers.
     /// Will try to convert each inner matcher to the destination type and
-    /// return llvm::None if it fails to do so.
+    /// return std::nullopt if it fails to do so.
     llvm::Optional<DynTypedMatcher>
     constructVariadicOperator(DynTypedMatcher::VariadicOperator Op,
                               ArrayRef<VariantMatcher> InnerMatchers) const;

diff  --git a/clang/include/clang/Analysis/AnyCall.h b/clang/include/clang/Analysis/AnyCall.h
index 876d423a21f2d..d18c04648bda0 100644
--- a/clang/include/clang/Analysis/AnyCall.h
+++ b/clang/include/clang/Analysis/AnyCall.h
@@ -108,7 +108,7 @@ class AnyCall {
   }
 
   /// If @c E is a generic call (to ObjC method /function/block/etc),
-  /// return a constructed @c AnyCall object. Return None otherwise.
+  /// return a constructed @c AnyCall object. Return std::nullopt otherwise.
   static Optional<AnyCall> forExpr(const Expr *E) {
     if (const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
       return AnyCall(ME);
@@ -128,7 +128,7 @@ class AnyCall {
   }
 
   /// If @c D is a callable (Objective-C method or a function), return
-  /// a constructed @c AnyCall object. Return None otherwise.
+  /// a constructed @c AnyCall object. Return std::nullopt otherwise.
   // FIXME: block support.
   static Optional<AnyCall> forDecl(const Decl *D) {
     if (const auto *FD = dyn_cast<FunctionDecl>(D)) {

diff  --git a/clang/include/clang/Analysis/MacroExpansionContext.h b/clang/include/clang/Analysis/MacroExpansionContext.h
index 57934bfc09d97..ea9ced02c6139 100644
--- a/clang/include/clang/Analysis/MacroExpansionContext.h
+++ b/clang/include/clang/Analysis/MacroExpansionContext.h
@@ -85,13 +85,13 @@ class MacroExpansionContext {
   /// \param MacroExpansionLoc Must be the expansion location of a macro.
   /// \return The textual representation of the token sequence which was
   ///         substituted in place of the macro after the preprocessing.
-  ///         If no macro was expanded at that location, returns llvm::None.
+  ///         If no macro was expanded at that location, returns std::nullopt.
   Optional<StringRef> getExpandedText(SourceLocation MacroExpansionLoc) const;
 
   /// \param MacroExpansionLoc Must be the expansion location of a macro.
   /// \return The text from the original source code which were substituted by
   ///         the macro expansion chain from the given location.
-  ///         If no macro was expanded at that location, returns llvm::None.
+  ///         If no macro was expanded at that location, returns std::nullopt.
   Optional<StringRef> getOriginalText(SourceLocation MacroExpansionLoc) const;
 
   LLVM_DUMP_METHOD void dumpExpansionRangesToStream(raw_ostream &OS) const;

diff  --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index b482b6a271c21..bed429d17422e 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -939,7 +939,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
 
   /// Retrieve the memory buffer associated with the given file.
   ///
-  /// Returns None if the buffer is not valid.
+  /// Returns std::nullopt if the buffer is not valid.
   llvm::Optional<llvm::MemoryBufferRef>
   getMemoryBufferForFileOrNone(const FileEntry *File);
 
@@ -999,8 +999,8 @@ class SourceManager : public RefCountedBase<SourceManager> {
   }
 
   /// Bypass the overridden contents of a file.  This creates a new FileEntry
-  /// and initializes the content cache for it.  Returns None if there is no
-  /// such file in the filesystem.
+  /// and initializes the content cache for it.  Returns std::nullopt if there
+  /// is no such file in the filesystem.
   ///
   /// This should be called before parsing has begun.
   Optional<FileEntryRef> bypassFileContentsOverride(FileEntryRef File);
@@ -1020,7 +1020,8 @@ class SourceManager : public RefCountedBase<SourceManager> {
 
   /// Return the buffer for the specified FileID.
   ///
-  /// If there is an error opening this buffer the first time, return None.
+  /// If there is an error opening this buffer the first time, return
+  /// std::nullopt.
   llvm::Optional<llvm::MemoryBufferRef>
   getBufferOrNone(FileID FID, SourceLocation Loc = SourceLocation()) const {
     if (auto *Entry = getSLocEntryForFile(FID))
@@ -1057,7 +1058,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// Returns the filename for the provided FileID, unless it's a built-in
   /// buffer that's not represented by a filename.
   ///
-  /// Returns None for non-files and built-in files.
+  /// Returns std::nullopt for non-files and built-in files.
   Optional<StringRef> getNonBuiltinFilenameForID(FileID FID) const;
 
   /// Returns the FileEntry record for the provided SLocEntry.

diff  --git a/clang/include/clang/Basic/TargetID.h b/clang/include/clang/Basic/TargetID.h
index de24253ec9ed3..b2d35d8719e1e 100644
--- a/clang/include/clang/Basic/TargetID.h
+++ b/clang/include/clang/Basic/TargetID.h
@@ -48,7 +48,7 @@ std::string getCanonicalTargetID(llvm::StringRef Processor,
 
 /// Get the conflicted pair of target IDs for a compilation or a bundled code
 /// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
-/// returns None.
+/// returns std::nullopt.
 std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
 getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs);
 

diff  --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index f4b7581fd531f..6775d18cdefed 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1513,7 +1513,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Return an AST address space which can be used opportunistically
   /// for constant global memory. It must be possible to convert pointers into
   /// this address space to LangAS::Default. If no such address space exists,
-  /// this may return None, and such optimizations will be disabled.
+  /// this may return std::nullopt, and such optimizations will be disabled.
   virtual llvm::Optional<LangAS> getConstantAddressSpace() const {
     return LangAS::Default;
   }
@@ -1653,8 +1653,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// space \p AddressSpace to be converted in order to be used, then return the
   /// corresponding target specific DWARF address space.
   ///
-  /// \returns Otherwise return None and no conversion will be emitted in the
-  /// DWARF.
+  /// \returns Otherwise return std::nullopt and no conversion will be emitted
+  /// in the DWARF.
   virtual std::optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace)
       const {
     return std::nullopt;

diff  --git a/clang/include/clang/Lex/HeaderMap.h b/clang/include/clang/Lex/HeaderMap.h
index 7930cb83598ca..222776d88c54a 100644
--- a/clang/include/clang/Lex/HeaderMap.h
+++ b/clang/include/clang/Lex/HeaderMap.h
@@ -75,7 +75,7 @@ class HeaderMapImpl {
   HMapBucket getBucket(unsigned BucketNo) const;
 
   /// Look up the specified string in the string table.  If the string index is
-  /// not valid, return None.
+  /// not valid, return std::nullopt.
   Optional<StringRef> getString(unsigned StrTabIdx) const;
 };
 

diff  --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 499ee95f3a00f..8f571848d62a3 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2242,7 +2242,7 @@ class Preprocessor {
 
   /// Given a "foo" or \<foo> reference, look up the indicated file.
   ///
-  /// Returns None on failure.  \p isAngled indicates whether the file
+  /// Returns std::nullopt on failure.  \p isAngled indicates whether the file
   /// reference is for system \#include's or not (i.e. using <> instead of "").
   Optional<FileEntryRef>
   LookupFile(SourceLocation FilenameLoc, StringRef Filename, bool isAngled,

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7a493c052ab1f..984de6307ec64 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11590,8 +11590,9 @@ class Sema final {
   /// \param TI The trait info object representing the match clause.
   /// \param NumAppendArgs The number of omp_interop_t arguments to account for
   /// in checking.
-  /// \returns None, if the function/variant function are not compatible with
-  /// the pragma, pair of original function/variant ref expression otherwise.
+  /// \returns std::nullopt, if the function/variant function are not compatible
+  /// with the pragma, pair of original function/variant ref expression
+  /// otherwise.
   Optional<std::pair<FunctionDecl *, Expr *>>
   checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef,
                                     OMPTraitInfo &TI, unsigned NumAppendArgs,

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index ded33472cd077..444c317cbbefc 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -420,7 +420,7 @@ class CallEvent {
 
   /// Some calls have parameter numbering mismatched from argument numbering.
   /// This function converts an argument index to the corresponding
-  /// parameter index. Returns None is the argument doesn't correspond
+  /// parameter index. Returns std::nullopt is the argument doesn't correspond
   /// to any parameter variable.
   virtual Optional<unsigned>
   getAdjustedParameterIndex(unsigned ASTArgumentIndex) const {

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index 1b9526324086d..a4fa3fbf45dbe 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -369,7 +369,7 @@ class SValBuilder {
     return loc::ConcreteInt(BasicVals.getValue(integer));
   }
 
-  /// Return MemRegionVal on success cast, otherwise return None.
+  /// Return MemRegionVal on success cast, otherwise return std::nullopt.
   Optional<loc::MemRegionVal> getCastedMemRegionVal(const MemRegion *region,
                                                     QualType type);
 

diff  --git a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
index ecc07995bc3a6..0d9cb6a38e0a8 100644
--- a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -69,7 +69,7 @@ class HeaderIncludes {
   /// this will simply insert the #include in front of the first #include of the
   /// same category in the code that should be sorted after \p IncludeName. If
   /// \p IncludeName already exists (with exactly the same spelling), this
-  /// returns None.
+  /// returns std::nullopt.
   llvm::Optional<tooling::Replacement> insert(llvm::StringRef Header,
                                               bool IsAngled) const;
 

diff  --git a/clang/include/clang/Tooling/Refactoring/ASTSelection.h b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
index 33dd386d2340d..c07f8a80e3f21 100644
--- a/clang/include/clang/Tooling/Refactoring/ASTSelection.h
+++ b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
@@ -65,8 +65,8 @@ struct SelectedASTNode {
 
 /// Traverses the given ASTContext and creates a tree of selected AST nodes.
 ///
-/// \returns None if no nodes are selected in the AST, or a selected AST node
-/// that corresponds to the TranslationUnitDecl otherwise.
+/// \returns std::nullopt if no nodes are selected in the AST, or a selected AST
+/// node that corresponds to the TranslationUnitDecl otherwise.
 Optional<SelectedASTNode> findSelectedASTNodes(const ASTContext &Context,
                                                SourceRange SelectionRange);
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7be88a6405a96..ce9774422b120 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -6739,7 +6739,7 @@ static const FunctionDecl *getVirtualOperatorDelete(QualType T) {
 /// still exists and is of the right kind for the purpose of a deletion.
 ///
 /// On success, returns the heap allocation to deallocate. On failure, produces
-/// a diagnostic and returns None.
+/// a diagnostic and returns std::nullopt.
 static Optional<DynAlloc *> CheckDeleteKind(EvalInfo &Info, const Expr *E,
                                             const LValue &Pointer,
                                             DynAlloc::Kind DeallocKind) {

diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp
index 705a736861986..4d1c2f834ea84 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -997,7 +997,7 @@ class CalledOnceChecker : public ConstStmtVisitor<CalledOnceChecker> {
 
   /// Return true/false if 'swift_async' attribute states that the given
   /// parameter is conventionally called once.
-  /// Return llvm::None if the given declaration doesn't have 'swift_async'
+  /// Return std::nullopt if the given declaration doesn't have 'swift_async'
   /// attribute.
   static llvm::Optional<bool> isConventionalSwiftAsync(const Decl *D,
                                                        unsigned ParamIndex) {

diff  --git a/clang/lib/Analysis/MacroExpansionContext.cpp b/clang/lib/Analysis/MacroExpansionContext.cpp
index 489cdfcbbc043..0fb9c6a894aa9 100644
--- a/clang/lib/Analysis/MacroExpansionContext.cpp
+++ b/clang/lib/Analysis/MacroExpansionContext.cpp
@@ -101,7 +101,7 @@ MacroExpansionContext::getExpandedText(SourceLocation MacroExpansionLoc) const {
   if (MacroExpansionLoc.isMacroID())
     return std::nullopt;
 
-  // If there was no macro expansion at that location, return None.
+  // If there was no macro expansion at that location, return std::nullopt.
   if (ExpansionRanges.find_as(MacroExpansionLoc) == ExpansionRanges.end())
     return std::nullopt;
 

diff  --git a/clang/lib/Basic/DarwinSDKInfo.cpp b/clang/lib/Basic/DarwinSDKInfo.cpp
index a1c071c5f620d..5543acb126df7 100644
--- a/clang/lib/Basic/DarwinSDKInfo.cpp
+++ b/clang/lib/Basic/DarwinSDKInfo.cpp
@@ -29,7 +29,7 @@ std::optional<VersionTuple> DarwinSDKInfo::RelatedTargetVersionMapping::map(
   // the major-only check.
   if (Key.getMinor())
     return map(VersionTuple(Key.getMajor()), MinimumValue, MaximumValue);
-  // If this a major only key, return None for a missing entry.
+  // If this a major only key, return std::nullopt for a missing entry.
   return std::nullopt;
 }
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 35674ce2ff53a..1dbc4c286c15e 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -392,8 +392,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   /// space \p AddressSpace to be converted in order to be used, then return the
   /// corresponding target specific DWARF address space.
   ///
-  /// \returns Otherwise return None and no conversion will be emitted in the
-  /// DWARF.
+  /// \returns Otherwise return std::nullopt and no conversion will be emitted
+  /// in the DWARF.
   std::optional<unsigned>
   getDWARFAddressSpace(unsigned AddressSpace) const override {
     const unsigned DWARF_Private = 1;

diff  --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index f62d86fe99aae..69b79e9e0f728 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -157,8 +157,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
   /// space \p AddressSpace to be converted in order to be used, then return the
   /// corresponding target specific DWARF address space.
   ///
-  /// \returns Otherwise return None and no conversion will be emitted in the
-  /// DWARF.
+  /// \returns Otherwise return std::nullopt and no conversion will be emitted
+  /// in the DWARF.
   std::optional<unsigned>
   getDWARFAddressSpace(unsigned AddressSpace) const override {
     if (AddressSpace >= std::size(NVPTXDWARFAddrSpaceMap) ||

diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 54c9dbecd35e5..d863004ab9e1d 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -283,7 +283,7 @@ bool ConstantAggregateBuilder::addBits(llvm::APInt Bits, uint64_t OffsetInBits,
 /// Returns a position within Elems and Offsets such that all elements
 /// before the returned index end before Pos and all elements at or after
 /// the returned index begin at or after Pos. Splits elements as necessary
-/// to ensure this. Returns None if we find something we can't split.
+/// to ensure this. Returns std::nullopt if we find something we can't split.
 Optional<size_t> ConstantAggregateBuilder::splitAt(CharUnits Pos) {
   if (Pos >= Size)
     return Offsets.size();

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index e23bf397d9683..6e5bc063a665e 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -325,7 +325,7 @@ class CoverageMappingBuilder {
 
   /// Get the coverage mapping file ID for \c Loc.
   ///
-  /// If such file id doesn't exist, return None.
+  /// If such file id doesn't exist, return std::nullopt.
   Optional<unsigned> getCoverageFileID(SourceLocation Loc) {
     auto Mapping = FileIDMapping.find(SM.getFileID(Loc));
     if (Mapping != FileIDMapping.end())
@@ -335,7 +335,7 @@ class CoverageMappingBuilder {
 
   /// This shrinks the skipped range if it spans a line that contains a
   /// non-comment token. If shrinking the skipped range would make it empty,
-  /// this returns None.
+  /// this returns std::nullopt.
   /// Note this function can potentially be expensive because
   /// getSpellingLineNumber uses getLineNumber, which is expensive.
   Optional<SpellingRegion> adjustSkippedRange(SourceManager &SM,

diff  --git a/clang/lib/DirectoryWatcher/DirectoryScanner.h b/clang/lib/DirectoryWatcher/DirectoryScanner.h
index feb8b4ea861ea..42fe8efcc8fec 100644
--- a/clang/lib/DirectoryWatcher/DirectoryScanner.h
+++ b/clang/lib/DirectoryWatcher/DirectoryScanner.h
@@ -23,7 +23,7 @@ std::vector<DirectoryWatcher::Event>
 getAsFileEvents(const std::vector<std::string> &Scan);
 
 /// Gets status of file (or directory) at \p Path.
-/// \returns llvm::None if \p Path doesn't exist or can't get the status.
+/// \returns std::nullopt if \p Path doesn't exist or can't get the status.
 llvm::Optional<llvm::sys::fs::file_status> getFileStatus(llvm::StringRef Path);
 
 } // namespace clang

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index e1c179edd527d..1ce6df468d00d 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -329,7 +329,8 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
       continue;
 
     bool IsSystem = Dir.isSystemHeaderDirectory();
-    // Only returns None if not a normal directory, which we just checked
+    // Only returns std::nullopt if not a normal directory, which we just
+    // checked
     DirectoryEntryRef NormalDir = *Dir.getDirRef();
     // Search for a module map file in this directory.
     if (loadModuleMapFile(NormalDir, IsSystem,

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 87a40724fac0a..5264c006b3301 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -273,7 +273,7 @@ static bool warnByDefaultOnWrongCase(StringRef Include) {
 /// \param Candidates the candidates to find a similar string.
 ///
 /// \returns a similar string if exists. If no similar string exists,
-/// returns None.
+/// returns std::nullopt.
 static Optional<StringRef> findSimilarStr(
     StringRef LHS, const std::vector<StringRef> &Candidates) {
   // We need to check if `Candidates` has the exact case-insensitive string

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 31cd2abb24557..d18b0bd1543e0 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -6193,7 +6193,7 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
 //     Only aggregate initialization is possible, but we can't assist with it.
 //     Returns an out-of-range index.
 //   - we saw no designators, just positional arguments.
-//     Returns None.
+//     Returns std::nullopt.
 static llvm::Optional<unsigned>
 getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate,
                                          ArrayRef<Expr *> Args) {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index bbf5e5c873de1..31298c6cd5175 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9733,8 +9733,8 @@ isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
 }
 
 /// Compute the type of the implicit object parameter for the given function,
-/// if any. Returns None if there is no implicit object parameter, and a null
-/// QualType if there is a 'matches anything' implicit object parameter.
+/// if any. Returns std::nullopt if there is no implicit object parameter, and a
+/// null QualType if there is a 'matches anything' implicit object parameter.
 static Optional<QualType> getImplicitObjectParamType(ASTContext &Context,
                                                      const FunctionDecl *F) {
   if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))

diff  --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index efe16cb40f2e0..9133b66fec7c5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -165,7 +165,7 @@ static bool shouldGenerateNote(llvm::raw_string_ostream &os,
 
 /// Finds argument index of the out paramter in the call @c S
 /// corresponding to the symbol @c Sym.
-/// If none found, returns None.
+/// If none found, returns std::nullopt.
 static Optional<unsigned> findArgIdxOfSymbol(ProgramStateRef CurrSt,
                                              const LocationContext *LCtx,
                                              SymbolRef &Sym,

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index eac69569ee2bb..b52f3854683f6 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -221,7 +221,7 @@ class PathDiagnosticBuilder : public BugReporterContext {
 public:
   /// Find a non-invalidated report for a given equivalence class,  and returns
   /// a PathDiagnosticBuilder able to construct bug reports for 
diff erent
-  /// consumers. Returns None if no valid report is found.
+  /// consumers. Returns std::nullopt if no valid report is found.
   static Optional<PathDiagnosticBuilder>
   findValidReport(ArrayRef<PathSensitiveBugReport *> &bugReports,
                   PathSensitiveBugReporter &Reporter);
@@ -1566,7 +1566,8 @@ static void simplifySimpleBranches(PathPieces &pieces) {
 
 /// Returns the number of bytes in the given (character-based) SourceRange.
 ///
-/// If the locations in the range are not on the same line, returns None.
+/// If the locations in the range are not on the same line, returns
+/// std::nullopt.
 ///
 /// Note that this does not do a precise user-visible character or column count.
 static Optional<size_t> getLengthOnSingleLine(const SourceManager &SM,

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 0647585246b4b..3e434f16160aa 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1361,7 +1361,7 @@ class SymbolicRangeInferrer
 
   /// Try to convert given range into the given type.
   ///
-  /// It will return llvm::None only when the trivial conversion is possible.
+  /// It will return std::nullopt only when the trivial conversion is possible.
   llvm::Optional<Range> convert(const Range &Origin, APSIntType To) {
     if (To.testInRange(Origin.From(), false) != APSIntType::RTR_Within ||
         To.testInRange(Origin.To(), false) != APSIntType::RTR_Within) {

diff  --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 81104883381f5..6d6ee55917966 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1674,7 +1674,7 @@ getElementRegionOffsetsWithBase(const ElementRegion *ER) {
 ///   const int arr[10][20][30] = {}; // ArrayExtents { 10, 20, 30 }
 ///   int x1 = arr[4][5][6]; // SrcOffsets { NonLoc(6), NonLoc(5), NonLoc(4) }
 ///                          // DstOffsets { 4, 5, 6 }
-///                          // returns None
+///                          // returns std::nullopt
 ///   int x2 = arr[42][5][-6]; // returns UndefinedVal
 ///   int x3 = arr[4][5][x2];  // returns UnknownVal
 static Optional<SVal>

diff  --git a/clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp b/clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
index 06a5c7c41169b..eca6ab0c71bef 100644
--- a/clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
+++ b/clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
@@ -529,7 +529,7 @@ void compare_same_symbol_minus_left_minus_right_int_less(void) {
 //
 //  // Rearrange signed symbolic expressions only
 //  if (!SingleTy->isSignedIntegerOrEnumerationType())
-//    return None;
+//    return std::nullopt;
 //
 // Without the symbolic casts, the SVal for `x` in `unsigned x = f()` will be
 // the signed `int`. However, with the symbolic casts it will be `unsigned`.

diff  --git a/clang/tools/clang-refactor/TestSupport.h b/clang/tools/clang-refactor/TestSupport.h
index 1282c3a90f3dc..c6b37b4cd6448 100644
--- a/clang/tools/clang-refactor/TestSupport.h
+++ b/clang/tools/clang-refactor/TestSupport.h
@@ -93,7 +93,7 @@ struct TestSelectionRangesInFile {
 /// because clang-refactor should return zero on exit when the group results are
 /// consistent.
 ///
-/// \returns None on failure (errors are emitted to stderr), or a set of
+/// \returns std::nullopt on failure (errors are emitted to stderr), or a set of
 /// grouped source ranges in the given file otherwise.
 Optional<TestSelectionRangesInFile> findTestSelectionRanges(StringRef Filename);
 


        


More information about the cfe-commits mailing list