LLVM  15.0.0git
Optional.h
Go to the documentation of this file.
1 //===- Optional.h - Simple variant for passing optional values --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file provides Optional, a template class modeled in the spirit of
11 /// OCaml's 'opt' variant. The idea is to strongly type whether or not
12 /// a value can be optional.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_ADT_OPTIONAL_H
17 #define LLVM_ADT_OPTIONAL_H
18 
19 #include "llvm/ADT/Hashing.h"
20 #include "llvm/ADT/None.h"
22 #include "llvm/Support/Compiler.h"
24 #include <cassert>
25 #include <new>
26 #include <utility>
27 
28 namespace llvm {
29 
30 class raw_ostream;
31 
32 namespace optional_detail {
33 
34 /// Storage for any type.
35 //
36 // The specialization condition intentionally uses
37 // llvm::is_trivially_{copy/move}_constructible instead of
38 // std::is_trivially_{copy/move}_constructible. GCC versions prior to 7.4 may
39 // instantiate the copy/move constructor of `T` when
40 // std::is_trivially_{copy/move}_constructible is instantiated. This causes
41 // compilation to fail if we query the trivially copy/move constructible
42 // property of a class which is not copy/move constructible.
43 //
44 // The current implementation of OptionalStorage insists that in order to use
45 // the trivial specialization, the value_type must be trivially copy
46 // constructible and trivially copy assignable due to =default implementations
47 // of the copy/move constructor/assignment. It does not follow that this is
48 // necessarily the case std::is_trivially_copyable is true (hence the expanded
49 // specialization condition).
50 //
51 // The move constructible / assignable conditions emulate the remaining behavior
52 // of std::is_trivially_copyable.
53 template <typename T,
55  std::is_trivially_copy_assignable<T>::value &&
57  !std::is_move_constructible<T>::value) &&
58  (std::is_trivially_move_assignable<T>::value ||
59  !std::is_move_assignable<T>::value))>
61  union {
62  char empty;
63  T val;
64  };
65  bool hasVal = false;
66 
67 public:
68  ~OptionalStorage() { reset(); }
69 
70  constexpr OptionalStorage() noexcept : empty() {}
71 
72  constexpr OptionalStorage(OptionalStorage const &other) : OptionalStorage() {
73  if (other.has_value()) {
74  emplace(other.val);
75  }
76  }
78  if (other.has_value()) {
79  emplace(std::move(other.val));
80  }
81  }
82 
83  template <class... Args>
84  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
85  : val(std::forward<Args>(args)...), hasVal(true) {}
86 
87  void reset() noexcept {
88  if (hasVal) {
89  val.~T();
90  hasVal = false;
91  }
92  }
93 
94  constexpr bool has_value() const noexcept { return hasVal; }
95  constexpr bool hasValue() const noexcept { return hasVal; }
96 
97  T &value() &noexcept {
98  assert(hasVal);
99  return val;
100  }
101  T &getValue() &noexcept {
102  assert(hasVal);
103  return val;
104  }
105  constexpr T const &value() const &noexcept {
106  assert(hasVal);
107  return val;
108  }
109  constexpr T const &getValue() const &noexcept {
110  assert(hasVal);
111  return val;
112  }
113  T &&value() &&noexcept {
114  assert(hasVal);
115  return std::move(val);
116  }
117  T &&getValue() &&noexcept {
118  assert(hasVal);
119  return std::move(val);
120  }
121 
122  template <class... Args> void emplace(Args &&...args) {
123  reset();
124  ::new ((void *)std::addressof(val)) T(std::forward<Args>(args)...);
125  hasVal = true;
126  }
127 
129  if (has_value()) {
130  val = y;
131  } else {
132  ::new ((void *)std::addressof(val)) T(y);
133  hasVal = true;
134  }
135  return *this;
136  }
138  if (has_value()) {
139  val = std::move(y);
140  } else {
141  ::new ((void *)std::addressof(val)) T(std::move(y));
142  hasVal = true;
143  }
144  return *this;
145  }
146 
148  if (other.has_value()) {
149  if (has_value()) {
150  val = other.val;
151  } else {
152  ::new ((void *)std::addressof(val)) T(other.val);
153  hasVal = true;
154  }
155  } else {
156  reset();
157  }
158  return *this;
159  }
160 
162  if (other.has_value()) {
163  if (has_value()) {
164  val = std::move(other.val);
165  } else {
166  ::new ((void *)std::addressof(val)) T(std::move(other.val));
167  hasVal = true;
168  }
169  } else {
170  reset();
171  }
172  return *this;
173  }
174 };
175 
176 template <typename T> class OptionalStorage<T, true> {
177  union {
178  char empty;
180  };
181  bool hasVal = false;
182 
183 public:
184  ~OptionalStorage() = default;
185 
186  constexpr OptionalStorage() noexcept : empty{} {}
187 
188  constexpr OptionalStorage(OptionalStorage const &other) = default;
189  constexpr OptionalStorage(OptionalStorage &&other) = default;
190 
191  OptionalStorage &operator=(OptionalStorage const &other) = default;
192  OptionalStorage &operator=(OptionalStorage &&other) = default;
193 
194  template <class... Args>
195  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
196  : val(std::forward<Args>(args)...), hasVal(true) {}
197 
198  void reset() noexcept {
199  if (hasVal) {
200  val.~T();
201  hasVal = false;
202  }
203  }
204 
205  constexpr bool has_value() const noexcept { return hasVal; }
206  constexpr bool hasValue() const noexcept { return hasVal; }
207 
208  T &value() &noexcept {
209  assert(hasVal);
210  return val;
211  }
212  T &getValue() &noexcept {
213  assert(hasVal);
214  return val;
215  }
216  constexpr T const &value() const &noexcept {
217  assert(hasVal);
218  return val;
219  }
220  constexpr T const &getValue() const &noexcept {
221  assert(hasVal);
222  return val;
223  }
224  T &&value() &&noexcept {
225  assert(hasVal);
226  return std::move(val);
227  }
228  T &&getValue() &&noexcept {
229  assert(hasVal);
230  return std::move(val);
231  }
232 
233  template <class... Args> void emplace(Args &&...args) {
234  reset();
235  ::new ((void *)std::addressof(val)) T(std::forward<Args>(args)...);
236  hasVal = true;
237  }
238 
240  if (has_value()) {
241  val = y;
242  } else {
243  ::new ((void *)std::addressof(val)) T(y);
244  hasVal = true;
245  }
246  return *this;
247  }
249  if (has_value()) {
250  val = std::move(y);
251  } else {
252  ::new ((void *)std::addressof(val)) T(std::move(y));
253  hasVal = true;
254  }
255  return *this;
256  }
257 };
258 
259 } // namespace optional_detail
260 
261 template <typename T> class Optional {
262  optional_detail::OptionalStorage<T> Storage;
263 
264 public:
265  using value_type = T;
266 
267  constexpr Optional() = default;
268  constexpr Optional(NoneType) {}
269 
270  constexpr Optional(const T &y) : Storage(in_place, y) {}
271  constexpr Optional(const Optional &O) = default;
272 
273  constexpr Optional(T &&y) : Storage(in_place, std::move(y)) {}
274  constexpr Optional(Optional &&O) = default;
275 
276  template <typename... ArgTypes>
277  constexpr Optional(in_place_t, ArgTypes &&...Args)
278  : Storage(in_place, std::forward<ArgTypes>(Args)...) {}
279 
281  Storage = std::move(y);
282  return *this;
283  }
284  Optional &operator=(Optional &&O) = default;
285 
286  /// Create a new object by constructing it in place with the given arguments.
287  template <typename... ArgTypes> void emplace(ArgTypes &&... Args) {
288  Storage.emplace(std::forward<ArgTypes>(Args)...);
289  }
290 
291  static constexpr Optional create(const T *y) {
292  return y ? Optional(*y) : Optional();
293  }
294 
295  Optional &operator=(const T &y) {
296  Storage = y;
297  return *this;
298  }
299  Optional &operator=(const Optional &O) = default;
300 
301  void reset() { Storage.reset(); }
302 
303  constexpr const T *getPointer() const { return &Storage.value(); }
304  T *getPointer() { return &Storage.value(); }
305  constexpr const T &value() const & { return Storage.value(); }
306  constexpr const T &getValue() const & { return Storage.value(); }
307  T &value() & { return Storage.value(); }
308  T &getValue() & { return Storage.value(); }
309 
310  constexpr explicit operator bool() const { return has_value(); }
311  constexpr bool has_value() const { return Storage.has_value(); }
312  constexpr bool hasValue() const { return Storage.has_value(); }
313  constexpr const T *operator->() const { return getPointer(); }
314  T *operator->() { return getPointer(); }
315  constexpr const T &operator*() const & { return value(); }
316  T &operator*() & { return value(); }
317 
318  template <typename U> constexpr T value_or(U &&alt) const & {
319  return has_value() ? value() : std::forward<U>(alt);
320  }
321  template <typename U> constexpr T getValueOr(U &&alt) const & {
322  return has_value() ? value() : std::forward<U>(alt);
323  }
324 
325  /// Apply a function to the value if present; otherwise return None.
326  template <class Function>
327  auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
328  if (*this)
329  return F(value());
330  return None;
331  }
332 
333  T &&value() && { return std::move(Storage.value()); }
334  T &&getValue() && { return std::move(Storage.value()); }
335  T &&operator*() && { return std::move(Storage.value()); }
336 
337  template <typename U> T value_or(U &&alt) && {
338  return has_value() ? std::move(value()) : std::forward<U>(alt);
339  }
340  template <typename U> T getValueOr(U &&alt) && {
341  return has_value() ? std::move(value()) : std::forward<U>(alt);
342  }
343 
344  /// Apply a function to the value if present; otherwise return None.
345  template <class Function>
346  auto map(const Function &F)
347  && -> Optional<decltype(F(std::move(*this).value()))> {
348  if (*this)
349  return F(std::move(*this).value());
350  return None;
351  }
352 };
353 
354 template <class T> llvm::hash_code hash_value(const Optional<T> &O) {
355  return O ? hash_combine(true, *O) : hash_value(false);
356 }
357 
358 template <typename T, typename U>
359 constexpr bool operator==(const Optional<T> &X, const Optional<U> &Y) {
360  if (X && Y)
361  return *X == *Y;
362  return X.has_value() == Y.has_value();
363 }
364 
365 template <typename T, typename U>
366 constexpr bool operator!=(const Optional<T> &X, const Optional<U> &Y) {
367  return !(X == Y);
368 }
369 
370 template <typename T, typename U>
371 constexpr bool operator<(const Optional<T> &X, const Optional<U> &Y) {
372  if (X && Y)
373  return *X < *Y;
374  return X.has_value() < Y.has_value();
375 }
376 
377 template <typename T, typename U>
378 constexpr bool operator<=(const Optional<T> &X, const Optional<U> &Y) {
379  return !(Y < X);
380 }
381 
382 template <typename T, typename U>
383 constexpr bool operator>(const Optional<T> &X, const Optional<U> &Y) {
384  return Y < X;
385 }
386 
387 template <typename T, typename U>
388 constexpr bool operator>=(const Optional<T> &X, const Optional<U> &Y) {
389  return !(X < Y);
390 }
391 
392 template <typename T>
393 constexpr bool operator==(const Optional<T> &X, NoneType) {
394  return !X;
395 }
396 
397 template <typename T>
398 constexpr bool operator==(NoneType, const Optional<T> &X) {
399  return X == None;
400 }
401 
402 template <typename T>
403 constexpr bool operator!=(const Optional<T> &X, NoneType) {
404  return !(X == None);
405 }
406 
407 template <typename T>
408 constexpr bool operator!=(NoneType, const Optional<T> &X) {
409  return X != None;
410 }
411 
412 template <typename T> constexpr bool operator<(const Optional<T> &, NoneType) {
413  return false;
414 }
415 
416 template <typename T> constexpr bool operator<(NoneType, const Optional<T> &X) {
417  return X.has_value();
418 }
419 
420 template <typename T>
421 constexpr bool operator<=(const Optional<T> &X, NoneType) {
422  return !(None < X);
423 }
424 
425 template <typename T>
426 constexpr bool operator<=(NoneType, const Optional<T> &X) {
427  return !(X < None);
428 }
429 
430 template <typename T> constexpr bool operator>(const Optional<T> &X, NoneType) {
431  return None < X;
432 }
433 
434 template <typename T> constexpr bool operator>(NoneType, const Optional<T> &X) {
435  return X < None;
436 }
437 
438 template <typename T>
439 constexpr bool operator>=(const Optional<T> &X, NoneType) {
440  return None <= X;
441 }
442 
443 template <typename T>
444 constexpr bool operator>=(NoneType, const Optional<T> &X) {
445  return X <= None;
446 }
447 
448 template <typename T>
449 constexpr bool operator==(const Optional<T> &X, const T &Y) {
450  return X && *X == Y;
451 }
452 
453 template <typename T>
454 constexpr bool operator==(const T &X, const Optional<T> &Y) {
455  return Y && X == *Y;
456 }
457 
458 template <typename T>
459 constexpr bool operator!=(const Optional<T> &X, const T &Y) {
460  return !(X == Y);
461 }
462 
463 template <typename T>
464 constexpr bool operator!=(const T &X, const Optional<T> &Y) {
465  return !(X == Y);
466 }
467 
468 template <typename T>
469 constexpr bool operator<(const Optional<T> &X, const T &Y) {
470  return !X || *X < Y;
471 }
472 
473 template <typename T>
474 constexpr bool operator<(const T &X, const Optional<T> &Y) {
475  return Y && X < *Y;
476 }
477 
478 template <typename T>
479 constexpr bool operator<=(const Optional<T> &X, const T &Y) {
480  return !(Y < X);
481 }
482 
483 template <typename T>
484 constexpr bool operator<=(const T &X, const Optional<T> &Y) {
485  return !(Y < X);
486 }
487 
488 template <typename T>
489 constexpr bool operator>(const Optional<T> &X, const T &Y) {
490  return Y < X;
491 }
492 
493 template <typename T>
494 constexpr bool operator>(const T &X, const Optional<T> &Y) {
495  return Y < X;
496 }
497 
498 template <typename T>
499 constexpr bool operator>=(const Optional<T> &X, const T &Y) {
500  return !(X < Y);
501 }
502 
503 template <typename T>
504 constexpr bool operator>=(const T &X, const Optional<T> &Y) {
505  return !(X < Y);
506 }
507 
508 raw_ostream &operator<<(raw_ostream &OS, NoneType);
509 
510 template <typename T, typename = decltype(std::declval<raw_ostream &>()
511  << std::declval<const T &>())>
512 raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
513  if (O)
514  OS << *O;
515  else
516  OS << None;
517  return OS;
518 }
519 
520 } // end namespace llvm
521 
522 #endif // LLVM_ADT_OPTIONAL_H
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(OptionalStorage &&other)
Definition: Optional.h:77
llvm::Optional::operator*
T && operator*() &&
Definition: Optional.h:335
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::Optional::Optional
constexpr Optional(NoneType)
Definition: Optional.h:268
llvm::Function
Definition: Function.h:60
llvm::operator<=
bool operator<=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:337
llvm::Optional::Optional
constexpr Optional(const T &y)
Definition: Optional.h:270
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(OptionalStorage &&other)
Definition: Optional.h:161
llvm::Optional::value
T & value() &
Definition: Optional.h:307
llvm::Optional::operator=
Optional & operator=(T &&y)
Definition: Optional.h:280
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1909
llvm::Optional::value_or
T value_or(U &&alt) &&
Definition: Optional.h:337
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage() noexcept
Definition: Optional.h:70
llvm::Optional::getValue
T & getValue() &
Definition: Optional.h:308
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1992
llvm::optional_detail::OptionalStorage< T, true >::getValue
T & getValue() &noexcept
Definition: Optional.h:212
llvm::Optional
Definition: APInt.h:33
T
#define T
Definition: Mips16ISelLowering.cpp:341
Hashing.h
llvm::optional_detail::OptionalStorage< T, true >::value
T && value() &&noexcept
Definition: Optional.h:224
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(in_place_t, Args &&...args)
Definition: Optional.h:84
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4828
new
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
Definition: README.txt:125
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::Optional::getPointer
constexpr const T * getPointer() const
Definition: Optional.h:303
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:312
llvm::optional_detail::OptionalStorage< T, true >::value
T & value() &noexcept
Definition: Optional.h:208
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::optional_detail::OptionalStorage< T, true >::emplace
void emplace(Args &&...args)
Definition: Optional.h:233
llvm::Optional::operator*
T & operator*() &
Definition: Optional.h:316
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(OptionalStorage const &other)
Definition: Optional.h:72
STLForwardCompat.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::Optional::create
static constexpr Optional create(const T *y)
Definition: Optional.h:291
llvm::None
const NoneType None
Definition: None.h:24
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::Optional::Optional
constexpr Optional(T &&y)
Definition: Optional.h:273
llvm::optional_detail::OptionalStorage< T, true >::has_value
constexpr bool has_value() const noexcept
Definition: Optional.h:205
llvm::optional_detail::OptionalStorage< T, true >::value
constexpr const T & value() const &noexcept
Definition: Optional.h:216
val
The initial backend is deliberately restricted to z10 We should add support for later architectures at some point If an asm ties an i32 r result to an i64 the input will be treated as an leaving the upper bits uninitialised For i64 store i32 val
Definition: README.txt:15
llvm::operator>=
bool operator>=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:338
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:239
llvm::optional_detail::OptionalStorage::getValue
T & getValue() &noexcept
Definition: Optional.h:101
uint64_t
llvm::Optional::reset
void reset()
Definition: Optional.h:301
llvm::Optional::getValue
T && getValue() &&
Definition: Optional.h:334
llvm::NoneType
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having t...
Definition: None.h:23
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::Optional::emplace
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
Definition: Optional.h:287
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:339
llvm::Optional::getPointer
T * getPointer()
Definition: Optional.h:304
llvm::optional_detail::OptionalStorage< T, true >::hasValue
constexpr bool hasValue() const noexcept
Definition: Optional.h:206
llvm::Optional::Optional
constexpr Optional(in_place_t, ArgTypes &&...Args)
Definition: Optional.h:277
llvm::optional_detail::OptionalStorage< T, true >::getValue
constexpr const T & getValue() const &noexcept
Definition: Optional.h:220
llvm::is_trivially_move_constructible
An implementation of std::is_trivially_move_constructible since we have users with STLs that don't ye...
Definition: type_traits.h:109
llvm::optional_detail::OptionalStorage::~OptionalStorage
~OptionalStorage()
Definition: Optional.h:68
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1675
llvm::Optional::getValue
constexpr const T & getValue() const &
Definition: Optional.h:306
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1990
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(T const &y)
Definition: Optional.h:128
llvm::in_place
constexpr in_place_t in_place
Definition: STLForwardCompat.h:53
llvm::optional_detail::OptionalStorage< T, true >::OptionalStorage
constexpr OptionalStorage() noexcept
Definition: Optional.h:186
None.h
llvm::optional_detail::OptionalStorage::getValue
T && getValue() &&noexcept
Definition: Optional.h:117
llvm::optional_detail::OptionalStorage::reset
void reset() noexcept
Definition: Optional.h:87
Compiler.h
llvm::is_trivially_copy_constructible
An implementation of std::is_trivially_copy_constructible since we have users with STLs that don't ye...
Definition: type_traits.h:98
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(OptionalStorage const &other)
Definition: Optional.h:147
llvm::Optional::operator->
constexpr const T * operator->() const
Definition: Optional.h:313
llvm::optional_detail::OptionalStorage< T, true >::val
T val
Definition: Optional.h:179
llvm::Optional::has_value
constexpr bool has_value() const
Definition: Optional.h:311
llvm::optional_detail::OptionalStorage::hasValue
constexpr bool hasValue() const noexcept
Definition: Optional.h:95
llvm::Optional::getValueOr
T getValueOr(U &&alt) &&
Definition: Optional.h:340
llvm::optional_detail::OptionalStorage< T, true >::operator=
OptionalStorage & operator=(T &&y)
Definition: Optional.h:248
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:115
llvm::optional_detail::OptionalStorage::getValue
constexpr const T & getValue() const &noexcept
Definition: Optional.h:109
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:268
llvm::optional_detail::OptionalStorage::val
T val
Definition: Optional.h:63
std
Definition: BitVector.h:851
type_traits.h
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(T &&y)
Definition: Optional.h:137
llvm::Optional::operator->
T * operator->()
Definition: Optional.h:314
llvm::optional_detail::OptionalStorage::value
constexpr const T & value() const &noexcept
Definition: Optional.h:105
llvm::Optional::value
T && value() &&
Definition: Optional.h:333
y
into llvm powi allowing the code generator to produce balanced multiplication trees the intrinsic needs to be extended to support and second the code generator needs to be enhanced to lower these to multiplication trees Interesting testcase for add shift mul int y
Definition: README.txt:61
llvm::Optional::map
auto map(const Function &F) &&-> Optional< decltype(F(std::move(*this).value()))>
Apply a function to the value if present; otherwise return None.
Definition: Optional.h:346
llvm::optional_detail::OptionalStorage::empty
char empty
Definition: Optional.h:62
llvm::in_place_t
Definition: STLForwardCompat.h:48
llvm::optional_detail::OptionalStorage::emplace
void emplace(Args &&...args)
Definition: Optional.h:122
llvm::hash_combine
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:605
llvm::Optional::operator=
Optional & operator=(const T &y)
Definition: Optional.h:295
llvm::operator>
bool operator>(int64_t V1, const APSInt &V2)
Definition: APSInt.h:340
llvm::optional_detail::OptionalStorage::value
T & value() &noexcept
Definition: Optional.h:97
llvm::optional_detail::OptionalStorage< T, true >::empty
char empty
Definition: Optional.h:178
llvm::Optional::value
constexpr const T & value() const &
Definition: Optional.h:305
llvm::Optional::map
auto map(const Function &F) const &-> Optional< decltype(F(value()))>
Apply a function to the value if present; otherwise return None.
Definition: Optional.h:327
llvm::optional_detail::OptionalStorage::has_value
constexpr bool has_value() const noexcept
Definition: Optional.h:94
llvm::optional_detail::OptionalStorage< T, true >::getValue
T && getValue() &&noexcept
Definition: Optional.h:228
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::optional_detail::OptionalStorage< T, true >::reset
void reset() noexcept
Definition: Optional.h:198
llvm::Optional::Optional
constexpr Optional()=default
llvm::optional_detail::OptionalStorage< T, true >::operator=
OptionalStorage & operator=(T const &y)
Definition: Optional.h:239
llvm::optional_detail::OptionalStorage::value
T && value() &&noexcept
Definition: Optional.h:113
llvm::optional_detail::OptionalStorage
Storage for any type.
Definition: Optional.h:60
llvm::Optional::getValueOr
constexpr T getValueOr(U &&alt) const &
Definition: Optional.h:321
llvm::Optional::value_or
constexpr T value_or(U &&alt) const &
Definition: Optional.h:318
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:73
llvm::Optional::operator*
constexpr const T & operator*() const &
Definition: Optional.h:315
llvm::optional_detail::OptionalStorage< T, true >::OptionalStorage
constexpr OptionalStorage(in_place_t, Args &&...args)
Definition: Optional.h:195