Files
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

71 lines
2.7 KiB
C

// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.core.FixedAddressDereference -analyzer-output=text -verify %s
extern char *something();
void test1() {
int *p;
p = (int *)22; // expected-note{{Pointer value of (int *)22 stored to 'p'}}
*p = 2; // expected-warning{{Dereference of a fixed address (loaded from variable 'p')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'p')}}
}
void test2_1(int *p) {
*p = 1; // expected-warning{{Dereference of a fixed address (loaded from variable 'p')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'p')}}
}
void test2() {
int *p = (int *)11; // expected-note{{'p' initialized to (int *)11}}
test2_1(p); // expected-note{{Passing pointer value (int *)11 via 1st parameter 'p'}} \
// expected-note{{Calling 'test2_1'}}
}
struct test3_s {
int a;
};
void test3() {
struct test3_s *x;
unsigned long long val = 1111111; // expected-note{{'val' initialized to 1111111}}
x = (struct test3_s *)val; // expected-note{{Pointer value of (struct test3_s *)1111111 stored to 'x'}}
x->a = 3; // expected-warning{{Access to field 'a' results in a dereference of a fixed address (loaded from variable 'x')}} \
// expected-note{{Access to field 'a' results in a dereference of a fixed address (loaded from variable 'x')}}
}
char *test4_1() {
char *ret;
ret = something(); // expected-note{{Value assigned to 'ret'}}
if (ret == (char *)-1) // expected-note{{Assuming the condition is true}} \
// expected-note{{Taking true branch}}
return ret; // expected-note{{Returning pointer (loaded from 'ret')}}
return 0;
}
void test4() {
char *x;
x = test4_1(); // expected-note{{Calling 'test4_1'}} \
// expected-note{{Returning from 'test4_1'}} \
// expected-note{{Pointer value of (char *)-1 stored to 'x'}}
*x = 3; // expected-warning{{Dereference of a fixed address (loaded from variable 'x')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'x')}}
}
void suppress_volatile_pointee(void) {
*(volatile int *)0x00011100 = 4; // no-warning: volatile pointees are suppressed
}
void suppress_volatile_pointee_using_subscript(void) {
((volatile int *)0x00011100)[0] = 4; // no-warning: volatile pointees are suppressed
}
void suppress_ptr_to_100element_volatile_array(void) {
((volatile int (*)[100])0x00011100)[2][0] = 4; // no-warning: volatile pointees are suppressed
}
void deref_volatile_nullptr(void) {
*(volatile int *)0 = 1; // core.NullDereference still warns about this
// expected-warning@-1 {{Dereference of null pointer [core.NullDereference]}}
// expected-note@-2 {{Dereference of null pointer}}
}