[clang-tools-extra] c824db4 - [clang-tools-extra] Use std::optional instead of None in comments (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 10 16:59:28 PST 2022


Author: Kazu Hirata
Date: 2022-12-10T16:59:22-08:00
New Revision: c824db46d4bc0e34cd365b94a5262145757080a9

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

LOG: [clang-tools-extra] Use std::optional 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-tools-extra/clang-tidy/ClangTidyCheck.h
    clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
    clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
    clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
    clang-tools-extra/clangd/Hover.h
    clang-tools-extra/clangd/ParsedAST.h
    clang-tools-extra/pseudo/lib/DirectiveTree.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 86a5fc4c2ae7d..e5d98b0196f58 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -154,7 +154,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
     ///
     /// Reads the option with the check-local name \p LocalName from the
     /// ``CheckOptions``. If the corresponding key is not present, return
-    /// ``None``.
+    /// ``std::nullopt``.
     llvm::Optional<StringRef> get(StringRef LocalName) const;
 
     /// Read a named option from the ``Context``.

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index 1e5ce5331f081..ba7dc70b2f606 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -46,7 +46,7 @@ static double getValue(const IntegerLiteral *IntLit,
 
 // Given the scale of a duration and a `Multiplier`, determine if `Multiplier`
 // would produce a new scale.  If so, return a tuple containing the new scale
-// and a suitable Multiplier for that scale, otherwise `None`.
+// and a suitable Multiplier for that scale, otherwise `std::nullopt`.
 static llvm::Optional<std::tuple<DurationScale, double>>
 getNewScaleSingleStep(DurationScale OldScale, double Multiplier) {
   switch (OldScale) {

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
index 14126072a12ea..d8b0acf63cfd5 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
@@ -42,7 +42,7 @@ bool isLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
 /// Possibly strip a floating point cast expression.
 ///
 /// If `Node` represents an explicit cast to a floating point type, return
-/// the textual context of the cast argument, otherwise `None`.
+/// the textual context of the cast argument, otherwise `std::nullopt`.
 llvm::Optional<std::string>
 stripFloatCast(const ast_matchers::MatchFinder::MatchResult &Result,
                const Expr &Node);

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index d00afecd495de..327d98fc0485f 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -123,13 +123,14 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
 
 protected:
   /// Overridden by derived classes, returns information about if and how a Decl
-  /// failed the check. A 'None' result means the Decl did not fail the check.
+  /// failed the check. A 'std::nullopt' result means the Decl did not fail the
+  /// check.
   virtual llvm::Optional<FailureInfo>
   getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const = 0;
 
   /// Overridden by derived classes, returns information about if and how a
-  /// macro failed the check. A 'None' result means the macro did not fail the
-  /// check.
+  /// macro failed the check. A 'std::nullopt' result means the macro did not
+  /// fail the check.
   virtual llvm::Optional<FailureInfo>
   getMacroFailureInfo(const Token &MacroNameTok,
                       const SourceManager &SM) const = 0;

diff  --git a/clang-tools-extra/clangd/Hover.h b/clang-tools-extra/clangd/Hover.h
index 1a46ff5ad772b..f9d83f64f142b 100644
--- a/clang-tools-extra/clangd/Hover.h
+++ b/clang-tools-extra/clangd/Hover.h
@@ -42,11 +42,11 @@ struct HoverInfo {
   /// - template <ParamType Name = DefaultType> class Foo {};
   struct Param {
     /// The printable parameter type, e.g. "int", or "typename" (in
-    /// TemplateParameters), might be None for macro parameters.
+    /// TemplateParameters), might be std::nullopt for macro parameters.
     llvm::Optional<PrintedType> Type;
-    /// None for unnamed parameters.
+    /// std::nullopt for unnamed parameters.
     llvm::Optional<std::string> Name;
-    /// None if no default is provided.
+    /// std::nullopt if no default is provided.
     llvm::Optional<std::string> Default;
   };
 

diff  --git a/clang-tools-extra/clangd/ParsedAST.h b/clang-tools-extra/clangd/ParsedAST.h
index b0a5c423ba31b..e9133f16473bc 100644
--- a/clang-tools-extra/clangd/ParsedAST.h
+++ b/clang-tools-extra/clangd/ParsedAST.h
@@ -113,7 +113,7 @@ class ParsedAST {
   PathRef tuPath() const { return TUPath; }
 
   /// Returns the version of the ParseInputs used to build Preamble part of this
-  /// AST. Might be None if no Preamble is used.
+  /// AST. Might be std::nullopt if no Preamble is used.
   llvm::Optional<llvm::StringRef> preambleVersion() const;
 
   const HeuristicResolver *getHeuristicResolver() const {
@@ -152,7 +152,8 @@ class ParsedAST {
   MainFileMacros Macros;
   // Pragma marks in the main file.
   std::vector<PragmaMark> Marks;
-  // Data, stored after parsing. None if AST was built with a stale preamble.
+  // Data, stored after parsing. std::nullopt if AST was built with a stale
+  // preamble.
   llvm::Optional<std::vector<Diag>> Diags;
   // Top-level decls inside the current file. Not that this does not include
   // top-level decls from the preamble.

diff  --git a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
index b479ecfbbfc1b..4835fc24071a9 100644
--- a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
+++ b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
@@ -284,7 +284,7 @@ class BranchChooser {
 
 private:
   // Return true if the directive starts an always-taken conditional branch,
-  // false if the branch is never taken, and None otherwise.
+  // false if the branch is never taken, and std::nullopt otherwise.
   llvm::Optional<bool> isTakenWhenReached(const DirectiveTree::Directive &Dir) {
     switch (Dir.Kind) {
     case clang::tok::pp_if:


        


More information about the cfe-commits mailing list