#include <cstdlib>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
auto BEnableIfAttrs = B->specific_attrs<EnableIfAttr>();
for (auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
- Optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
- Optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
+ std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
+ std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
// Return false if the number of enable_if attributes is different.
if (!Cand1A || !Cand2A)
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
+#include <optional>
#include <utility>
using namespace clang;
const GenericSelectionExpr *E2) {
for (auto Pair : zip_longest(E1->getAssocTypeSourceInfos(),
E2->getAssocTypeSourceInfos())) {
- Optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
- Optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
+ std::optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
+ std::optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
// Skip this case if there are a different number of associated types.
if (!Child1 || !Child2)
return false;
return false;
for (auto Pair : zip_longest(E1->getArgs(), E2->getArgs())) {
- Optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
- Optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
+ std::optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
+ std::optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
// Different number of args.
if (!Child1 || !Child2)
return false;
// Iterate over the children of both statements and also compare them.
for (auto Pair : zip_longest(S1->children(), S2->children())) {
- Optional<const Stmt *> Child1 = std::get<0>(Pair);
- Optional<const Stmt *> Child2 = std::get<1>(Pair);
+ std::optional<const Stmt *> Child1 = std::get<0>(Pair);
+ std::optional<const Stmt *> Child2 = std::get<1>(Pair);
// One of the statements has a different amount of children than the other,
// so the statements can't be equivalent.
if (!Child1 || !Child2)
#include "llvm/Support/Casting.h"
#include <algorithm>
#include <cstdlib>
+#include <optional>
using namespace clang;
using namespace sema;
llvm::FoldingSetNodeID Cand1ID, Cand2ID;
for (auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
- Optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
- Optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
+ std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
+ std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
// It's impossible for Cand1 to be better than (or equal to) Cand2 if Cand1
// has fewer enable_if attributes than Cand2, and vice versa.
#define LLVM_ADT_STLEXTRAS_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/identity.h"
}
template <typename Iter>
-auto deref_or_none(const Iter &I, const Iter &End) -> llvm::Optional<
+auto deref_or_none(const Iter &I, const Iter &End) -> std::optional<
std::remove_const_t<std::remove_reference_t<decltype(*I)>>> {
if (I == End)
return std::nullopt;
}
template <typename Iter> struct ZipLongestItemType {
- using type = llvm::Optional<std::remove_const_t<
+ using type = std::optional<std::remove_const_t<
std::remove_reference_t<decltype(*std::declval<Iter>())>>>;
};
} // namespace detail
/// Iterate over two or more iterators at the same time. Iteration continues
-/// until all iterators reach the end. The llvm::Optional only contains a value
+/// until all iterators reach the end. The std::optional only contains a value
/// if the iterator has not reached the end.
template <typename T, typename U, typename... Args>
detail::zip_longest_range<T, U, Args...> zip_longest(T &&t, U &&u,
ArrayRef<uint8_t> Bytes;
// If not None, display offsets for each line relative to starting value.
- Optional<uint64_t> FirstByteOffset;
+ std::optional<uint64_t> FirstByteOffset;
uint32_t IndentLevel; // Number of characters to indent each line.
uint32_t NumPerLine; // Number of bytes to show per line.
uint8_t ByteGroupSize; // How many hex bytes are grouped without spaces
friend class raw_ostream;
public:
- FormattedBytes(ArrayRef<uint8_t> B, uint32_t IL, Optional<uint64_t> O,
+ FormattedBytes(ArrayRef<uint8_t> B, uint32_t IL, std::optional<uint64_t> O,
uint32_t NPL, uint8_t BGS, bool U, bool A)
: Bytes(B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
ByteGroupSize(BGS), Upper(U), ASCII(A) {
inline FormattedBytes
format_bytes(ArrayRef<uint8_t> Bytes,
- Optional<uint64_t> FirstByteOffset = std::nullopt,
+ std::optional<uint64_t> FirstByteOffset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
inline FormattedBytes
format_bytes_with_ascii(ArrayRef<uint8_t> Bytes,
- Optional<uint64_t> FirstByteOffset = std::nullopt,
+ std::optional<uint64_t> FirstByteOffset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "gtest/gtest.h"
+#include <optional>
using namespace llvm;
{
// Check left range longer than right.
- const vector<tuple<Optional<unsigned>, Optional<StringRef>>> expected{
+ const vector<tuple<optional<unsigned>, optional<StringRef>>> expected{
make_tuple(3, StringRef("2")), make_tuple(1, StringRef("7")),
make_tuple(4, StringRef("1")), make_tuple(1, StringRef("8")),
make_tuple(5, std::nullopt), make_tuple(9, std::nullopt)};
{
// Check right range longer than left.
- const vector<tuple<Optional<StringRef>, Optional<unsigned>>> expected{
+ const vector<tuple<optional<StringRef>, optional<unsigned>>> expected{
make_tuple(StringRef("2"), 3), make_tuple(StringRef("7"), 1),
make_tuple(StringRef("1"), 4), make_tuple(StringRef("8"), 1),
make_tuple(std::nullopt, 5), make_tuple(std::nullopt, 9)};
#include "llvm/Support/raw_ostream.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
+#include <optional>
using namespace llvm;
static std::string
formatted_bytes_str(ArrayRef<uint8_t> Bytes,
- llvm::Optional<uint64_t> Offset = std::nullopt,
+ std::optional<uint64_t> Offset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4) {
std::string S;
raw_string_ostream Str(S);
}
static std::string format_bytes_with_ascii_str(
- ArrayRef<uint8_t> Bytes, Optional<uint64_t> Offset = std::nullopt,
+ ArrayRef<uint8_t> Bytes, std::optional<uint64_t> Offset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4) {
std::string S;
raw_string_ostream Str(S);