Commit Graph

2165 Commits

Author SHA1 Message Date
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
DeLesley Hutchins 08e094aee3 Test commit
llvm-svn: 140149
2011-09-20 17:25:59 +00:00
Anna Zaks c2b3c1f14b [analyzer] Constify a method.
llvm-svn: 140091
2011-09-19 23:17:48 +00:00
Ted Kremenek 459597a6eb Fix massive LiveVariables regression (due to LiveVariables rewrite) by addressing two performance problems:
- Speed of "merge()", which merged data flow facts.  This was doing a set canonicalization on every insertion, which was super slow.
  To fix this, we use ImmutableSetRef.

- Visit CFGBlocks in reverse postorder.  This is a huge speedup, as on some test cases the algorithm would take many iterations
  to converge.

This contains a bunch of copy-paste from UninitializedValues.cpp and ThreadSafety.cpp.  The idea
was to get something working first, and then refactor the common logic for all three files into
a separate analysis/library entry point.

llvm-svn: 139968
2011-09-16 23:01:39 +00:00
Caitlin Sadowski 086fb95da5 Thread safety: Adding FIXMEs and a couple cleanups
llvm-svn: 139894
2011-09-16 00:35:54 +00:00
Caitlin Sadowski 6525fb25cb Thread safety: completeing the implementation of shared/exclusive locks required attributes
llvm-svn: 139804
2011-09-15 17:43:08 +00:00
Caitlin Sadowski af9b7c5f8b Thread safety: refactoring various out of scope warnings to use the same inteface. This eliminates a lot of unnecessary duplicated code.
llvm-svn: 139801
2011-09-15 17:25:19 +00:00
Caitlin Sadowski 5b34a2fd6e Thread safety: adding additional documentation to the main thread safety interface, and making the destructor for the thread safety handler pure virtual
llvm-svn: 139722
2011-09-14 20:05:09 +00:00
Caitlin Sadowski 787c2a1b09 Thread safety: adding test cases for unparseable lock expressions and expanding the handling of these expressions
llvm-svn: 139720
2011-09-14 20:00:24 +00:00
Chandler Carruth 75d78232fd Add a bit to the CFGBlock to track when it contains a no-return
CFGElement. This will allow greatly simplifying the logic in
-Wreturn-type.

llvm-svn: 139593
2011-09-13 09:53:55 +00:00
Chandler Carruth a70991bb3f Consolidate the logic for building a no-return CFG block into a single
location with a single comment rather than scattering it in three
places.

llvm-svn: 139592
2011-09-13 09:13:49 +00:00
Chandler Carruth ad74725ab5 Enhance the CFG construction to detect no-return destructors for
temporary objects and local variables. When detected, these split the
block, marking the new one as having only the exit block as a successor.
This prevents a large number of false positives in warnings sensitive to
no-return constructs such as -Wreturn-type, and fixes the remainder of
PR10063 along with several variations of this bug that had not been
reported. The test cases are extended across the board to cover these
patterns.

This also checks in a stress test for these types of CFGs. The stress
test declares some 32k variables, a mixture of no-return and normal
destructors. Previously, this resulted in roughly 2500 CFG blocks, but
didn't model any of the no-return destructors. With this patch, it
results in over 33k blocks, many of them now unreachable.

The nice thing about how the analyzer is set up? This causes *no*
regression in performance of building the CFG. It actually in some cases
makes it faster, as best I can benchmark. The analysis for -Wreturn-type
(and any other that cares about no-return code paths) is technically
slower now as it has to look at many more candidate blocks, but it
computes the correct answer. I have more test cases to follow, I think
they all work now. Also I have further work that should dramatically
simplify analyses in the presence of no-return.

llvm-svn: 139586
2011-09-13 06:09:01 +00:00
Caitlin Sadowski eecd273951 Thread safety: small formatting change
llvm-svn: 139548
2011-09-12 22:28:41 +00:00
Benjamin Kramer 8a8051f2cd Silence "end of non-void function" warnings with llvm_unreachable and add an assert.
llvm-svn: 139474
2011-09-10 21:52:04 +00:00
Chandler Carruth a626d645d5 Extend the Stmt AST to make it easier to look through label, default,
and case statements. Use this to make the logic in the CFG builder more
robust at finding the actual statements within a compound statement,
even when there are many layers of labels obscuring it.

Also extend the test cases for a large chunk of PR10063. Still more work
to do here though.

