Commit Graph

12 Commits

Author SHA1 Message Date
Kristof Umann f44d2b4e13 [analyzer] Attempt to make a windows buildbot happy.
Got an error that a cast is happening from a pointer type to long, which is
smaller.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342223 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 11:20:16 +00:00
Kristof Umann 4e5e136e7e [analyzer][UninitializedObjectChecker] Support for nonloc::LocAsInteger
Differential Revision: https://reviews.llvm.org/D49437


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342221 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 10:18:26 +00:00
Kristof Umann 6667b4e8eb [analyzer][UninitializedObjectChecker] Fixed dereferencing
iThis patch aims to fix derefencing, which has been debated for months now.

Instead of working with SVals, the function now relies on TypedValueRegion.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342213 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 08:58:21 +00:00
Kristof Umann 01b8a31de3 [analyzer][UninitializedObjectChecker] Refactoring p6.: Move dereferencing to a function
Now that it has it's own file, it makes little sense for
isPointerOrReferenceUninit to be this large, so I moved
dereferencing to a separate function.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340265 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:45:21 +00:00
Kristof Umann 0da238081a [analyzer][UninitializedObjectChecker] Void pointers are casted back to their dynamic type in note message
Differential Revision: https://reviews.llvm.org/D49228


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339653 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 08:20:51 +00:00
Kristof Umann 1cdeaa85d9 [analyzer][UninitializedObjectChecker] Pointer/reference objects are dereferenced according to dynamic type
This patch fixed an issue where the dynamic type of pointer/reference
object was known by the analyzer, but wasn't obtained in the checker,
which resulted in false negatives. This should also increase reliability
of the checker, as derefencing is always done now according to the
dynamic type (even if that happens to be the same as the static type).

Special thanks to Artem Degrachev for setting me on the right track.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339240 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-08 13:18:53 +00:00
Kristof Umann 3fb90d137e [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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339135 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 12:55:26 +00:00
Richard Smith 05ff991ac2 Fold dangling-field warning into general initialization lifetime checks.
This reinstates r337627, reverted in r337671, with a fix to correctly
handle the lvalueness of array subscript expressions on pointers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337726 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 18:50:26 +00:00
Ilya Biryukov 547ca57a7d Revert "Fold dangling-field warning into general initialization lifetime checks."
This reverts commit r337627.
After the change, clang started producing invalid warning on the following code:
    struct foo {
      foo(char *x) : x_(&x[10]) {}
    private:
      char *x_;
    };

1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337671 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 06:32:36 +00:00
Richard Smith d788672fbe Fold dangling-field warning into general initialization lifetime checks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337627 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 22:25:55 +00:00
Kristof Umann ad8d9be58e [analyzer][UninitializedObjectChecker] Support for MemberPointerTypes
Differential Revision: https://reviews.llvm.org/D48325


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336994 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-13 12:21:38 +00:00
Kristof Umann 6402a97d5b [analyzer] Checker for uninitialized C++ objects
This checker analyzes C++ constructor calls, and reports uninitialized fields.

Due to the nature of this problem (uninitialized fields after an object
construction), this checker doesn't search for bugs, but rather is a tool to
enforce a specific programming model where every field needs to be initialized.

This checker lands in alpha for now, and a number of followup patches will be
made to reduce false negatives and to make it easier for the user to understand
what rules the checker relies on, eg. whether a derived class' constructor is
responsible for initializing inherited data members or whether it should be
handled in the base class' constructor.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334935 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-18 11:50:17 +00:00