Summary: SIOF is only for interactions between objects of non-POD types. Previously the checker was also reporting for POD types. Reviewed By: akotulski Differential Revision: D4197620 fbshipit-source-id: 7c56571master
parent
05c72f510a
commit
17179d4275
@ -1 +1 @@
|
||||
Subproject commit 248d630ea8a64a01ca56ccb87f97acd707610660
|
||||
Subproject commit 18904710494629ff27a5350d715f3a2a228970b6
|
@ -1,4 +1,10 @@
|
||||
siof/const_use.cpp, __infer_globals_initializer_use_u, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of use_u,access to u]
|
||||
siof/pod_across_translation_units-1.cpp, __infer_globals_initializer_x, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of x,call to baz,call to bar,call to foo,access to y]
|
||||
siof/siof_across_translation_units-1.cpp, __infer_globals_initializer_another_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object,access to another_global_object]
|
||||
siof/siof_across_translation_units-1.cpp, __infer_globals_initializer_another_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object,call to SomeOtherObject_SomeOtherObject,access to global_object]
|
||||
siof/siof.cpp, __infer_globals_initializer_X::static_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of X::static_pod_accesses_non_pod,call to access_to_non_pod,access to global_object2]
|
||||
siof/siof.cpp, __infer_globals_initializer_another_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object,call to SomeOtherNonPODObject_SomeOtherNonPODObject,access to extern_global_object]
|
||||
siof/siof.cpp, __infer_globals_initializer_another_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object2,call to access_to_non_pod,access to global_object2]
|
||||
siof/siof.cpp, __infer_globals_initializer_another_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object3,call to access_to_templated_non_pod,access to global_object3]
|
||||
siof/siof.cpp, __infer_globals_initializer_initWithGlobal, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithGlobal,call to getGlobalNonPOD,access to global_object2]
|
||||
siof/siof.cpp, __infer_globals_initializer_initWithStatic, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithStatic,call to getFunctionStaticNonPOD,access to getFunctionStaticNonPOD_instance]
|
||||
siof/siof.cpp, __infer_globals_initializer_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of pod_accesses_non_pod,call to access_to_non_pod,access to global_object2]
|
||||
siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object,call to SomeOtherTemplatedNonPODObject<_Bool>_SomeOtherTemplatedNonPODObject,access to extern_global_object]
|
||||
siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object2,call to access_to_non_pod,access to global_object2]
|
||||
siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object3,call to access_to_templated_non_pod,access to global_object3]
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 "siof_types.h"
|
||||
|
||||
extern SomeNonPODObject extern_global_object;
|
||||
SomeNonPODObject global_object;
|
||||
|
||||
extern int access_to_non_pod();
|
||||
|
||||
struct SomeOtherNonPODObject {
|
||||
SomeOtherNonPODObject() {
|
||||
global_object.some_method(); // OK, same translation unit
|
||||
extern_global_object.some_method(); // bad, different translation unit
|
||||
};
|
||||
|
||||
SomeOtherNonPODObject(int i) {
|
||||
global_object.some_method(); // OK, same translation unit
|
||||
};
|
||||
};
|
||||
|
||||
SomeOtherNonPODObject another_global_object; // SIOF!
|
||||
SomeOtherNonPODObject another_global_object2(access_to_non_pod()); // SIOF!
|
||||
SomeOtherNonPODObject another_global_object3(
|
||||
access_to_templated_non_pod()); // SIOF!
|
||||
SomeOtherNonPODObject another_global_object4(42); // OK
|
||||
|
||||
int pod_accesses_non_pod = access_to_non_pod(); // SIOF!
|
||||
|
||||
struct X {
|
||||
static int static_pod_accesses_non_pod;
|
||||
};
|
||||
|
||||
int X::static_pod_accesses_non_pod = access_to_non_pod(); // SIOF!
|
||||
|
||||
SomeNonPODObject initWithStatic = getFunctionStaticNonPOD(); // OK
|
||||
SomeNonPODObject initWithGlobal = getGlobalNonPOD(); // SIOF!
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This file exists only so that the SIOF checkers sees global_object
|
||||
// being initialized via a method call. The SIOF checker could be
|
||||
// improved to know that all non-POD types require initialization in
|
||||
// C++.
|
||||
|
||||
struct SomeObject {
|
||||
void some_method();
|
||||
};
|
||||
|
||||
SomeObject global_object;
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 "siof_types.h"
|
||||
|
||||
SomeNonPODObject global_object2;
|
||||
|
||||
int access_to_non_pod() {
|
||||
global_object2.some_method();
|
||||
return 5;
|
||||
}
|
||||
|
||||
SomeTemplatedNonPODObject<int> global_object3;
|
||||
|
||||
int access_to_templated_non_pod() { return global_object3.some_method(); }
|
||||
|
||||
SomeNonPODObject& getFunctionStaticNonPOD() {
|
||||
static SomeNonPODObject instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
SomeNonPODObject& getGlobalNonPOD() { return global_object2; }
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 "siof_types.h"
|
||||
|
||||
extern SomeTemplatedNonPODObject<int> extern_global_object;
|
||||
|
||||
SomeTemplatedNonPODObject<int> global_object;
|
||||
|
||||
template <typename T>
|
||||
struct SomeOtherTemplatedNonPODObject {
|
||||
SomeOtherTemplatedNonPODObject() {
|
||||
global_object.some_method(); // OK, same translation unit
|
||||
extern_global_object.some_method(); // bad, different translation unit
|
||||
};
|
||||
|
||||
SomeOtherTemplatedNonPODObject(int i) {
|
||||
global_object.some_method(); // OK, same translation unit
|
||||
};
|
||||
};
|
||||
|
||||
SomeOtherTemplatedNonPODObject<bool> another_templated_global_object; // SIOF!
|
||||
SomeOtherTemplatedNonPODObject<bool> another_templated_global_object2(
|
||||
access_to_non_pod()); // SIOF!
|
||||
SomeOtherTemplatedNonPODObject<bool> another_templated_global_object3(
|
||||
access_to_templated_non_pod()); // SIOF!
|
||||
SomeOtherTemplatedNonPODObject<bool> another_templated_global_object4(42); // OK
|
Loading…
Reference in new issue