llvm-svn: 139437
2011-09-10 00:02:34 +00:00
Caitlin Sadowski 82e2de512e Thread safety: removing unnecessary import and reordering import list
llvm-svn: 139426
2011-09-09 23:00:59 +00:00
Caitlin Sadowski 0bef2279fb Thread safety: removing unnecessary import
llvm-svn: 139425
2011-09-09 22:49:12 +00:00
Caitlin Sadowski ff2f3f8105 Thread safety: This patch deals with previously unhandled cases when building lock expressions. We now resolve this expressions, avoid crashing when encountering cast expressions, and have a diagnostic for unresolved lock expressions
llvm-svn: 139370
2011-09-09 16:21:55 +00:00
Caitlin Sadowski 33208340bd Thread Safety: Moving the analysis to a new file
llvm-svn: 139369
2011-09-09 16:11:56 +00:00
Ted Kremenek aed4677a1c -Wuninitialized: fix insidious bug resulting from interplay of blocks and dead code. Fixes <rdar://problem/10060250>.
llvm-svn: 139027
2011-09-02 19:39:26 +00:00
Nico Weber 1fb82667dd Warn on missing [super finalize] calls.
This matches gcc's logic. Second half of PR10661.

llvm-svn: 138730
2011-08-28 22:35:17 +00:00
Ted Kremenek 1b7f49c2d6 Teach -Wunreachable-code about dead code caused by macro expansions. This should suppress false positives resulting from 'assert' and friends.
llvm-svn: 138576
2011-08-25 19:28:55 +00:00
Ted Kremenek bd91371381 Start reworking -Wunreachable-code. The original analysis had serious flaws with how it
handled SCC's of dead code, or simply having false negatives by overly suppressing warnings.

WIP.

llvm-svn: 138410
2011-08-23 23:05:11 +00:00
Ted Kremenek 6b9964d237 CFG: record set of C++ 'try' dispatch blocks, which could be of interest to various analyses (e.g., reachability).
llvm-svn: 138409
2011-08-23 23:05:07 +00:00
Ted Kremenek adfb445466 Constify the result of CFGStmt::getStmt().
llvm-svn: 138408
2011-08-23 23:05:04 +00:00
Ted Kremenek ee9848e20d Fix regression in -Wuninitialized involving VLAs. It turns out that we were modeling sizeof(VLAs)
incorrectly in the CFG, and also the static analyzer.  This patch regresses the analyzer a bit, but
that needs to be followed up with a better solution.

Fixes <rdar://problem/10008112>.

llvm-svn: 138372
2011-08-23 20:30:50 +00:00
Ted Kremenek 417d566775 Remove dead code.
llvm-svn: 138183
2011-08-20 01:15:28 +00:00
Chad Rosier 6fdf38bfbd Fix else style. No functionality change intended.
llvm-svn: 137896
2011-08-17 23:08:45 +00:00
Ted Kremenek c14efa7122 Fix a handful of dead stores found by Clang's static analyzer. There's a bunch of others I haven't touched.
llvm-svn: 137867
2011-08-17 21:04:19 +00:00
Ted Kremenek 5ef32dbf2a Cleanup various declarations of 'Stmt*' to be 'Stmt *', etc. in libAnalyzer and libStaticAnalyzer[*]. It was highly inconsistent, and very ugly to look at.
llvm-svn: 137537
2011-08-12 23:37:29 +00:00
Ted Kremenek e8f7316fee [analyzer] change "tag" in ProgramPoint from "void*" to a ProgramPointTag*.
Having a notion of an actual ProgramPointTag will aid in introspection of the analyzer's behavior.
For example, the GraphViz output of the analyzer will pretty-print the tags in a useful manner.

llvm-svn: 137529
2011-08-12 23:04:46 +00:00
Ted Kremenek 50aa2d480c Revert "Fix crash in CFGBuilder involving implicit destructor calls and gotos jumping after an object was declared. Fixes PR 10620."
llvm-svn: 137459
2011-08-12 14:41:23 +00:00
Ted Kremenek 06b8cd7324 Fix crash in CFGBuilder involving implicit destructor calls and gotos jumping after an object was declared. Fixes PR 10620.
llvm-svn: 137426
2011-08-12 04:09:00 +00:00
Ted Kremenek a0cdf58b0c Fix another -Wuninitialized assertion failure (this one involving bit casts) resulting from the recent -Wuninitialized changes.
llvm-svn: 137068
2011-08-08 21:43:08 +00:00
Ted Kremenek 84a1ca5280 [analyzer] Simplify logic for ExprEngine::VisitUnaryExprOrTypeTraitExpr to avoid recursion to subexpression.
This exposed bugs in the live variables analysis, and a latent analyzer bug in the SymbolReaper.

