xref: /aosp_15_r20/external/clang/test/Analysis/diagnostics/explicit-suppression.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=false -verify %s
2*67e74705SXin Li // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=true -DSUPPRESSED=1 -verify %s
3*67e74705SXin Li 
4*67e74705SXin Li #ifdef SUPPRESSED
5*67e74705SXin Li // expected-no-diagnostics
6*67e74705SXin Li #endif
7*67e74705SXin Li 
8*67e74705SXin Li #include "../Inputs/system-header-simulator-cxx.h"
9*67e74705SXin Li 
10*67e74705SXin Li void clang_analyzer_eval(bool);
11*67e74705SXin Li 
12*67e74705SXin Li class C {
13*67e74705SXin Li   // The virtual function is to make C not trivially copy assignable so that we call the
14*67e74705SXin Li   // variant of std::copy() that does not defer to memmove().
15*67e74705SXin Li   virtual int f();
16*67e74705SXin Li };
17*67e74705SXin Li 
testCopyNull(C * I,C * E)18*67e74705SXin Li void testCopyNull(C *I, C *E) {
19*67e74705SXin Li   std::copy(I, E, (C *)0);
20*67e74705SXin Li #ifndef SUPPRESSED
21*67e74705SXin Li   // expected-warning@../Inputs/system-header-simulator-cxx.h:166 {{Called C++ object pointer is null}}
22*67e74705SXin Li #endif
23*67e74705SXin Li }
24