diff clang-tools-extra/clangd/SemanticSelection.cpp @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents c4bab56944e8
children
line wrap: on
line diff
--- a/clang-tools-extra/clangd/SemanticSelection.cpp	Wed Nov 09 17:47:54 2022 +0900
+++ b/clang-tools-extra/clangd/SemanticSelection.cpp	Fri Aug 18 09:04:13 2023 +0900
@@ -25,6 +25,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include <optional>
 #include <queue>
 #include <vector>
 
@@ -40,15 +41,15 @@
   }
 }
 
-llvm::Optional<FoldingRange> toFoldingRange(SourceRange SR,
-                                            const SourceManager &SM) {
+std::optional<FoldingRange> toFoldingRange(SourceRange SR,
+                                           const SourceManager &SM) {
   const auto Begin = SM.getDecomposedLoc(SR.getBegin()),
              End = SM.getDecomposedLoc(SR.getEnd());
   // Do not produce folding ranges if either range ends is not within the main
   // file. Macros have their own FileID so this also checks if locations are not
   // within the macros.
   if ((Begin.first != SM.getMainFileID()) || (End.first != SM.getMainFileID()))
-    return llvm::None;
+    return std::nullopt;
   FoldingRange Range;
   Range.startCharacter = SM.getColumnNumber(Begin.first, Begin.second) - 1;
   Range.startLine = SM.getLineNumber(Begin.first, Begin.second) - 1;
@@ -57,7 +58,7 @@
   return Range;
 }
 
-llvm::Optional<FoldingRange>
+std::optional<FoldingRange>
 extractFoldingRange(const syntax::Node *Node,
                     const syntax::TokenBufferTokenManager &TM) {
   if (const auto *Stmt = dyn_cast<syntax::CompoundStatement>(Node)) {
@@ -69,7 +70,7 @@
     const auto *RBrace = cast_or_null<syntax::Leaf>(
         Stmt->findChild(syntax::NodeRole::CloseParen));
     if (!LBrace || !RBrace)
-      return llvm::None;
+      return std::nullopt;
     // Fold the entire range within braces, including whitespace.
     const SourceLocation LBraceLocInfo =
                              TM.getToken(LBrace->getTokenKey())->endLocation(),
@@ -82,7 +83,7 @@
     if (Range && Range->startLine != Range->endLine)
       return Range;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Traverse the tree and collect folding ranges along the way.
@@ -153,7 +154,7 @@
   Head.range = std::move(Ranges.front());
   SelectionRange *Tail = &Head;
   for (auto &Range :
-       llvm::makeMutableArrayRef(Ranges.data(), Ranges.size()).drop_front()) {
+       llvm::MutableArrayRef(Ranges.data(), Ranges.size()).drop_front()) {
     Tail->parent = std::make_unique<SelectionRange>();
     Tail = Tail->parent.get();
     Tail->range = std::move(Range);