llvm-project/clang/test/Analysis/diagnostics/explicit-suppression.cpp
Balazs Benics 566363981b
[analyzer] Model builtin-like functions as builtin functions (#99886)
Some template function instantiations don't have a body, even though
their templates did have a body.
Examples are: `std::move`, `std::forward`, `std::addressof` etc.

They had bodies before
72315d02c4

After that change, the sentiment was that these special functions should
be considered and treated as builtin functions.

Fixes #94193

CPP-5358
2024-07-23 08:39:11 +02:00

25 lines
879 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=false -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=true -DSUPPRESSED=1 -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DSUPPRESSED=1 -verify %s
#ifdef SUPPRESSED
// expected-no-diagnostics
#endif
#include "../Inputs/system-header-simulator-cxx.h"
void clang_analyzer_eval(bool);
class C {
// The virtual function is to make C not trivially copy assignable so that we call the
// variant of std::copy() that does not defer to memmove().
virtual int f();
};
void testCopyNull(C *I, C *E) {
std::copy(I, E, (C *)0);
#ifndef SUPPRESSED
// expected-warning@#system_header_simulator_cxx_std_copy_impl_loop {{Called C++ object pointer is null}}
#endif
}