Skip to content

Commit 2984156

Browse files
author
Andy Kaylor
authored
Make SmallVectorImpl destructor protected (#71746)
Because the SmallVectorImpl destructor is not virtual, the destructor of derived classes will not be called if pointers to the SmallVectorImpl class are deleted directly. Making the SmallVectorImpl destructor protected will prevent this.
1 parent 7360d5d commit 2984156

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,16 +601,16 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T> {
601601
RHS.resetToSmall();
602602
}
603603

604-
public:
605-
SmallVectorImpl(const SmallVectorImpl &) = delete;
606-
607604
~SmallVectorImpl() {
608605
// Subclass has already destructed this vector's elements.
609606
// If this wasn't grown from the inline copy, deallocate the old space.
610607
if (!this->isSmall())
611608
free(this->begin());
612609
}
613610

611+
public:
612+
SmallVectorImpl(const SmallVectorImpl &) = delete;
613+
614614
void clear() {
615615
this->destroy_range(this->begin(), this->end());
616616
this->Size = 0;

0 commit comments

Comments
 (0)