summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker/IdempotentOperationChecker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove the TypesCompatibleExprClass AST node. Merge its functionality into ↵Francois Pichet2010-12-081-1/+1
| | | | | | BinaryTypeTraitExpr. llvm-svn: 121298
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-1/+1
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Refine IdempotentOperationChecker::PathWasCompletelyAnalyzed() to also checkTed Kremenek2010-11-131-0/+9
| | | | | | BlockEdges, BlockEntrances, and BlockExits for the target block value. llvm-svn: 118984
* Teach IdempotentOperations::PathWasCompletelyAnalyzed to also consider items ↵Ted Kremenek2010-11-131-1/+31
| | | | | | | | | | remaining in the worklist that could have impacted the evaluation of a block. Fixes <rdar://problem/8663596>. llvm-svn: 118983
* Don't flag idempotent '+' or '-' warnings for pointer arithmetic (typically ↵Ted Kremenek2010-10-291-0/+7
| | | | | | | | false positives). Fixes <rdar://problem/8601243>. llvm-svn: 117635
* Revert r114244 since it breaks a test in Analysis.Tom Care2010-09-181-3/+0
| | | | llvm-svn: 114246
* IdempotentOperationChecker no longer reports errors that are post-dominated ↵Tom Care2010-09-181-0/+3
| | | | | | by a sink. This fixes some false positives that were flagged because a path was incomplete (usually in a loop). llvm-svn: 114244
* Rename GRState::getSVal() -> getRawSVal() and getSimplifiedSVal() -> getSVal().Ted Kremenek2010-09-091-1/+3
| | | | | | | | | | | | | | | | | The end result is now we eagarly constant-fold symbols in the analyzer that are perfectly constrained to be a constant value. This allows us to recover some path-sensitivity in some cases by lowering the required level of reasoning power needed to evaluate some expressions. The net win from this change is that the false positive in PR 8015 is fixed, and we also find more idempotent operations bugs. We do, however, regress with the BugReporterVisitors, which need to be modified to understand this constant folding (and look past it). This causes some diagnostic regressions in plist-output.m which will get addressed in a future patch. plist-output.m is now marked XFAIL, while plist-output-alternate.m now tests that the plist output is working, but with the suboptimal diagnostics. This second test file will eventually be removed. llvm-svn: 113477
* Simplified reachability checking in IdempotentOperationChecker and added a ↵Tom Care2010-09-091-72/+155
| | | | | | | | | | helper function for path display. - Created private class CFGReachabilityAnalysis, which provides cached reachability lookups in the CFG - Simplified PathWasCompletelyAnalyzed to use the new reachability class - Added getLastRelevantNodes function for future use with path displaying in BugReporter llvm-svn: 113465
* Re-enabled truncation/extension checking in IdempotentOperationChecker and ↵Tom Care2010-09-071-6/+5
| | | | | | added a test case. llvm-svn: 113269
* "I see dead code". IdempotentOperationChecker::isTruncationExtensionAssignmentChris Lattner2010-09-031-2/+4
| | | | | | | | | should probably be removed if it has no purpose, but I just #if'd it out in case it's usefulIdempotentOperationChecker::isTruncationExtensionAssignment should probably be removed if it has no purpose, but I just #if'd it out in case it's useful llvm-svn: 112949
* Reapply 112850 and 112839 with a constructor for the BinaryOperatorData ↵Tom Care2010-09-021-17/+60
| | | | | | struct. Clang would zero out the enum and pointer in the struct in some conditions, but GCC would never zero out the values. llvm-svn: 112909
* Reverting 112850 and 112839 due to test failures on some systemsTom Care2010-09-021-58/+17
| | | | llvm-svn: 112857
* Fixed broken build with GCCTom Care2010-09-021-12/+12
| | | | llvm-svn: 112850
* Improved error reporting in IdempotentOperationCheckerTom Care2010-09-021-17/+58
| | | | | | | | | - SourceRange highlighting is only given for the relevant side of the operator (assignments give both) - Added PostVisitBinaryOperator hook to retrieve the ExplodedNode for an operator - Added a BugReporterVisitor to display the last store to every VarDecl in a Stmt - Changed bug reporting to use the new BugReporterVisitor llvm-svn: 112839
* Adjusted the semantics of assign checking in IdempotentOperationCheckerTom Care2010-08-301-26/+41
| | | | | | | | | | - Fixed a regression where assigning '0' would be reported - Changed the way self assignments are filtered to allow constant testing - Added a test case for assign ops - Fixed one test case where a function pointer was not considered constant - Fixed test cases relating to 0 assignment llvm-svn: 112501
* Added checking of (x == x) and (x != x) to IdempotentOperationChecker and ↵Tom Care2010-08-271-0/+2
| | | | | | updated test cases flagged by it. llvm-svn: 112313
* Fix bug in IdempotentOperationChecker where an assumption would not get ↵Tom Care2010-08-271-0/+4
| | | | | | updated properly. llvm-svn: 112309
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-71/+71
| | | | | | to the new constants. llvm-svn: 112047
* Improvements to IdempotentOperationChecker and its use of PseudoConstantAnalysisTom Care2010-08-241-11/+29
| | | | | | | | | | | | - Added wasReferenced function to PseudoConstantAnalysis to determine if a variable was ever referenced in a function (outside of a self-assignment) - BlockDeclRefExpr referenced variables are now explicitly added to the non-constant list - Remove unnecessary ignore of implicit casts - Generalized parameter self-assign detection to detect deliberate self-assigns of variables to avoid unused variable warnings - Updated test cases with deliberate self-assignments - Fixed bug with C++ references and pseudoconstants - Added test case for C++ references and pseudoconstants llvm-svn: 111965
* Several small changes to PseudoConstantAnalysis and the way ↵Tom Care2010-08-231-19/+45
| | | | | | | | | | | | IdempotentOperationChecker uses it. - Psuedo -> Pseudo (doh...) - C++ reference support - Added pseudoconstant test case for __block vars - Separated out static local checking from pseudoconstant analysis and generalized to non-local checking - Added missing test cases for storage false positives llvm-svn: 111832
* Added psuedo-constant analysis and integrated it into the false positive ↵Tom Care2010-08-181-15/+37
| | | | | | | | | | | | | reduction stage in IdempotentOperationChecker. - Renamed IdempotentOperationChecker::isConstant to isConstantOrPseudoConstant to better reflect the function - Changed IdempotentOperationChecker::PreVisitBinaryOperator to only run 'CanVary' once on undefined assumptions - Created new PsuedoConstantAnalysis class and added it to AnalysisContext - Changed IdempotentOperationChecker to exploit the new analysis - Updated tests with psuedo-constants - Added check to IdempotentOperationChecker to see if a Decl is const qualified llvm-svn: 111426
* Added basic psuedoconstant checking in IdempotentOperationChecker and fixed ↵Tom Care2010-08-161-2/+16
| | | | | | some test cases. llvm-svn: 111190
* Zap unused UnaryOperator::OffsetOf.Eli Friedman2010-08-131-2/+1
| | | | llvm-svn: 110996
* Improved IdempotentOperationChecker false positives and false negatives.Tom Care2010-08-121-98/+203
| | | | | | | | | - Unfinished analysis may still report valid warnings if the path was completely analyzed - New 'CanVary' heuristic to recursively determine if a subexpression has a varying element - Updated test cases, including one known bug - Exposed GRCoreEngine through GRExprEngine llvm-svn: 110970
* Removed IdempotentOperationChecker from default analysis and returned back ↵Tom Care2010-08-061-1/+1
| | | | | | | | | to a flag (-analyzer-check-idempotent-operations) - Added IdempotentOperationChecker to experimental analyses for testing purposes - Updated test cases to explictly call the checker llvm-svn: 110482
* Changed GRExprEngine to pass down a reference to itself when checkers are ↵Tom Care2010-08-031-4/+3
| | | | | | | | | doing postanalysis. This allows the checker to gather information about the state of the engine when it has finished. - Exposed the worklist and BlockAborted flag in GRCoreEngine - Changed postanalysis checkers to use the new infrastructure llvm-svn: 110095
* 'Assumption &A' gets default initialized to 'Possible' if it doesn't exist; ↵Ted Kremenek2010-08-021-8/+5
| | | | | | | | no need to two lookups in the hashtable. llvm-svn: 110059
* Uncomment unfinished work bailout in IdempotentOperationsChecker.Tom Care2010-07-301-2/+2
| | | | llvm-svn: 109893
* Extracted out some useful common functions in IdempotentOperationChecker to ↵Tom Care2010-07-271-86/+3
| | | | | | their own CheckerHelpers file. llvm-svn: 109560
* Finesse 'idempotent operations' analyzer issues to include the opcode of the ↵Ted Kremenek2010-07-271-10/+16
| | | | | | binary operator for clearer error reporting. Also remove the 'Idempotent operation' prefix in messages; it's redundant since the bug type is the same. llvm-svn: 109527
* Put 'Idempotent operations' static analyzer issues in the 'Dead code' category.Ted Kremenek2010-07-271-1/+2
| | | | llvm-svn: 109517
* Fix APFloat assertion failure in IdempotentOperationChecker resulting in havingTed Kremenek2010-07-171-4/+6
| | | | | | an APFloat with different "float semantics" than the compared float literal. llvm-svn: 108590
* Improved false positive rate for the idempotent operations checker and moved ↵Tom Care2010-07-161-3/+80
| | | | | | | | | | it into the default path-sensitive analysis options. - Added checks for static local variables, self assigned parameters, and truncating/extending self assignments - Removed command line option (now default with --analyze) - Updated test cases to pass with idempotent operation warnings llvm-svn: 108550
* Change explicit handling of impossible condition to call llvm_unreachable in ↵Tom Care2010-07-071-2/+2
| | | | | | IdempotentOperationChecker::PreVisitBinaryOperator. llvm-svn: 107748
* Silence an annoying GCC warning about use of an uninitialized variable. EvenChandler Carruth2010-07-071-1/+1
| | | | | | | making the other switch case unreachable, or sinking the 'continue' into it doesn't silence this. llvm-svn: 107745
* Use 'llvm_unreachable' to mark impossible code paths so that GCC doesn'tChandler Carruth2010-07-071-1/+2
| | | | | | consider them for warnings. llvm-svn: 107741
* Added a path-sensitive idempotent operation checker ↵Tom Care2010-07-061-0/+453
(-analyzer-idempotent-operation). Finds idempotent and/or tautological operations in a path sensitive context, flagging operations that have no effect or a predictable effect. Example: { int a = 1; int b = 5; int c = b / a; // a is 1 on all paths } - New IdempotentOperationChecker class - Moved recursive Stmt functions in r107675 to IdempotentOperationChecker - Minor refactoring of SVal to allow checking for any integer - Added command line option for check - Added basic test cases llvm-svn: 107706
OpenPOWER on IntegriCloud