Skip to content

Commit 966aa32

Browse files
authored
Merge pull request #8120 from bnbarham/std-optional-all-the-things
Migrate remaining llvm::Optional to std::optional
2 parents a9767a1 + d05e79d commit 966aa32

File tree

61 files changed

+312
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+312
-317
lines changed

clang/include/clang/Basic/PointerAuthOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#define LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H
1616

1717
#include "clang/Basic/LLVM.h"
18-
#include "llvm/ADT/Optional.h"
1918
#include "llvm/Target/TargetOptions.h"
2019
#include <map>
2120
#include <memory>
21+
#include <optional>
2222
#include <string>
2323
#include <vector>
2424
#include "llvm/Support/ErrorHandling.h"

clang/include/clang/Tooling/Refactor/RefactoringOperation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "clang/Tooling/Refactor/RefactoringOptionSet.h"
1616
#include "clang/Tooling/Refactor/RefactoringReplacement.h"
1717
#include "clang/Tooling/Refactor/SymbolOperation.h"
18-
#include "llvm/ADT/None.h"
1918
#include "llvm/Support/Error.h"
19+
#include <optional>
2020
#include <string>
2121
#include <vector>
2222

clang/lib/Tooling/Refactor/RefactoringContinuations.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ class SpecificRefactoringContinuation final : public RefactoringContinuation {
266266
ConsumerFn Consumer;
267267
std::unique_ptr<ASTQueryType> ASTQuery;
268268
/// Inputs store state that's dependent on the original TU.
269-
llvm::Optional<std::tuple<QueryOrState...>> Inputs;
269+
std::optional<std::tuple<QueryOrState...>> Inputs;
270270
/// State contains TU-independent values.
271-
llvm::Optional<
271+
std::optional<
272272
std::tuple<typename StateTraits<QueryOrState>::PersistentType...>>
273273
State;
274274

clang/tools/IndexStore/IndexStore.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/Index/IndexUnitWriter.h"
2020
#include "clang/DirectoryWatcher/DirectoryWatcher.h"
2121
#include "llvm/ADT/ArrayRef.h"
22-
#include "llvm/ADT/Optional.h"
2322
#include "llvm/ADT/SmallString.h"
2423
#include "llvm/Support/Chrono.h"
2524
#include "llvm/Support/ManagedStatic.h"

clang/tools/c-index-test/core_main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static std::string findRecordNameForFile(indexstore::IndexStore &store,
486486
}
487487

488488
static int printStoreFileRecord(StringRef storePath, StringRef filePath,
489-
Optional<unsigned> lineStart, unsigned lineCount,
489+
std::optional<unsigned> lineStart, unsigned lineCount,
490490
PathRemapper remapper, raw_ostream &OS) {
491491
std::string error;
492492
indexstore::IndexStore store(storePath, remapper, error);
@@ -698,7 +698,7 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
698698
bool SerializeDiags, bool DependencyFile,
699699
ArrayRef<std::string> DepTargets, std::string OutputPath,
700700
CXCASDatabases DBs,
701-
Optional<std::string> ModuleName = std::nullopt) {
701+
std::optional<std::string> ModuleName = std::nullopt) {
702702
CXDependencyScannerServiceOptions Opts =
703703
clang_experimental_DependencyScannerServiceOptions_create();
704704
auto CleanupOpts = llvm::make_scope_exit([&] {
@@ -1193,7 +1193,7 @@ static int watchDirectory(StringRef dirPath) {
11931193

11941194
bool deconstructPathAndRange(StringRef input,
11951195
std::string &filepath,
1196-
Optional<unsigned> &lineStart,
1196+
std::optional<unsigned> &lineStart,
11971197
unsigned &lineCount) {
11981198
StringRef path, start, end;
11991199
std::tie(path, end) = input.rsplit(':');
@@ -1272,7 +1272,7 @@ int indextest_core_main(int argc, const char **argv) {
12721272
if (options::Action == ActionType::PrintRecord) {
12731273
if (!options::FilePathAndRange.empty()) {
12741274
std::string filepath;
1275-
Optional<unsigned> lineStart;
1275+
std::optional<unsigned> lineStart;
12761276
unsigned lineCount;
12771277
if (deconstructPathAndRange(options::FilePathAndRange,
12781278
filepath, lineStart, lineCount))
@@ -1330,9 +1330,9 @@ int indextest_core_main(int argc, const char **argv) {
13301330
return aggregateDataAsJSON(storePath, PathRemapper, OS);
13311331
}
13321332

1333-
Optional<std::string> CASPath = options::CASPath.empty()
1333+
std::optional<std::string> CASPath = options::CASPath.empty()
13341334
? std::nullopt
1335-
: Optional<std::string>(options::CASPath);
1335+
: std::optional<std::string>(options::CASPath);
13361336

13371337
CXCASOptions CASOpts = nullptr;
13381338
CXCASDatabases DBs = nullptr;

clang/tools/libclang/CIndexDiagnostic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang-c/Index.h"
1717
#include "clang/Basic/LLVM.h"
1818
#include "llvm/ADT/DenseMap.h"
19-
#include "llvm/ADT/Optional.h"
2019
#include "llvm/ADT/StringRef.h"
2120
#include <assert.h>
2221
#include <memory>

lldb/include/lldb/Core/Module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "llvm/ADT/DenseSet.h"
3232
#include "llvm/ADT/STLFunctionalExtras.h"
3333
#include "llvm/ADT/StringRef.h"
34-
#include "llvm/ADT/Optional.h"
34+
#include <optional>
3535
#include "llvm/Support/Chrono.h"
3636

3737
#include <atomic>
@@ -820,7 +820,7 @@ class Module : public std::enable_shared_from_this<Module>,
820820
#ifdef LLDB_ENABLE_SWIFT
821821
void
822822
ReportWarningToolchainMismatch(CompileUnit &comp_unit,
823-
llvm::Optional<lldb::user_id_t> debugger_id);
823+
std::optional<lldb::user_id_t> debugger_id);
824824

825825
bool IsSwiftCxxInteropEnabled();
826826
#endif

lldb/include/lldb/Core/ValueObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ class ValueObject {
589589
virtual bool HasSyntheticValue();
590590

591591
#ifdef LLDB_ENABLE_SWIFT
592-
llvm::Optional<SwiftScratchContextReader> GetSwiftScratchContext();
592+
std::optional<SwiftScratchContextReader> GetSwiftScratchContext();
593593
#endif // LLDB_ENABLE_SWIFT
594594

595595
virtual bool IsSynthetic() { return false; }

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "lldb/Utility/Timeout.h"
4646
#include "lldb/lldb-public.h"
4747

48-
#include "llvm/ADT/Optional.h"
48+
#include <optional>
4949

5050
namespace lldb_private {
5151

@@ -1281,7 +1281,7 @@ class Target : public std::enable_shared_from_this<Target>,
12811281
return m_scratch_typesystem_lock;
12821282
}
12831283

1284-
llvm::Optional<SwiftScratchContextReader>
1284+
std::optional<SwiftScratchContextReader>
12851285
GetSwiftScratchContext(Status &error, ExecutionContextScope &exe_scope,
12861286
bool create_on_demand = true);
12871287

lldb/include/lldb/Utility/Either.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef liblldb_Either_h_
1010
#define liblldb_Either_h_
1111

12-
#include "llvm/ADT/Optional.h"
12+
#include <optional>
1313

1414
#include <functional>
1515

@@ -51,23 +51,23 @@ template <typename T1, typename T2> class Either {
5151

5252
template <class X, typename std::enable_if<std::is_same<T1, X>::value>::type
5353
* = nullptr>
54-
llvm::Optional<T1> GetAs() const {
54+
std::optional<T1> GetAs() const {
5555
switch (m_selected) {
5656
case Selected::One:
5757
return m_t1;
5858
default:
59-
return llvm::Optional<T1>();
59+
return std::optional<T1>();
6060
}
6161
}
6262

6363
template <class X, typename std::enable_if<std::is_same<T2, X>::value>::type
6464
* = nullptr>
65-
llvm::Optional<T2> GetAs() const {
65+
std::optional<T2> GetAs() const {
6666
switch (m_selected) {
6767
case Selected::Two:
6868
return m_t2;
6969
default:
70-
return llvm::Optional<T2>();
70+
return std::optional<T2>();
7171
}
7272
}
7373

0 commit comments

Comments
 (0)