Author: Haojian Wu
Date: 2022-12-08T13:49:09+01:00
New Revision: 67b72a28903734372972740adb4a9ccc7626cb35

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

LOG: [tooling] use std::optional in tooling StandardLibrary.h/.cpp, NFC

Added: 
    

Modified: 
    clang/include/clang/Tooling/Inclusions/StandardLibrary.h
    clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h 
b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
index 4b5ddbb704e37..5c657b40f10d9 100644
--- a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
+++ b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
@@ -16,9 +16,9 @@
 #define LLVM_CLANG_TOOLING_INCLUSIONS_STANDARDLIBRARY_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
+#include <optional>
 #include <string>
 
 namespace clang {
@@ -37,7 +37,7 @@ class Symbol;
 class Header {
 public:
   // Name should contain the angle brackets, e.g. "<vector>".
-  static llvm::Optional<Header> named(llvm::StringRef Name);
+  static std::optional<Header> named(llvm::StringRef Name);
 
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Header &H) 
{
     return OS << H.name();
@@ -64,7 +64,7 @@ class Symbol {
 public:
   /// \p Scope should have the trailing "::", for example:
   /// named("std::chrono::", "system_clock")
-  static llvm::Optional<Symbol> named(llvm::StringRef Scope,
+  static std::optional<Symbol> named(llvm::StringRef Scope,
                                       llvm::StringRef Name);
 
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) 
{
@@ -94,7 +94,7 @@ class Symbol {
 class Recognizer {
 public:
   Recognizer();
-  llvm::Optional<Symbol> operator()(const Decl *D);
+  std::optional<Symbol> operator()(const Decl *D);
 
 private:
   using NSSymbolMap = llvm::DenseMap<llvm::StringRef, unsigned>;

diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 87276f531ce8d..9e5e421fdebcd 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -77,7 +76,7 @@ static void ensureInitialized() {
   (void)Dummy;
 }
 
-llvm::Optional<Header> Header::named(llvm::StringRef Name) {
+std::optional<Header> Header::named(llvm::StringRef Name) {
   ensureInitialized();
   auto It = HeaderIDs->find(Name);
   if (It == HeaderIDs->end())
@@ -87,7 +86,7 @@ llvm::Optional<Header> Header::named(llvm::StringRef Name) {
 llvm::StringRef Header::name() const { return HeaderNames[ID]; }
 llvm::StringRef Symbol::scope() const { return SymbolNames[ID].first; }
 llvm::StringRef Symbol::name() const { return SymbolNames[ID].second; }
-llvm::Optional<Symbol> Symbol::named(llvm::StringRef Scope,
+std::optional<Symbol> Symbol::named(llvm::StringRef Scope,
                                      llvm::StringRef Name) {
   ensureInitialized();
   if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(Scope)) {
@@ -124,7 +123,7 @@ NSSymbolMap *Recognizer::namespaceSymbols(const 
NamespaceDecl *D) {
   return Result;
 }
 
-llvm::Optional<Symbol> Recognizer::operator()(const Decl *D) {
+std::optional<Symbol> Recognizer::operator()(const Decl *D) {
   // If D is std::vector::iterator, `vector` is the outer symbol to look up.
   // We keep all the candidate DCs as some may turn out to be anon enums.
   // Do this resolution lazily as we may turn out not to have a std namespace.


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to