Reviewed By: jberdine Differential Revision: D5182255 fbshipit-source-id: f954337master
parent
d1ef5ae27f
commit
093a00af9b
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace basics {
|
||||||
|
|
||||||
|
class BasicsNoMutex {
|
||||||
|
public:
|
||||||
|
BasicsNoMutex() {}
|
||||||
|
|
||||||
|
void set(int new_value) {
|
||||||
|
field_1 = new_value;
|
||||||
|
field_2 = new_value;
|
||||||
|
field_3 = new_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get1() { return field_1; }
|
||||||
|
|
||||||
|
int get2() { return field_2; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int field_1;
|
||||||
|
int field_2;
|
||||||
|
int field_3;
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 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 <mutex>
|
||||||
|
|
||||||
|
namespace basics {
|
||||||
|
|
||||||
|
class BasicsWithHeader {
|
||||||
|
public:
|
||||||
|
BasicsWithHeader(){};
|
||||||
|
|
||||||
|
void set(int new_value) {
|
||||||
|
field_1 = new_value;
|
||||||
|
field_2 = new_value;
|
||||||
|
field_3 = new_value;
|
||||||
|
};
|
||||||
|
int get1() { return field_1; };
|
||||||
|
int get2() { return field_2; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
int field_1;
|
||||||
|
int field_2;
|
||||||
|
int field_3;
|
||||||
|
std::mutex mutex_;
|
||||||
|
};
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get2, 3, THREAD_SAFETY_VIOLATION, [access to `suspiciously_written`]
|
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get2, 3, THREAD_SAFETY_VIOLATION, [access to `suspiciously_written`]
|
||||||
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get3, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `not_guarded`,<Beginning of write trace>,access to `not_guarded`]
|
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get3, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `not_guarded`,<Beginning of write trace>,access to `not_guarded`]
|
||||||
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get4, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `suspiciously_read`,<Beginning of write trace>,access to `suspiciously_read`]
|
codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get4, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `suspiciously_read`,<Beginning of write trace>,access to `suspiciously_read`]
|
||||||
|
codetoanalyze/cpp/threadsafety/basics_with_mutex.cpp, basics::BasicsWithHeader_get1, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `field_1`,<Beginning of write trace>,access to `field_1`]
|
||||||
|
codetoanalyze/cpp/threadsafety/basics_with_mutex.cpp, basics::BasicsWithHeader_get2, 0, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `field_2`,<Beginning of write trace>,access to `field_2`]
|
||||||
|
Loading…
Reference in new issue