Files
TheRock/compiler/amd-llvm/clang/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

172 lines
4.2 KiB
C++

// This is a fake system header with divide-by-zero bugs introduced in
// c++ std library functions. We use these bugs to test hard-coded
// suppression of diagnostics within standard library functions that are known
// to produce false positives.
#pragma clang system_header
typedef unsigned char uint8_t;
typedef __typeof__(sizeof(int)) size_t;
void *memmove(void *s1, const void *s2, size_t n);
#define TRIGGER_DIV_BY_ZERO \
do { \
int z = 0; \
z = 5/z; \
} while (0)
namespace std {
template <class _Tp>
class allocator {
public:
void deallocate(void *p) {
::delete p;
}
};
template <class _Alloc>
class allocator_traits {
public:
static void deallocate(void *p) {
_Alloc().deallocate(p);
}
};
template <class _Tp, class _Alloc>
class __list_imp
{};
template <class _Tp, class _Alloc = allocator<_Tp> >
class list
: private __list_imp<_Tp, _Alloc>
{
public:
void pop_front() {
// Fake use-after-free.
// No warning is expected as we are suppressing warning coming
// out of std::list.
TRIGGER_DIV_BY_ZERO;
}
bool empty() const;
};
// basic_string
template<class _CharT, class _Alloc = allocator<_CharT> >
class __attribute__ ((__type_visibility__("default"))) basic_string {
bool isLong;
union {
_CharT localStorage[4];
_CharT *externalStorage;
void assignExternal(_CharT *newExternal) {
externalStorage = newExternal;
}
} storage;
typedef allocator_traits<_Alloc> __alloc_traits;
public:
basic_string();
void push_back(int c) {
// Fake error trigger.
// No warning is expected as we are suppressing warning coming
// out of std::basic_string.
TRIGGER_DIV_BY_ZERO;
}
_CharT *getBuffer() {
return isLong ? storage.externalStorage : storage.localStorage;
}
basic_string &operator +=(int c) {
// Fake deallocate stack-based storage.
// No warning is expected as we are suppressing warnings within
// std::basic_string.
__alloc_traits::deallocate(getBuffer());
}
basic_string &operator =(const basic_string &other) {
// Fake deallocate stack-based storage, then use the variable in the
// same union.
// No warning is expected as we are suppressing warnings within
// std::basic_string.
__alloc_traits::deallocate(getBuffer());
storage.assignExternal(new _CharT[4]);
}
};
template<class _Engine, class _UIntType>
class __independent_bits_engine {
public:
// constructors and seeding functions
__independent_bits_engine(_Engine& __e, size_t __w);
};
template<class _Engine, class _UIntType>
__independent_bits_engine<_Engine, _UIntType>
::__independent_bits_engine(_Engine& __e, size_t __w)
{
// Fake error trigger.
// No warning is expected as we are suppressing warning coming
// out of std::__independent_bits_engine.
TRIGGER_DIV_BY_ZERO;
}
#if __has_feature(cxx_decltype)
typedef decltype(nullptr) nullptr_t;
template<class _Tp>
class shared_ptr
{
public:
constexpr shared_ptr(nullptr_t);
explicit shared_ptr(_Tp* __p);
shared_ptr(shared_ptr&& __r) { }
~shared_ptr();
shared_ptr& operator=(shared_ptr&& __r) {
// Fake error trigger.
// No warning is expected as we are suppressing warning coming
// out of std::shared_ptr.
TRIGGER_DIV_BY_ZERO;
}
};
template<class _Tp>
inline
constexpr
shared_ptr<_Tp>::shared_ptr(nullptr_t) {
}
#endif // __has_feature(cxx_decltype)
template<typename _RandomAccessIterator>
void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
// Fake error trigger
// std::sort is expected to be evaluated conservatively.
TRIGGER_DIV_BY_ZERO;
}
template<typename _RandomAccessIterator>
void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
// Fake error trigger
// std::stable_sort is expected to be evaluated conservatively.
TRIGGER_DIV_BY_ZERO;
}
template<typename _BidirectionalIterator>
void inplace_merge(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last) {
// Fake error trigger
// std::inplace_merge is expected to be evaluated conservatively.
TRIGGER_DIV_BY_ZERO;
}
} // namespace std