xref: /llvm-project/clang/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp (revision d3c54313abe723c834462e9ed8f738fc0b7ca542)
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 
testList_pop_front(std::list<int> list)10 void testList_pop_front(std::list<int> list) {
11   while(!list.empty())
12     list.pop_front();  // no-warning
13 }
14 
testBasicStringSuppression()15 void testBasicStringSuppression() {
16   std::basic_string<uint8_t> v;
17   v.push_back(1); // no-warning
18 }
19 
testBasicStringSuppression_append()20 void testBasicStringSuppression_append() {
21   std::basic_string<char32_t> v;
22   v += 'c'; // no-warning
23 }
24 
testBasicStringSuppression_assign(std::basic_string<char32_t> & v,const std::basic_string<char32_t> & v2)25 void testBasicStringSuppression_assign(std::basic_string<char32_t> &v,
26                                        const std::basic_string<char32_t> &v2) {
27   v = v2; // no-warning
28 }
29 
30 class MyEngine;
testSuppression_independent_bits_engine(MyEngine & e)31 void testSuppression_independent_bits_engine(MyEngine& e) {
32   std::__independent_bits_engine<MyEngine, unsigned int> x(e, 64); // no-warning
33 }
34 
testSuppression_std_shared_pointer()35 void testSuppression_std_shared_pointer() {
36   std::shared_ptr<int> p(new int(1));
37 
38   p = nullptr; // no-warning
39 }
40