Clang Project

clang_source_code/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s
2// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -verify %s
3// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
4// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
5
6// expected-no-diagnostics
7
8#include "../Inputs/system-header-simulator-cxx-std-suppression.h"
9
10void testList_pop_front(std::list<int> list) {
11  while(!list.empty())
12    list.pop_front();  // no-warning
13}
14
15void testBasicStringSuppression() {
16  std::basic_string<uint8_t> v;
17  v.push_back(1); // no-warning
18}
19
20void testBasicStringSuppression_append() {
21  std::basic_string<char32_t> v;
22  v += 'c'; // no-warning
23}
24
25void testBasicStringSuppression_assign(std::basic_string<char32_t> &v,
26                                       const std::basic_string<char32_t> &v2) {
27  v = v2; // no-warning
28}
29
30class MyEngine;
31void testSuppression_independent_bits_engine(MyEngine& e) {
32  std::__independent_bits_engine<MyEngine, unsigned int> x(e, 64); // no-warning
33}
34
35void testSuppression_std_shared_pointer() {
36  std::shared_ptr<int> p(new int(1));
37
38  p = nullptr; // no-warning
39}
40