[backend] Fix issue where the attribute of a procedure definition could be overwritten with the attribute of a declaration

Reviewed By: sblackshear

Differential Revision: D3856374

fbshipit-source-id: a8a0a52
master
Cristiano Calcagno 8 years ago committed by Facebook Github Bot 5
parent 8589dc4868
commit ec67521c6f

@ -53,6 +53,7 @@ let store_attributes (proc_attributes: ProcAttributes.t) => {
| None => true
| Some proc_attributes_on_disk =>
let higher_rank_than_on_disk () =>
proc_attributes.is_defined &&
DB.source_file_compare proc_attributes.loc.file proc_attributes_on_disk.loc.file > 0;
let becomes_defined = proc_attributes.is_defined && not proc_attributes_on_disk.is_defined;
/* Only overwrite the attribute file if the procedure becomes defined

@ -25,6 +25,7 @@ FILES = \
nestedoperators/*.cpp \
npe/*.cpp \
numeric/*.cpp \
overwrite_attribute/*.cpp \
reference/*.cpp \
resource_leaks/*.cpp \
smart_ptr/*.cpp \

@ -116,6 +116,7 @@ numeric/min_max.cpp, max_X_inv_div0, 2, DIVIDE_BY_ZERO
numeric/min_max.cpp, max_int_div0, 0, DIVIDE_BY_ZERO
numeric/min_max.cpp, min_X_div0, 2, DIVIDE_BY_ZERO
numeric/min_max.cpp, min_int_div0, 0, DIVIDE_BY_ZERO
overwrite_attribute/main.cpp, testSetIntValue, 3, DIVIDE_BY_ZERO
reference/reference_field.cpp, reference_field::ptr_F_div0, 5, DIVIDE_BY_ZERO
reference/reference_field.cpp, reference_field::ptr_I_div0, 5, DIVIDE_BY_ZERO
reference/reference_field.cpp, reference_field::ptr_getF_div0, 5, DIVIDE_BY_ZERO

@ -0,0 +1,12 @@
/*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include "lib.h"
void setIntValue(int* x, int val) { *x = val; }

@ -0,0 +1,10 @@
/*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
void setIntValue(int* x, int val);

@ -0,0 +1,16 @@
/*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include "lib.h"
int testSetIntValue() {
int x;
setIntValue(&x, 0);
return 1 / x; // div0
}
Loading…
Cancel
Save