=?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com>, =?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com>, =?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/127...@github.com>
================ @@ -0,0 +1,77 @@ +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-all-address-spaces=false -verify=x86-nosuppress %s +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=x86-suppress %s +// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-all-address-spaces=false -verify=other-nosuppress %s +// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=other-suppress %s + +#define AS_ATTRIBUTE(_X) volatile __attribute__((address_space(_X))) + +#define _get_base() ((void * AS_ATTRIBUTE(256) *)0) + +void* test_address_space_array(unsigned long slot) { + return _get_base()[slot]; // other-nosuppress-warning{{Dereference}} +} + +void test_address_space_condition(int AS_ATTRIBUTE(257) *cpu_data) { + if (cpu_data == 0) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} + } +} + +struct X { int member; }; +int test_address_space_member(void) { + struct X AS_ATTRIBUTE(258) *data = (struct X AS_ATTRIBUTE(258) *)0UL; + int ret; + ret = data->member; // other-nosuppress-warning{{Dereference}} + return ret; +} + +void test_other_address_space_condition(int AS_ATTRIBUTE(259) *cpu_data) { + if (cpu_data == 0) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} \ + // x86-nosuppress-warning{{Dereference}} + } +} + +void test_no_address_space_condition(int *cpu_data) { + if (cpu_data == 0) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} \ + // x86-nosuppress-warning{{Dereference}} \ + // other-suppress-warning{{Dereference}} \ + // x86-suppress-warning{{Dereference}} + } +} + +#define _fixed_get_base() ((void * AS_ATTRIBUTE(256) *)2) + +void* fixed_test_address_space_array(unsigned long slot) { + return _fixed_get_base()[slot]; // other-nosuppress-warning{{Dereference}} +} + +void fixed_test_address_space_condition(int AS_ATTRIBUTE(257) *cpu_data) { + if (cpu_data == (int AS_ATTRIBUTE(257) *)2) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} + } +} + +int fixed_test_address_space_member(void) { + struct X AS_ATTRIBUTE(258) *data = (struct X AS_ATTRIBUTE(258) *)2UL; + int ret; + ret = data->member; // other-nosuppress-warning{{Dereference}} + return ret; +} + +void fixed_test_other_address_space_condition(int AS_ATTRIBUTE(259) *cpu_data) { + if (cpu_data == (int AS_ATTRIBUTE(259) *)2) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} \ + // x86-nosuppress-warning{{Dereference}} + } +} + +void fixed_test_no_address_space_condition(int *cpu_data) { + if (cpu_data == (int *)2) { + *cpu_data = 3; // other-nosuppress-warning{{Dereference}} \ + // x86-nosuppress-warning{{Dereference}} \ + // other-suppress-warning{{Dereference}} \ + // x86-suppress-warning{{Dereference}} +} ---------------- steakhal wrote: ```suggestion } ``` https://github.com/llvm/llvm-project/pull/127191 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits