Commit Graph

3396 Commits

Author SHA1 Message Date
George Karpenkov b9dbcf4f94 [analyzer] ExplodedGraph printing fixes
Fixes a number of issues:

 - Global variables are not used for communication
 - Trait should be defined on a graph, not on a node
 - Defining the trait on a graph allows us to use a correct allocator,
   no longer crashing while printing trimmed graphs

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342413 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 20:46:53 +00:00
George Karpenkov 58cfe5b8b7 [analyzer] Further printing improvements: use declarations,
skip pointers whenever redundant, use unique prefixes.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342316 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:34:45 +00:00
George Karpenkov ab961c560a [analyzer] Generate and use stable identifiers for LocationContext
Those are not created in the allocator.
Since they are created fairly rarely, a counter overhead should not
affect the memory consumption.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342314 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:03:36 +00:00
George Karpenkov 7d1cca4458 [analyzer] Dump reproducible identifiers for statements in exploded graph in store
Differential Revision: https://reviews.llvm.org/D51826

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342313 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:03:17 +00:00
George Karpenkov 843c06ec25 [analyzer] Use correct end-of-line character when printing statements for exploded graph
Prevents bad centering.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342312 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:02:56 +00:00
George Karpenkov f702afcb3e [analyzer] Dump unique identifiers for statements in exploded graph
Differential Revision: https://reviews.llvm.org/D51823

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:02:09 +00:00
George Karpenkov e4d256f38d [analyzer] Skip printing duplicate nodes, even if nodes have multiple predecessors/successors
Still generate a node, but leave the redundant field empty.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342308 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:01:26 +00:00
Ilya Biryukov fdf354a5a0 [analyzer] Restore final on NeedsCastLocField. NFC
To fix compiler warning about non-virtual dtor introduced in r342221.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342225 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 11:28:48 +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 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 fe266159d5 [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees
Differential Revision: https://reviews.llvm.org/D50892


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342217 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 09:13:36 +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
Adam Balogh 844a9e7959 [Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, emplace and erase operations
This patch adds support for the following operations in the iterator checkers: assign, clear, insert, insert_after, emplace, emplace_after, erase and erase_after. This affects mismatched iterator checks ("this" and parameter must match) and invalidation checks (according to the standard).

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341794 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 09:07:47 +00:00
Adam Balogh 399a4432e1 [Analyzer] Iterator Checker - Part 7: Support for push and pop operations
This patch adds support for the following operations in the iterator checkers: push_back, push_front, emplace_back, emplace_front, pop_back and pop_front. This affects iterator range checks (range is extended after push and emplace and reduced after pop operations) and invalidation checks (according to the standard).

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341793 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 09:06:31 +00:00
Adam Balogh e171ae4858 [Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for constructors and comparisons
Extension of the mismatched iterator checker for constructors taking range of first..last (first and last must be iterators of the same container) and also for comparisons of iterators of different containers (one does not compare iterators of different containers, since the set of iterators is partially ordered, there are no relations between iterators of different containers, except that they are always non-equal).

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341792 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 09:05:31 +00:00
Adam Balogh 90174d3815 [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers
If a container is moved by its move assignment operator, according to the standard all their iterators except the past-end iterators remain valid but refer to the new container. This patch introduces support for this case in the iterator checkers.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341791 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 09:04:27 +00:00
Adam Balogh 6475259f54 [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters
New check added to the checker which checks whether iterator parameters of template functions typed by the same template parameter refer to the same container.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341790 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 09:03:22 +00:00
George Karpenkov e1e8e05bd9 [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into the class
Differential Revision: https://reviews.llvm.org/D51513

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341724 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 22:13:35 +00:00
George Karpenkov f53cf284fb [analyzer] [NFC] Use StringRef when returning a large string literal in HTMLDiagnostics
(NB: could be a clang-tidy / analyzer check)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341723 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 22:13:15 +00:00
George Karpenkov 43322674ac [analyzer] Remove the "postponed" hack, deal with derived symbols using an extra map
The "derived" symbols indicate children fields of a larger symbol.
As parents do not have pointers to their children, the garbage
collection algorithm the analyzer currently uses adds such symbols into
a "postponed" category, and then keeps running through the worklist
until the fixed point is reached.

The current patch rectifies that by instead using a helper map which
stores pointers from parents to children, so that no fixed point
calculation is necessary.

The current patch yields ~5% improvement in running time on sqlite.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341722 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 22:07:57 +00:00
George Karpenkov 71ac9ba16b Revert "Revert "Revert "Revert "[analyzer] Add coverage information to plist output, update tests""""
This reverts commit 2f5d71d9fa135be86bb299e7d773036e50bf1df6.

Hopefully fixing tests on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341719 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 21:58:24 +00:00
Simon Pilgrim 30f22e0d51 Revert "Revert "Revert "[analyzer] Add coverage information to plist output, update tests"""
Reverts analyzer tests from rL341627 again as they still broke windows buildbots

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341648 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 10:27:16 +00:00
George Karpenkov f0bf1c6f8d Revert "Revert "[analyzer] Add coverage information to plist output, update tests""
This reverts commit a39bcab414dd7ace7e490363ecdf01ecce7743fc.

Reverting the revert, fixing tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341627 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 02:02:35 +00:00
George Karpenkov 40ee08b1ae Revert "[analyzer] Add coverage information to plist output, update tests"
This reverts commit 03d183b6b94eda27ce66a4f9b87a00b0a148cf9e.

Temporary revert until the tests are fixed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341626 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 01:39:23 +00:00
George Karpenkov 0815531dca [analyzer] Add coverage information to plist output, update tests
Split tests which were still using FileCheck to compare plists.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341621 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:44:17 +00:00
George Karpenkov 5c31d31323 [analyzer] [NFC] Prefer passing around reference to std::unique_ptr&
When object is owned elsewhere

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341620 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:43:55 +00:00
George Karpenkov 5bf7347d5c [analyzer] Executed lines: store file IDs, not hashes.
Raw FileIDs are needed for the PlistDiagnostics to produce stable filenames.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341619 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:43:37 +00:00
George Karpenkov 1ee3e10df5 [analyzer] Do not add invalid source location to the coverage information
Invalid source locations may arise from generated code.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341618 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:43:17 +00:00
George Karpenkov 4d7f220123 [analyzer] Push updating-the-executed-lines logic into the BugReporter.
So it can be reused across different consumers.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341617 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:42:53 +00:00
George Karpenkov 3f0bc9eab1 [analyzer] Skip printing trivial nodes in exploded graph
A node is considered to be trivial if it only has one successor, one
predecessor, and a state equal to the predecessor.
Can drastically (> 2x) reduce the size of the generated exploded
graph.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341616 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:42:32 +00:00
George Karpenkov cb712aff1f [analyzer] [NFC] Move dumping program point into a separate function
Differential Revision: https://reviews.llvm.org/D51666

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341603 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 23:08:27 +00:00
George Karpenkov 960d25b4d9 [analyzer] Dump stable identifiers for exploded nodes
Differential Revision: https://reviews.llvm.org/D51667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341602 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 23:08:07 +00:00
George Karpenkov 4d1df0a4ae [analyzer] Remove traces of ubigraph visualization
Ubigraph project has been dead since about 2008, and to the best of my
knowledge, no one was using it.
Previously, I wasn't able to launch the existing binary at all.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341601 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 23:07:47 +00:00
George Karpenkov cc7b7584b5 [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph
Differential Revision: https://reviews.llvm.org/D51395

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341600 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 23:07:26 +00:00
Artem Dergachev 914b703238 [analyzer] InnerPointerChecker: Fix a segfault when checking symbolic strings.
Return value of dyn_cast_or_null should be checked before use.
Otherwise we may put a null pointer into the map as a key and eventually
crash in checkDeadSymbols.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341092 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 18:45:05 +00:00
George Karpenkov 11b8f23212 [analyzer] Improve tracing for uninitialized struct fields
rdar://13729267

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340986 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 22:48:50 +00:00
Artem Dergachev 0d516dba5e [analyzer] Support modeling no-op BaseToDerived casts in ExprEngine.
Introduce a new MemRegion sub-class, CXXDerivedObjectRegion, which is
the opposite of CXXBaseObjectRegion, to represent such casts. Such region is
a bit weird because it is by design bigger than its super-region.
But it's not harmful when it is put on top of a SymbolicRegion
that has unknown extent anyway.

Offset computation for CXXDerivedObjectRegion and proper modeling of casts
still remains to be implemented.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340984 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 22:43:31 +00:00
Artem Dergachev 19ada6cb9b [analyzer] CFRetainReleaseChecker: Don't check C++ methods with the same name.
Don't try to understand what's going on when there's a C++ method called eg.
CFRetain().

Refactor the checker a bit, to use more modern APIs.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340982 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 22:39:20 +00:00
Artem Dergachev 2483f1c915 [CFG] [analyzer] Disable argument construction contexts for variadic functions.
The analyzer doesn't make use of them anyway and they seem to have
pretty weird AST from time to time, so let's just skip them for now.

Fixes a crash reported as pr37769.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340977 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 22:05:35 +00:00
George Karpenkov ee49cd21c4 [analyzer] Resolve the crash in ReturnUndefChecker
By making sure the returned value from getKnownSVal is consistent with
the value used inside expression engine.

PR38427

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340965 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:29:59 +00:00
George Karpenkov b1014a1a42 [analyzer] [NFC] Move class definition out of the function
Differential Revision: https://reviews.llvm.org/D51322

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340964 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:29:39 +00:00
George Karpenkov faff2291a9 [analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by default
Differential Revision: https://reviews.llvm.org/D51251

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340963 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:29:17 +00:00
George Karpenkov d2d7786ce5 [analyzer] [NFC] Remove unused "state" argument from makeSymExprValNN
Differential Revision: https://reviews.llvm.org/D51250

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340962 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:28:54 +00:00
George Karpenkov 9af55c6d39 [analyzer] Better retain count rules for OSObjects
Differential Revision: https://reviews.llvm.org/D51184

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340961 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:28:33 +00:00
George Karpenkov 01c0d176c0 [analyzer] [NFC] Follow the convention when naming classes
Renames InvalidateRegionsWorker and RemoveDeadBindingsWorker

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340960 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 20:28:13 +00:00
Adam Balogh d0fc178812 [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments
We add check for invalidation of iterators. The only operation we handle here
is the (copy) assignment.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340805 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 08:41:15 +00:00
Nico Weber 3a27fd7b06 fix comment typo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340743 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 14:23:50 +00:00
Mikhail R. Gadelha 60783c8623 [analyzer] Moved all CSA code from the SMT API to a new header, `SMTConv.h`. NFC.
Summary:
With this patch, the SMT backend is almost completely detached from the CSA.

Unfortunate consequence is that we missed the `ConditionTruthVal` from the CSA and had to use `Optional<bool>`.

The Z3 solver implementation is still in the same file as the `Z3ConstraintManager`, in `lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp` though, but except for that, the SMT API can be moved to anywhere in the codebase.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, Szelethus

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340534 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 13:21:31 +00:00