LLVM  16.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(std::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  LLVM_DEPRECATED("Use has_value instead.", "has_value")
96  constexpr bool hasValue() const noexcept {
97  return hasVal;
98  }
99 
100  T &value() &noexcept {
101  assert(hasVal);
102  return val;
103  }
104  LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept {
105  assert(hasVal);
106  return val;
107  }
108  constexpr T const &value() const &noexcept {
109  assert(hasVal);
110  return val;
111  }
112  LLVM_DEPRECATED("Use value instead.", "value")
113  constexpr T const &getValue() const &noexcept {
114  assert(hasVal);
115  return val;
116  }
117  T &&value() &&noexcept {
118  assert(hasVal);
119  return std::move(val);
120  }
121  LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept {
122  assert(hasVal);
123  return std::move(val);
124  }
125 
126  template <class... Args> void emplace(Args &&...args) {
127  reset();
128  ::new ((void *)std::addressof(val)) T(std::forward<Args>(args)...);
129  hasVal = true;
130  }
131 
133  if (has_value()) {
134  val = y;
135  } else {
136  ::new ((void *)std::addressof(val)) T(y);
137  hasVal = true;
138  }
139  return *this;
140  }
142  if (has_value()) {
143  val = std::move(y);
144  } else {
145  ::new ((void *)std::addressof(val)) T(std::move(y));
146  hasVal = true;
147  }
148  return *this;
149  }
150 
152  if (other.has_value()) {
153  if (has_value()) {
154  val = other.val;
155  } else {
156  ::new ((void *)std::addressof(val)) T(other.val);
157  hasVal = true;
158  }
159  } else {
160  reset();
161  }
162  return *this;
163  }
164 
166  if (other.has_value()) {
167  if (has_value()) {
168  val = std::move(other.val);
169  } else {
170  ::new ((void *)std::addressof(val)) T(std::move(other.val));
171  hasVal = true;
172  }
173  } else {
174  reset();
175  }
176  return *this;
177  }
178 };
179 
180 template <typename T> class OptionalStorage<T, true> {
181  union {
182  char empty;
184  };
185  bool hasVal = false;
186 
187 public:
188  ~OptionalStorage() = default;
189 
190  constexpr OptionalStorage() noexcept : empty{} {}
191 
192  constexpr OptionalStorage(OptionalStorage const &other) = default;
193  constexpr OptionalStorage(OptionalStorage &&other) = default;
194 
195  OptionalStorage &operator=(OptionalStorage const &other) = default;
196  OptionalStorage &operator=(OptionalStorage &&other) = default;
197 
198  template <class... Args>
199  constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
200  : val(std::forward<Args>(args)...), hasVal(true) {}
201 
202  void reset() noexcept {
203  if (hasVal) {
204  val.~T();
205  hasVal = false;
206  }
207  }
208 
209  constexpr bool has_value() const noexcept { return hasVal; }
210  LLVM_DEPRECATED("Use has_value instead.", "has_value")
211  constexpr bool hasValue() const noexcept {
212  return hasVal;
213  }
214 
215  T &value() &noexcept {
216  assert(hasVal);
217  return val;
218  }
219  LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept {
220  assert(hasVal);
221  return val;
222  }
223  constexpr T const &value() const &noexcept {
224  assert(hasVal);
225  return val;
226  }
227  LLVM_DEPRECATED("Use value instead.", "value")
228  constexpr T const &getValue() const &noexcept {
229  assert(hasVal);
230  return val;
231  }
232  T &&value() &&noexcept {
233  assert(hasVal);
234  return std::move(val);
235  }
236  LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept {
237  assert(hasVal);
238  return std::move(val);
239  }
240 
241  template <class... Args> void emplace(Args &&...args) {
242  reset();
243  ::new ((void *)std::addressof(val)) T(std::forward<Args>(args)...);
244  hasVal = true;
245  }
246 
248  if (has_value()) {
249  val = y;
250  } else {
251  ::new ((void *)std::addressof(val)) T(y);
252  hasVal = true;
253  }
254  return *this;
255  }
257  if (has_value()) {
258  val = std::move(y);
259  } else {
260  ::new ((void *)std::addressof(val)) T(std::move(y));
261  hasVal = true;
262  }
263  return *this;
264  }
265 };
266 
267 } // namespace optional_detail
268 
269 template <typename T> class Optional {
270  optional_detail::OptionalStorage<T> Storage;
271 
272 public:
273  using value_type = T;
274 
275  constexpr Optional() = default;
276  constexpr Optional(NoneType) {}
277 
278  constexpr Optional(const T &y) : Storage(std::in_place, y) {}
279  constexpr Optional(const Optional &O) = default;
280 
281  constexpr Optional(T &&y) : Storage(std::in_place, std::move(y)) {}
282  constexpr Optional(Optional &&O) = default;
283 
284  template <typename... ArgTypes>
285  constexpr Optional(std::in_place_t, ArgTypes &&...Args)
286  : Storage(std::in_place, std::forward<ArgTypes>(Args)...) {}
287 
289  Storage = std::move(y);
290  return *this;
291  }
292  Optional &operator=(Optional &&O) = default;
293 
294  /// Create a new object by constructing it in place with the given arguments.
295  template <typename... ArgTypes> void emplace(ArgTypes &&... Args) {
296  Storage.emplace(std::forward<ArgTypes>(Args)...);
297  }
298 
299  static constexpr Optional create(const T *y) {
300  return y ? Optional(*y) : Optional();
301  }
302 
303  Optional &operator=(const T &y) {
304  Storage = y;
305  return *this;
306  }
307  Optional &operator=(const Optional &O) = default;
308 
309  void reset() { Storage.reset(); }
310 
311  constexpr const T *getPointer() const { return &Storage.value(); }
312  T *getPointer() { return &Storage.value(); }
313  constexpr const T &value() const & { return Storage.value(); }
314  LLVM_DEPRECATED("Use value instead.", "value")
315  constexpr const T &getValue() const & {
316  return Storage.value();
317  }
318  T &value() & { return Storage.value(); }
319  LLVM_DEPRECATED("Use value instead.", "value") T &getValue() & {
320  return Storage.value();
321  }
322 
323  constexpr explicit operator bool() const { return has_value(); }
324  constexpr bool has_value() const { return Storage.has_value(); }
325  LLVM_DEPRECATED("Use has_value instead.", "has_value")
326  constexpr bool hasValue() const {
327  return Storage.has_value();
328  }
329  constexpr const T *operator->() const { return getPointer(); }
330  T *operator->() { return getPointer(); }
331  constexpr const T &operator*() const & { return value(); }
332  T &operator*() & { return value(); }
333 
334  template <typename U> constexpr T value_or(U &&alt) const & {
335  return has_value() ? value() : std::forward<U>(alt);
336  }
337  template <typename U>
338  LLVM_DEPRECATED("Use value_or instead.", "value_or")
339  constexpr T getValueOr(U &&alt) const & {
340  return has_value() ? value() : std::forward<U>(alt);
341  }
342 
343  /// Apply a function to the value if present; otherwise return None.
344  template <class Function>
345  auto transform(const Function &F) const & -> Optional<decltype(F(value()))> {
346  if (*this)
347  return F(value());
348  return None;
349  }
350  template <class Function>
351  LLVM_DEPRECATED("Use transform instead.", "transform")
352  auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
353  if (*this)
354  return F(value());
355  return None;
356  }
357 
358  T &&value() && { return std::move(Storage.value()); }
359  LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() && {
360  return std::move(Storage.value());
361  }
362  T &&operator*() && { return std::move(Storage.value()); }
363 
364  template <typename U> T value_or(U &&alt) && {
365  return has_value() ? std::move(value()) : std::forward<U>(alt);
366  }
367  template <typename U>
368  LLVM_DEPRECATED("Use value_or instead.", "value_or")
369  T getValueOr(U &&alt) && {
370  return has_value() ? std::move(value()) : std::forward<U>(alt);
371  }
372 
373  /// Apply a function to the value if present; otherwise return None.
374  template <class Function>
375  auto transform(
376  const Function &F) && -> Optional<decltype(F(std::move(*this).value()))> {
377  if (*this)
378  return F(std::move(*this).value());
379  return None;
380  }
381  template <class Function>
382  LLVM_DEPRECATED("Use transform instead.", "transform")
384  && -> Optional<decltype(F(std::move(*this).value()))> {
385  if (*this)
386  return F(std::move(*this).value());
387  return None;
388  }
389 };
390 
391 template <class T> llvm::hash_code hash_value(const Optional<T> &O) {
392  return O ? hash_combine(true, *O) : hash_value(false);
393 }
394 
395 template <typename T, typename U>
396 constexpr bool operator==(const Optional<T> &X, const Optional<U> &Y) {
397  if (X && Y)
398  return *X == *Y;
399  return X.has_value() == Y.has_value();
400 }
401 
402 template <typename T, typename U>
403 constexpr bool operator!=(const Optional<T> &X, const Optional<U> &Y) {
404  return !(X == Y);
405 }
406 
407 template <typename T, typename U>
408 constexpr bool operator<(const Optional<T> &X, const Optional<U> &Y) {
409  if (X && Y)
410  return *X < *Y;
411  return X.has_value() < Y.has_value();
412 }
413 
414 template <typename T, typename U>
415 constexpr bool operator<=(const Optional<T> &X, const Optional<U> &Y) {
416  return !(Y < X);
417 }
418 
419 template <typename T, typename U>
420 constexpr bool operator>(const Optional<T> &X, const Optional<U> &Y) {
421  return Y < X;
422 }
423 
424 template <typename T, typename U>
425 constexpr bool operator>=(const Optional<T> &X, const Optional<U> &Y) {
426  return !(X < Y);
427 }
428 
429 template <typename T>
430 constexpr bool operator==(const Optional<T> &X, NoneType) {
431  return !X;
432 }
433 
434 template <typename T>
435 constexpr bool operator==(NoneType, const Optional<T> &X) {
436  return X == None;
437 }
438 
439 template <typename T>
440 constexpr bool operator!=(const Optional<T> &X, NoneType) {
441  return !(X == None);
442 }
443 
444 template <typename T>
445 constexpr bool operator!=(NoneType, const Optional<T> &X) {
446  return X != None;
447 }
448 
449 template <typename T> constexpr bool operator<(const Optional<T> &, NoneType) {
450  return false;
451 }
452 
453 template <typename T> constexpr bool operator<(NoneType, const Optional<T> &X) {
454  return X.has_value();
455 }
456 
457 template <typename T>
458 constexpr bool operator<=(const Optional<T> &X, NoneType) {
459  return !(None < X);
460 }
461 
462 template <typename T>
463 constexpr bool operator<=(NoneType, const Optional<T> &X) {
464  return !(X < None);
465 }
466 
467 template <typename T> constexpr bool operator>(const Optional<T> &X, NoneType) {
468  return None < X;
469 }
470 
471 template <typename T> constexpr bool operator>(NoneType, const Optional<T> &X) {
472  return X < None;
473 }
474 
475 template <typename T>
476 constexpr bool operator>=(const Optional<T> &X, NoneType) {
477  return None <= X;
478 }
479 
480 template <typename T>
481 constexpr bool operator>=(NoneType, const Optional<T> &X) {
482  return X <= None;
483 }
484 
485 template <typename T>
486 constexpr bool operator==(const Optional<T> &X, const T &Y) {
487  return X && *X == Y;
488 }
489 
490 template <typename T>
491 constexpr bool operator==(const T &X, const Optional<T> &Y) {
492  return Y && X == *Y;
493 }
494 
495 template <typename T>
496 constexpr bool operator!=(const Optional<T> &X, const T &Y) {
497  return !(X == Y);
498 }
499 
500 template <typename T>
501 constexpr bool operator!=(const T &X, const Optional<T> &Y) {
502  return !(X == Y);
503 }
504 
505 template <typename T>
506 constexpr bool operator<(const Optional<T> &X, const T &Y) {
507  return !X || *X < Y;
508 }
509 
510 template <typename T>
511 constexpr bool operator<(const T &X, const Optional<T> &Y) {
512  return Y && X < *Y;
513 }
514 
515 template <typename T>
516 constexpr bool operator<=(const Optional<T> &X, const T &Y) {
517  return !(Y < X);
518 }
519 
520 template <typename T>
521 constexpr bool operator<=(const T &X, const Optional<T> &Y) {
522  return !(Y < X);
523 }
524 
525 template <typename T>
526 constexpr bool operator>(const Optional<T> &X, const T &Y) {
527  return Y < X;
528 }
529 
530 template <typename T>
531 constexpr bool operator>(const T &X, const Optional<T> &Y) {
532  return Y < X;
533 }
534 
535 template <typename T>
536 constexpr bool operator>=(const Optional<T> &X, const T &Y) {
537  return !(X < Y);
538 }
539 
540 template <typename T>
541 constexpr bool operator>=(const T &X, const Optional<T> &Y) {
542  return !(X < Y);
543 }
544 
545 raw_ostream &operator<<(raw_ostream &OS, NoneType);
546 
547 template <typename T, typename = decltype(std::declval<raw_ostream &>()
548  << std::declval<const T &>())>
549 raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
550  if (O)
551  OS << *O;
552  else
553  OS << None;
554  return OS;
555 }
556 
557 } // end namespace llvm
558 
559 #endif // LLVM_ADT_OPTIONAL_H
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(std::in_place_t, Args &&...args)
Definition: Optional.h:84
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(OptionalStorage &&other)
Definition: Optional.h:77
llvm::Optional::operator*
T && operator*() &&
Definition: Optional.h:362
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Optional::Optional
constexpr Optional(NoneType)
Definition: Optional.h:276
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:278
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(OptionalStorage &&other)
Definition: Optional.h:165
llvm::optional_detail::OptionalStorage< T, true >::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept
Definition: Optional.h:219
llvm::optional_detail::OptionalStorage::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept
Definition: Optional.h:104
llvm::Optional::value
T & value() &
Definition: Optional.h:318
llvm::Optional::operator=
Optional & operator=(T &&y)
Definition: Optional.h:288
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1835
llvm::Optional::value_or
T value_or(U &&alt) &&
Definition: Optional.h:364
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage() noexcept
Definition: Optional.h:70
llvm::optional_detail::OptionalStorage< T, true >::OptionalStorage
constexpr OptionalStorage(std::in_place_t, Args &&...args)
Definition: Optional.h:199
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1992
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:232
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4890
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:311
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:326
llvm::optional_detail::OptionalStorage< T, true >::value
T & value() &noexcept
Definition: Optional.h:215
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::optional_detail::OptionalStorage::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept
Definition: Optional.h:121
llvm::optional_detail::OptionalStorage< T, true >::emplace
void emplace(Args &&...args)
Definition: Optional.h:241
llvm::Optional::operator*
T & operator*() &
Definition: Optional.h:332
llvm::Optional::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&
Definition: Optional.h:359
llvm::optional_detail::OptionalStorage::OptionalStorage
constexpr OptionalStorage(OptionalStorage const &other)
Definition: Optional.h:72
LLVM_DEPRECATED
#define LLVM_DEPRECATED(MSG, FIX)
Definition: Compiler.h:145
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:52
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:299
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:281
llvm::optional_detail::OptionalStorage< T, true >::has_value
constexpr bool has_value() const noexcept
Definition: Optional.h:209
llvm::optional_detail::OptionalStorage< T, true >::value
constexpr const T & value() const &noexcept
Definition: Optional.h:223
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:264
uint64_t
llvm::Optional::reset
void reset()
Definition: Optional.h:309
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:295
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:312
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:1666
llvm::Optional::getValue
constexpr const T & getValue() const &
Definition: Optional.h:315
llvm::optional_detail::OptionalStorage< T, true >::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept
Definition: Optional.h:236
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:132
llvm::optional_detail::OptionalStorage< T, true >::OptionalStorage
constexpr OptionalStorage() noexcept
Definition: Optional.h:190
None.h
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
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:151
llvm::Optional::operator->
constexpr const T * operator->() const
Definition: Optional.h:329
llvm::optional_detail::OptionalStorage< T, true >::val
T val
Definition: Optional.h:183
llvm::Optional::has_value
constexpr bool has_value() const
Definition: Optional.h:324
llvm::optional_detail::OptionalStorage::hasValue
constexpr bool hasValue() const noexcept
Definition: Optional.h:96
llvm::optional_detail::OptionalStorage< T, true >::operator=
OptionalStorage & operator=(T &&y)
Definition: Optional.h:256
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:116
llvm::optional_detail::OptionalStorage::getValue
constexpr const T & getValue() const &noexcept
Definition: Optional.h:113
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:256
llvm::optional_detail::OptionalStorage::val
T val
Definition: Optional.h:63
std
Definition: BitVector.h:851
type_traits.h
llvm::Optional::LLVM_DEPRECATED
LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &
Definition: Optional.h:319
llvm::optional_detail::OptionalStorage::operator=
OptionalStorage & operator=(T &&y)
Definition: Optional.h:141
llvm::Optional::operator->
T * operator->()
Definition: Optional.h:330
llvm::optional_detail::OptionalStorage::value
constexpr const T & value() const &noexcept
Definition: Optional.h:108
llvm::Optional::value
T && value() &&
Definition: Optional.h:358
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_detail::OptionalStorage::empty
char empty
Definition: Optional.h:62
llvm::Optional::transform
auto transform(const Function &F) const &-> Optional< decltype(F(value()))>
Apply a function to the value if present; otherwise return None.
Definition: Optional.h:345
llvm::optional_detail::OptionalStorage::emplace
void emplace(Args &&...args)
Definition: Optional.h:126
llvm::hash_combine
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:605
llvm::Optional::transform
auto transform(const Function &F) &&-> Optional< decltype(F(std::move(*this).value()))>
Apply a function to the value if present; otherwise return None.
Definition: Optional.h:375
llvm::Optional::operator=
Optional & operator=(const T &y)
Definition: Optional.h:303
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:100
llvm::optional_detail::OptionalStorage< T, true >::empty
char empty
Definition: Optional.h:182
llvm::Optional::value
constexpr const T & value() const &
Definition: Optional.h:313
llvm::Optional::Optional
constexpr Optional(std::in_place_t, ArgTypes &&...Args)
Definition: Optional.h:285
llvm::Optional::map
auto map(const Function &F) const &-> Optional< decltype(F(value()))>
Definition: Optional.h:352
llvm::optional_detail::OptionalStorage::has_value
constexpr bool has_value() const noexcept
Definition: Optional.h:94
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:202
llvm::Optional::Optional
constexpr Optional()=default
llvm::optional_detail::OptionalStorage< T, true >::operator=
OptionalStorage & operator=(T const &y)
Definition: Optional.h:247
llvm::optional_detail::OptionalStorage::value
T && value() &&noexcept
Definition: Optional.h:117
llvm::optional_detail::OptionalStorage
Storage for any type.
Definition: Optional.h:60
llvm::Optional::getValueOr
constexpr T getValueOr(U &&alt) const &
Definition: Optional.h:339
llvm::Optional::value_or
constexpr T value_or(U &&alt) const &
Definition: Optional.h:334
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:331