Skip to content

Commit 53fc7e1

Browse files
committed
Reformat.
llvm-svn: 317078
1 parent 7c1ef4a commit 53fc7e1

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

llvm/include/llvm/ADT/Optional.h

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
namespace llvm {
2929

30-
template<typename T>
31-
class Optional {
30+
template <typename T> class Optional {
3231
AlignedCharArrayUnion<T> storage;
3332
bool hasVal = false;
3433

@@ -38,18 +37,14 @@ class Optional {
3837
Optional(NoneType) {}
3938
explicit Optional() {}
4039

41-
Optional(const T &y) : hasVal(true) {
42-
new (storage.buffer) T(y);
43-
}
40+
Optional(const T &y) : hasVal(true) { new (storage.buffer) T(y); }
4441

4542
Optional(const Optional &O) : hasVal(O.hasVal) {
4643
if (hasVal)
4744
new (storage.buffer) T(*O);
4845
}
4946

50-
Optional(T &&y) : hasVal(true) {
51-
new (storage.buffer) T(std::forward<T>(y));
52-
}
47+
Optional(T &&y) : hasVal(true) { new (storage.buffer) T(std::forward<T>(y)); }
5348

5449
Optional(Optional<T> &&O) : hasVal(O) {
5550
if (O) {
@@ -58,9 +53,7 @@ class Optional {
5853
}
5954
}
6055

61-
~Optional() {
62-
reset();
63-
}
56+
~Optional() { reset(); }
6457

6558
Optional &operator=(T &&y) {
6659
if (hasVal)
@@ -83,14 +76,13 @@ class Optional {
8376
}
8477

8578
/// Create a new object by constructing it in place with the given arguments.
86-
template<typename ...ArgTypes>
87-
void emplace(ArgTypes &&...Args) {
79+
template <typename... ArgTypes> void emplace(ArgTypes &&... Args) {
8880
reset();
8981
hasVal = true;
9082
new (storage.buffer) T(std::forward<ArgTypes>(Args)...);
9183
}
9284

93-
static inline Optional create(const T* y) {
85+
static inline Optional create(const T *y) {
9486
return y ? Optional(*y) : Optional();
9587
}
9688

@@ -124,26 +116,50 @@ class Optional {
124116
}
125117
}
126118

127-
const T* getPointer() const { assert(hasVal); return reinterpret_cast<const T*>(storage.buffer); }
128-
T* getPointer() { assert(hasVal); return reinterpret_cast<T*>(storage.buffer); }
129-
const T& getValue() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
130-
T& getValue() LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
119+
const T *getPointer() const {
120+
assert(hasVal);
121+
return reinterpret_cast<const T *>(storage.buffer);
122+
}
123+
T *getPointer() {
124+
assert(hasVal);
125+
return reinterpret_cast<T *>(storage.buffer);
126+
}
127+
const T &getValue() const LLVM_LVALUE_FUNCTION {
128+
assert(hasVal);
129+
return *getPointer();
130+
}
131+
T &getValue() LLVM_LVALUE_FUNCTION {
132+
assert(hasVal);
133+
return *getPointer();
134+
}
131135

132136
explicit operator bool() const { return hasVal; }
133137
bool hasValue() const { return hasVal; }
134-
const T* operator->() const { return getPointer(); }
135-
T* operator->() { return getPointer(); }
136-
const T& operator*() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
137-
T& operator*() LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
138+
const T *operator->() const { return getPointer(); }
139+
T *operator->() { return getPointer(); }
140+
const T &operator*() const LLVM_LVALUE_FUNCTION {
141+
assert(hasVal);
142+
return *getPointer();
143+
}
144+
T &operator*() LLVM_LVALUE_FUNCTION {
145+
assert(hasVal);
146+
return *getPointer();
147+
}
138148

139149
template <typename U>
140150
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION {
141151
return hasValue() ? getValue() : std::forward<U>(value);
142152
}
143153

144154
#if LLVM_HAS_RVALUE_REFERENCE_THIS
145-
T&& getValue() && { assert(hasVal); return std::move(*getPointer()); }
146-
T&& operator*() && { assert(hasVal); return std::move(*getPointer()); }
155+
T &&getValue() && {
156+
assert(hasVal);
157+
return std::move(*getPointer());
158+
}
159+
T &&operator*() && {
160+
assert(hasVal);
161+
return std::move(*getPointer());
162+
}
147163

148164
template <typename U>
149165
T getValueOr(U &&value) && {

0 commit comments

Comments
 (0)