From 461a67fa15370a9ec88f8f8a240bf7c123bb2029 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:11:37 +0000 Subject: Vendor import of clang trunk r321017: https://llvm.org/svn/llvm-project/cfe/trunk@321017 --- test/Analysis/initializer.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/Analysis/initializer.cpp') diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index c73635686d83..6359b93d0a29 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s void clang_analyzer_eval(bool); +#include "Inputs/system-header-simulator-cxx.h" + class A { int x; public: @@ -204,3 +206,21 @@ struct C { const char(&f)[2]; }; } + +namespace CXX_initializer_lists { +struct C { + C(std::initializer_list list); +}; +void testPointerEscapeIntoLists() { + C empty{}; // no-crash + + // Do not warn that 'x' leaks. It might have been deleted by + // the destructor of 'c'. + int *x = new int; + C c{x}; // no-warning +} + +void testPassListsWithExplicitConstructors() { + (void)(std::initializer_list){12}; // no-crash +} +} -- cgit v1.3