Files
TheRock/compiler/amd-llvm/clang/test/Analysis/inlining/inline-defensive-checks.cpp
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

104 lines
1.8 KiB
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
// expected-no-diagnostics
extern void __assert_fail (__const char *__assertion, __const char *__file,
unsigned int __line, __const char *__function)
__attribute__ ((__noreturn__));
#define assert(expr) \
((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
class ButterFly {
private:
ButterFly() { }
public:
int triggerderef() {
return 0;
}
};
ButterFly *getInP();
class X{
ButterFly *p;
void setP(ButterFly *inP) {
if(inP)
;
p = inP;
};
void subtest1() {
ButterFly *inP = getInP();
setP(inP);
}
int subtest2() {
int c = p->triggerderef(); // no-warning
return c;
}
int test() {
subtest1();
return subtest2();
}
};
typedef const int *Ty;
extern
Ty notNullArg(Ty cf) __attribute__((nonnull));
typedef const void *CFTypeRef;
extern Ty getTyVal();
inline void radar13224271_callee(Ty def, Ty& result ) {
result = def;
// Clearly indicates that result cannot be 0 if def is not NULL.
assert( (result != 0) || (def == 0) );
}
void radar13224271_caller()
{
Ty value;
radar13224271_callee(getTyVal(), value );
notNullArg(value); // no-warning
}
struct Foo {
int *ptr;
Foo(int *p) {
*p = 1; // no-warning
}
};
void idc(int *p3) {
if (p3)
;
}
int *retNull() {
return 0;
}
void test(int *p1, int *p2) {
idc(p1);
Foo f(p1);
}
struct Bar {
int x;
};
void idcBar(Bar *b) {
if (b)
;
}
void testRefToField(Bar *b) {
idcBar(b);
int &x = b->x; // no-warning
x = 5;
}
namespace get_deref_expr_with_cleanups {
struct S {
~S();
};
S *conjure();
// The argument won't be used, but it'll cause cleanups
// to appear around the call site.
S *get_conjured(S _) {
S *s = conjure();
if (s) {}
return s;
}
void test_conjured() {
S &s = *get_conjured(S()); // no-warning
}
} // namespace get_deref_expr_with_cleanups