diff options
author | Kristof Umann <kristof.umann@ericsson.com> | 2019-04-25 20:00:51 +0000 |
---|---|---|
committer | Kristof Umann <kristof.umann@ericsson.com> | 2019-04-25 20:00:51 +0000 |
commit | d8f5c573f20c284225f502ccb3031839474a74f3 (patch) | |
tree | 1c08c5e4d76611e4d86c20ce2a0944d17c897047 /test/Analysis/cxx-uninitialized-object.cpp | |
parent | 1bddf67ac3fa445c068051b617cfc045d1d024ab (diff) |
[analyzer][UninitializedObjectChecker] PR41590: Regard _Atomic types as primitive
https://bugs.llvm.org/show_bug.cgi?id=41590
For the following code snippet, UninitializedObjectChecker crashed:
struct MyAtomicInt {
_Atomic(int) x;
MyAtomicInt() {}
};
void entry() {
MyAtomicInt b;
}
The problem was that _Atomic types were not regular records, unions,
dereferencable or primitive, making the checker hit the llvm_unreachable at
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:347.
The solution is to regard these types as primitive as well. The test case shows
that with this addition, not only are we able to get rid of the crash, but we
can identify x as uninitialized.
Differential Revision: https://reviews.llvm.org/D61106
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/cxx-uninitialized-object.cpp')
-rw-r--r-- | test/Analysis/cxx-uninitialized-object.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Analysis/cxx-uninitialized-object.cpp b/test/Analysis/cxx-uninitialized-object.cpp index bcd3d85d0f..86f2ecdd83 100644 --- a/test/Analysis/cxx-uninitialized-object.cpp +++ b/test/Analysis/cxx-uninitialized-object.cpp @@ -1130,3 +1130,18 @@ void fCXX11MemberInitTest2() { // TODO: we'd expect the warning: {{2 uninitializeds field}} CXX11MemberInitTest2(); // no-warning } + +//===----------------------------------------------------------------------===// +// _Atomic tests. +//===----------------------------------------------------------------------===// + +struct MyAtomicInt { + _Atomic(int) x; // expected-note{{uninitialized field 'this->x'}} + int dontGetFilteredByNonPedanticMode = 0; + + MyAtomicInt() {} // expected-warning{{1 uninitialized field}} +}; + +void entry() { + MyAtomicInt b; +} |