Summary: In Objective-C, `static const int var = ..` is not recognized as ICE (integral constant expression) unlike C++. To handle such loads better, this diff adds a check for `constant_global_array` as a workaround. Reviewed By: skcho Differential Revision: D26369461 fbshipit-source-id: e2dae11f1master
parent
745f04f77d
commit
7af9d02542
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
static const int ConstantGlobal[] = {8};
|
||||
|
||||
void access_constant_global_Bad() {
|
||||
int a[5];
|
||||
a[ConstantGlobal[0]] = 3;
|
||||
}
|
||||
|
||||
int access_constant_global_via_assignment_Bad() {
|
||||
int a[5];
|
||||
const int* arr = ConstantGlobal;
|
||||
return a[arr[0]];
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
codetoanalyze/objc/bufferoverrun/block.m, Block.block_in_field_Bad, 7, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Offset trace>,Call,Assignment,<Length trace>,Array declaration,Array access: Offset: 15 Size: 10]
|
||||
codetoanalyze/objc/bufferoverrun/global.m, access_constant_global_Bad, 2, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Offset trace>,Assignment,<Length trace>,Array declaration,Array access: Offset: 8 Size: 5]
|
||||
codetoanalyze/objc/bufferoverrun/global.m, access_constant_global_via_assignment_Bad, 3, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Offset trace>,Assignment,<Length trace>,Array declaration,Array access: Offset: 8 Size: 5]
|
||||
codetoanalyze/objc/bufferoverrun/return_struct.m, ReturnStruct.call_get_struct_Bad, 3, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Offset trace>,Call,Parameter `n`,Assignment,Assignment,<Length trace>,Array declaration,Array access: Offset: 5 Size: 3]
|
||||
|
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
static const int ConstantGlobal[] = {10};
|
||||
|
||||
void access_constant_constant() {
|
||||
for (int i = 0; i <= ConstantGlobal[0]; i++) {
|
||||
}
|
||||
}
|
Loading…
Reference in new issue