diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-14 23:17:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-14 23:17:22 +0000 |
commit | 0c106995d52738c4cc0e25edffd6ae2ffaea817d (patch) | |
tree | 387b2d545535985f7d3682bd6314c5846fa3d8d1 | |
parent | a1cf15f4680e5cf39e72e28c5ea854fcba792e84 (diff) |
Split out 'test2' into an i386 and x86_64 file, illustrating how the
test behavior differs between architectures. When this is no longer
the case, these tests will be merged.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75708 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Analysis/misc-ps-region-store-i386.m | 29 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store-x86_64.m | 31 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store.m | 29 |
3 files changed, 66 insertions, 23 deletions
diff --git a/test/Analysis/misc-ps-region-store-i386.m b/test/Analysis/misc-ps-region-store-i386.m new file mode 100644 index 0000000000..f501dbe7ad --- /dev/null +++ b/test/Analysis/misc-ps-region-store-i386.m @@ -0,0 +1,29 @@ +// RUN: clang-cc -triple i386-apple-darwin9 -analyze -checker-cfref --analyzer-store=region --verify -fblocks %s + +typedef struct _BStruct { void *grue; } BStruct; +void testB_aux(void *ptr); +void testB(BStruct *b) { + { + int *__gruep__ = ((int *)&((b)->grue)); + int __gruev__ = *__gruep__; + int __gruev2__ = *__gruep__; + if (__gruev__ != __gruev2__) { + int *p = 0; + *p = 0xDEADBEEF; + } + + testB_aux(__gruep__); + } + { + int *__gruep__ = ((int *)&((b)->grue)); + int __gruev__ = *__gruep__; + int __gruev2__ = *__gruep__; + if (__gruev__ != __gruev2__) { + int *p = 0; + *p = 0xDEADBEEF; + } + + if (~0 != __gruev__) {} + } +} + diff --git a/test/Analysis/misc-ps-region-store-x86_64.m b/test/Analysis/misc-ps-region-store-x86_64.m new file mode 100644 index 0000000000..2f74904d9c --- /dev/null +++ b/test/Analysis/misc-ps-region-store-x86_64.m @@ -0,0 +1,31 @@ +// RUN: clang-cc -triple x86_64-apple-darwin9 -analyze -checker-cfref --analyzer-store=region --verify -fblocks %s + +// This test case appears in misc-ps-region-store-i386.m, but fails under x86_64. +// The reason is that 'int' is smaller than a pointer on a 64-bit architecture, +// and we aren't reasoning yet about just the first 32-bits of the pointer. +typedef struct _BStruct { void *grue; } BStruct; +void testB_aux(void *ptr); +void testB(BStruct *b) { + { + int *__gruep__ = ((int *)&((b)->grue)); + int __gruev__ = *__gruep__; + int __gruev2__ = *__gruep__; + if (__gruev__ != __gruev2__) { + int *p = 0; + *p = 0xDEADBEEF; // no-warning + } + + testB_aux(__gruep__); + } + { + int *__gruep__ = ((int *)&((b)->grue)); + int __gruev__ = *__gruep__; + int __gruev2__ = *__gruep__; + if (__gruev__ != __gruev2__) { + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{null}} + } + + if (~0 != __gruev__) {} + } +} diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index de8aec1abd..245273b220 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -1,4 +1,5 @@ -// RUN: clang-cc -triple i386-apple-darwin9 -analyze -checker-cfref --analyzer-store=region --verify -fblocks %s +// RUN: clang-cc -triple i386-apple-darwin9 -analyze -checker-cfref --analyzer-store=region --verify -fblocks %s && +// RUN: clang-cc -triple x86_64-apple-darwin9 -analyze -checker-cfref --analyzer-store=region --verify -fblocks %s typedef struct objc_selector *SEL; typedef signed char BOOL; @@ -86,29 +87,11 @@ void test_trivial_symbolic_comparison_pointer_parameter(int *x) { // of fields. typedef struct _BStruct { void *grue; } BStruct; void testB_aux(void *ptr); + void testB(BStruct *b) { - { - int *__gruep__ = ((int *)&((b)->grue)); - int __gruev__ = *__gruep__; - int __gruev2__ = *__gruep__; - if (__gruev__ != __gruev2__) { - int *p = 0; - *p = 0xDEADBEEF; - } - - testB_aux(__gruep__); - } - { - int *__gruep__ = ((int *)&((b)->grue)); - int __gruev__ = *__gruep__; - int __gruev2__ = *__gruep__; - if (__gruev__ != __gruev2__) { - int *p = 0; - *p = 0xDEADBEEF; - } - - if (~0 != __gruev__) {} - } + // This case has moved to 'misc-ps-region-store-i386.m' and + // 'misc-ps-region-store-x86_64.m'. It succeeds under x86_64. When it + // passes it both, pull it in here. } void testB_2(BStruct *b) { |