llvm-svn: 137006
2011-08-06 00:30:00 +00:00
Ted Kremenek 75842e4946 Fix assertion failure in -Wuninitialized involving no-op casts. Fixes PR 10577.
llvm-svn: 136939
2011-08-04 22:40:57 +00:00
Benjamin Kramer 3c05b7c161 Make helper functions static.
llvm-svn: 136679
2011-08-02 04:50:49 +00:00
Ted Kremenek e9fda1e48a [analyzer] Overhaul how the static analyzer expects CFGs by forcing CFGs to be linearized only when used by the static analyzer. This required a rewrite of LiveVariables, and exposed a ton of subtle bugs.
The motivation of this large change is to drastically simplify the logic in ExprEngine going forward.

Some fallout is that the output of some BugReporterVisitors is not as accurate as before; those will
need to be fixed over time.  There is also some possible performance regression as RemoveDeadBindings
will be called frequently; this can also be improved over time.

llvm-svn: 136419
2011-07-28 23:07:59 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Chandler Carruth 4dd6c043ae Move duplicate uninitialized warning suppression into the
AnalysisBasedWarnings Sema layer and out of the Analysis library itself.
This returns the uninitialized values analysis to a more pure form,
allowing its original logic to correctly detect some categories of
definitely uninitialized values. Fixes PR10358 (again).

Thanks to Ted for reviewing and updating this patch after his rewrite of
several portions of this analysis.

llvm-svn: 135748
2011-07-22 05:27:52 +00:00
Ted Kremenek 189ecec4db Simplify passing of CFGBuildOptions around for AnalysisContext. No functionality change.
llvm-svn: 135666
2011-07-21 05:22:47 +00:00
Ted Kremenek 81383c20e4 Fix -Wuninitialized regression involving functions invalidating parameters passed by reference.
llvm-svn: 135610
2011-07-20 19:49:47 +00:00
Ted Kremenek 65b3e0649c Fix false negative in -Wuninitialized involving a () wrapping an lvalue-to-rvalue conversion in a DeclStmt.
llvm-svn: 135525
2011-07-19 21:41:51 +00:00
Ted Kremenek 5d855bf7f2 Fix assertion failure in UninitializedValues.cpp where an lvalue to rvalue conversion is wrapped in a parenthesis.
llvm-svn: 135519
2011-07-19 20:33:49 +00:00
Ted Kremenek 9e100ea1a8 Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST crawl.
This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG.
This allows us to remove a fair amount of the code for -Wuninitialized.

Some fallout:
- AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized.  This
is a layering violation, since the logic for -Wuninitialized is in libAnalysis.  This can be fixed with the proper refactoring.
- Some of the source locations for -Wunreachable-code warnings have shifted.  While not ideal, this is okay because that analysis
already needs some serious reworking.

llvm-svn: 135480
2011-07-19 14:18:48 +00:00
Ted Kremenek 8b46c00b5f Add hooks into the CFG builder to force that specific expressions are always CFGElements.
llvm-svn: 135479
2011-07-19 14:18:43 +00:00
Chandler Carruth 7cf5a37605 Revert r135217, which wasn't the correct fix for PR10358. With this
patch, we actually move the state-machine for the value set backwards
one step. This can pretty easily lead to infinite loops where we
continually try to propagate a bit, succeed for one iteration, but then
back up because we find an uninitialized use.

A reduced test case from PR10379 is included.

llvm-svn: 135359
2011-07-16 22:27:02 +00:00
Ted Kremenek 6dcbbe8547 [analyzer] Per discussions with the Cocoa team, extend CF naming conventions to extend to camel case functions instead of just title case functions. Fixes <rdar://problem/9732321>.
llvm-svn: 135350
2011-07-16 19:50:36 +00:00
Ted Kremenek c85964ed90 [analyzer] Place checking for Core Foundation "Create" rule into a proper API. No functionality change.
llvm-svn: 135349
2011-07-16 19:50:32 +00:00
Ted Kremenek f0b28d7fe5 Fix false negative reported in PR 10358 by using 'Unknown' in -Wuninitialized to avoid cascading warnings. Patch by Kaelyn Uhrain.
llvm-svn: 135217
2011-07-14 23:43:06 +00:00