Skip to content

Commit 354b334

Browse files
committed
[clang] Diagnose the dangling references for vector.
1 parent 36235ce commit 354b334

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/lib/Sema/CheckExprLifetime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ shouldTrackFirstArgumentForConstructor(const CXXConstructExpr *Ctor) {
404404
if (LHSRecordDecl->hasAttr<PointerAttr>())
405405
return true;
406406

407-
if (Ctor->getConstructor()->getNumParams() != 1 ||
407+
if (Ctor->getConstructor()->getNumParams() < 1 ||
408408
!isContainerOfPointer(LHSRecordDecl))
409409
return false;
410410

clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,16 @@ template<typename T>
164164
struct initializer_list {
165165
const T* ptr; size_t sz;
166166
};
167-
template <typename T>
167+
template<typename T> class allocator {};
168+
template <typename T, typename Alloc = allocator<T>>
168169
struct vector {
169170
typedef __gnu_cxx::basic_iterator<T> iterator;
170171
iterator begin();
171172
iterator end();
172173
const T *data() const;
173174
vector();
174-
vector(initializer_list<T> __l);
175+
vector(initializer_list<T> __l,
176+
const Alloc& alloc = Alloc());
175177

176178
template<typename InputIterator>
177179
vector(InputIterator first, InputIterator __last);

0 commit comments

Comments
 (0)