Commit Graph

14 Commits

Author SHA1 Message Date
Kristof Umann 43cdc8690f [analyzer][UninitializedObjectChecker] New flag to ignore records based on it's fields
Based on a suggestion from @george.karpenkov.

In some cases, structs are used as unions with a help of a tag/kind field.
This patch adds a new string flag (a pattern), that is matched against the
fields of a record, and should a match be found, the entire record is ignored.

For more info refer to http://lists.llvm.org/pipermail/cfe-dev/2018-August/058906.html
and to the responses to that, especially http://lists.llvm.org/pipermail/cfe-dev/2018-August/059215.html.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342220 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 10:10:09 +00:00
Kristof Umann 91ef6e511f [analyzer][UninitializedObjectChecker] Refactored checker options
Since I plan to add a number of new flags, it made sense to encapsulate
them in a new struct, in order not to pollute FindUninitializedFields's
constructor with new boolean options with super long names.

This revision practically reverts D50508, since FindUninitializedFields
now accesses the pedantic flag anyways.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342219 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 09:39:26 +00:00
Kristof Umann f2937b1580 [analyzer][UninitializedObjectChecker] Updated comments
Some of the comments are incorrect, imprecise, or simply nonexistent.
Since I have a better grasp on how the analyzer works, it makes sense
to update most of them in a single swoop.

I tried not to flood the code with comments too much, this amount
feels just right to me.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342215 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 09:07:40 +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 33d03d9e30 [analyzer] Correctly marked a virtual function 'override'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340280 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 15:09:22 +00:00
Kristof Umann e46b1b616d [analyzer][UninitializedObjectChecker] Explicit namespace resolution for inherited data members
For the following example:

  struct Base {
    int x;
  };

  // In a different translation unit

  struct Derived : public Base {
    Derived() {}
  };

For a call to Derived::Derived(), we'll receive a note that
this->x is uninitialized. Since x is not a direct field of Derived,
it could be a little confusing. This patch aims to fix this, as well
as the case when the derived object has a field that has the name as
an inherited uninitialized data member:

  struct Base {
    int x; // note: uninitialized field 'this->Base::x'
  };

  struct Derived : public Base {
    int x = 5;
    Derived() {}
  };

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 12:16:59 +00:00
Kristof Umann 1bdc37d05e [analyzer][UninitializedObjectChecker] Added documentation to the checker list
Differential Revision: https://reviews.llvm.org/D50904


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340266 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:47:19 +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
George Karpenkov 39e21032cb [analyzer] Fix UninitializedObjectChecker to not crash on uninitialized "id" fields
Differential Revision: https://reviews.llvm.org/D50673

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339631 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 23:32:15 +00:00
Richard Smith 09d5c6b600 Fix Clang warnings and bad #include filenames in r339595 and r339599.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339624 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 22:07:11 +00:00
Kristof Umann 9b127f0e72 [analyzer][UninitializedObjectChecker] Refactoring p5.: Handle pedantic mode in the checker class only
Differential Revision: https://reviews.llvm.org/D50508


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339601 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 18:48:34 +00:00
Kristof Umann 532d704249 [analyzer][UninitializedObjectChecker] Refactoring p4.: Wrap FieldRegions and reduce weight on FieldChainInfo
Before this patch, FieldChainInfo used a spaghetti: it took care of way too many cases,
even though it was always meant as a lightweight wrapper around
ImmutableList<const FieldRegion *>.
This problem is solved by introducing a lightweight polymorphic wrapper around const
FieldRegion *, FieldNode. It is an interface that abstracts away special cases like
pointers/references, objects that need to be casted to another type for a proper note
messages.

Changes to FieldChainInfo:

  * Now wraps ImmutableList<const FieldNode &>.
  * Any pointer/reference related fields and methods were removed
  * Got a new add method. This replaces it's former constructors as a way to create a
    new FieldChainInfo objects with a new element.

Changes to FindUninitializedField:

  * In order not to deal with dynamic memory management, when an uninitialized field is
    found, the note message for it is constructed and is stored instead of a
    FieldChainInfo object. (see doc around addFieldToUninits).

Some of the test files are changed too, from now on uninitialized pointees of references
always print "uninitialized pointee" instead of "uninitialized field" (which should've
really been like this from the beginning).

I also updated every comment according to these changes.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339599 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 18:43:08 +00:00
Kristof Umann 2ed34ac167 [analyzer][UninitializedObjectChecker] Refactoring p3.: printTail moved out from FieldChainInfo
This is a standalone part of the effort to reduce FieldChainInfos inteerface.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339596 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 18:22:22 +00:00
Kristof Umann 4f97dae072 [analyzer][UninitializedObjectChecker] Refactoring p2.: Moving pointer chasing to a separate file
In this patch, the following classes and functions have been moved to a header file:

    FieldChainInfo
    FindUninitializedFields
    isPrimitiveType

This also meant that they moved from anonymous namespace to clang::ento.

Code related to pointer chasing now relies in its own file.

There's absolutely no functional change in this patch -- its literally just copy pasting.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339595 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 18:17:05 +00:00