llvm-project/clang/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
Kristof Umann a3f7b58742 [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing
Even for a checker being in alpha, some reports about pointees held so little
value to the user that it's safer to disable pointer/reference chasing for now.
It can be enabled with a new flag, in which case checker should function as it
has always been. This can be set with `CheckPointeeInitialization`.

Differential Revision: https://reviews.llvm.org/D49438

llvm-svn: 339135
2018-08-07 12:55:26 +00:00

28 lines
635 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
// RUN: -std=c++11 -DPEDANTIC -verify %s
class UninitPointerTest {
int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
int dontGetFilteredByNonPedanticMode = 0;
public:
UninitPointerTest() {} // expected-warning{{1 uninitialized field}}
};
void fUninitPointerTest() {
UninitPointerTest();
}
class UninitPointeeTest {
int *ptr; // no-note
int dontGetFilteredByNonPedanticMode = 0;
public:
UninitPointeeTest(int *ptr) : ptr(ptr) {} // no-warning
};
void fUninitPointeeTest() {
int a;
UninitPointeeTest t(&a);
}