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
48 lines
2.6 KiB
C
48 lines
2.6 KiB
C
// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -verify -triple x86_64-apple-darwin9 %s
|
|
|
|
typedef signed long CFIndex;
|
|
typedef const struct __CFAllocator * CFAllocatorRef;
|
|
enum { kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2,
|
|
kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4,
|
|
kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6,
|
|
kCFNumberCharType = 7, kCFNumberShortType = 8,
|
|
kCFNumberIntType = 9, kCFNumberLongType = 10,
|
|
kCFNumberLongLongType = 11, kCFNumberFloatType = 12,
|
|
kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14,
|
|
kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16,
|
|
kCFNumberMaxType = 16 };
|
|
typedef CFIndex CFNumberType;
|
|
typedef const struct __CFNumber * CFNumberRef;
|
|
typedef unsigned char Boolean;
|
|
extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
|
|
Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr);
|
|
|
|
__attribute__((cf_returns_retained)) CFNumberRef f1(unsigned char x) {
|
|
return CFNumberCreate(0, kCFNumberSInt16Type, &x); // expected-warning{{An 8-bit integer is used to initialize a CFNumber object that represents a 16-bit integer; 8 bits of the CFNumber value will be garbage}}
|
|
}
|
|
|
|
__attribute__((cf_returns_retained)) CFNumberRef f2(unsigned short x) {
|
|
return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{A 16-bit integer is used to initialize a CFNumber object that represents an 8-bit integer; 8 bits of the integer value will be lost}}
|
|
}
|
|
|
|
// test that the attribute overrides the naming convention.
|
|
__attribute__((cf_returns_not_retained)) CFNumberRef CreateNum(unsigned char x) {
|
|
return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{leak}}
|
|
}
|
|
|
|
__attribute__((cf_returns_retained)) CFNumberRef f3(unsigned i) {
|
|
return CFNumberCreate(0, kCFNumberLongType, &i); // expected-warning{{A 32-bit integer is used to initialize a CFNumber object that represents a 64-bit integer}}
|
|
}
|
|
|
|
unsigned char getValueTest1(CFNumberRef x) {
|
|
unsigned char scalar = 0;
|
|
CFNumberGetValue(x, kCFNumberSInt16Type, &scalar); // expected-warning{{A CFNumber object that represents a 16-bit integer is used to initialize an 8-bit integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
|
|
return scalar;
|
|
}
|
|
|
|
unsigned char getValueTest2(CFNumberRef x) {
|
|
unsigned short scalar = 0;
|
|
CFNumberGetValue(x, kCFNumberSInt8Type, &scalar); // expected-warning{{A CFNumber object that represents an 8-bit integer is used to initialize a 16-bit integer; 8 bits of the integer value will be garbage}}
|
|
return scalar;
|
|
}
|