Skip to content

Commit 478aa02

Browse files
[ADT] Simplify getFirstEl (NFC) (#153127)
getFirstEl computes the address of FirstEl. This patch computes the address by first casting this to SmallVectorAlignmentAndSize<T> and letting the C++ language compute the field address instead of adding the offset to this on our own.
1 parent f90ded5 commit 478aa02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ class SmallVectorTemplateCommon
128128
/// SmallVectorStorage is properly-aligned even for small-size of 0.
129129
void *getFirstEl() const {
130130
return const_cast<void *>(reinterpret_cast<const void *>(
131-
reinterpret_cast<const char *>(this) +
132-
offsetof(SmallVectorAlignmentAndSize<T>, FirstEl)));
131+
reinterpret_cast<const SmallVectorAlignmentAndSize<T> *>(this)
132+
->FirstEl));
133133
}
134134
// Space after 'FirstEl' is clobbered, do not add any instance vars after it.
135135

0 commit comments

Comments
 (0)