Commit Graph

118 Commits

Author SHA1 Message Date
Marcin Swiderski a7d84a7615 Added CFGTerminator class, that holds information about CFGBlock terminator statement.
llvm-svn: 117642
2010-10-29 05:21:47 +00:00
Zhongxing Xu d95ccd58a9 If visiting RHS causes us to finish 'Block', e.g. the RHS is a StmtExpr
containing a DoStmt, and the LHS doesn't create a new block, then we should
return RBlock.  Otherwise we'll incorrectly return NULL.

Also relax an assertion in VisitWhileStmt(). Reset 'Block' when it is finished.

llvm-svn: 117436
2010-10-27 03:23:10 +00:00
Marcin Swiderski 01769904d3 Added generation of destructors for member constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough).

llvm-svn: 117252
2010-10-25 07:05:54 +00:00
Marcin Swiderski 52e4bc1fed Added generation of destructors for constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough).

llvm-svn: 117251
2010-10-25 07:00:40 +00:00
Marcin Swiderski 772324971d - Fixed subexpressions evaluation order for binary operators to match order in code generated with the compiler,
- Fixed test cases for unreachable code warnings produced by Sema.

llvm-svn: 117220
2010-10-24 08:21:40 +00:00
Zhongxing Xu 614e17dddf * Simplify code
* Fix dump() to make it consistent with the test case.

llvm-svn: 115609
2010-10-05 08:38:06 +00:00
Marcin Swiderski 20b88739ed Added support for base and member destructors in destructor.
llvm-svn: 115592
2010-10-05 05:37:00 +00:00
Marcin Swiderski 87b1bb6fd2 Added support for C++ initializers in CFG.
llvm-svn: 115493
2010-10-04 03:38:22 +00:00
Zhongxing Xu b06a2cdd2b Now the whether adding implicit dtors is controlled by cmd option.
llvm-svn: 115275
2010-10-01 03:31:06 +00:00
Zhongxing Xu 6d372f7c0f The return value is never used.
llvm-svn: 115272
2010-10-01 03:22:39 +00:00
Zhongxing Xu 307701e1b4 Use default augument.
llvm-svn: 115271
2010-10-01 03:09:09 +00:00
Zhongxing Xu 81714f2196 Simplify interface for addLocalScopeForStmt().
llvm-svn: 115270
2010-10-01 03:00:16 +00:00
Zhongxing Xu ea360a3b1a The old logic would add non-struct and non C++ struct variables to the local
scope. Now we only add C++ struct with non-trivial destructor variables to the
local scope.

llvm-svn: 115269
2010-10-01 02:47:11 +00:00
Marcin Swiderski 3546b1aea1 Added generating CFGAutomaticObjDtors for exception variable in catch statement.
llvm-svn: 115266
2010-10-01 01:46:52 +00:00
Marcin Swiderski 6d5ee0c7f9 Added generating CFGAutomaticObjDtors for init statement, condition variable and implicit scope in for statement.
llvm-svn: 115265
2010-10-01 01:38:14 +00:00
Marcin Swiderski e407a3ba1e dded generating CFGAutomaticObjDtors for condition variable and implicit scopes in switch statement.
llvm-svn: 115264
2010-10-01 01:24:41 +00:00
Marcin Swiderski 1f4e15c56f Added generating CFGAutomaticObjDtors for condition variable and implicit scopes in while and do statements.
llvm-svn: 115262
2010-10-01 01:14:17 +00:00
Marcin Swiderski f883ade880 Added generating CFGAutomaticObjDtors for condition variable and implicit scopes in if statement.
llvm-svn: 115256
2010-10-01 00:52:17 +00:00
Marcin Swiderski e84cb97997 Fixed checking for trivial destructor in CFGBuilder::addLocalScopeForVarDecl. Checked type does not have to represent C++ class.
llvm-svn: 115254
2010-10-01 00:31:22 +00:00
Marcin Swiderski 667ffecd9e Added:
- Adding LocalScope for CompoundStmt,
- Adding CFGAutomaticObjDtors for end of scope, return, goto, break, continue,
- Regression tests for above cases.

llvm-svn: 115252
2010-10-01 00:23:17 +00:00
Marcin Swiderski 5e41573d26 Added methods for adding LocalScopes and CFGAutomaticObjDtors.
llvm-svn: 115237
2010-09-30 23:05:00 +00:00
Marcin Swiderski 321a707c9c Added methods for inserting CFGAutomaticObjDtors to CFGBlocks,
Fixed some misspells in comments.

llvm-svn: 115236
2010-09-30 22:54:37 +00:00
Marcin Swiderski e9862ce90a Added:
- post-increament, distance and bool conversion methods to LocalScope::const_iterator,
- adding VarDecl to LocalScope.

Fixed some misspells in comments.

llvm-svn: 115227
2010-09-30 22:42:32 +00:00
Marcin Swiderski 8b99b8a782 In preparation for adding generation of destructors for objects with automatic storage added:
- LocalScope class with iterator used to pointing into it,
- fat doxygen comment for LocalScope indended usage,
- BlockScopePosPair class used for storing jump targets/sources (for: goto, break, continue), that replaces raw CFGBlock pointer used earlier for this purpose.

llvm-svn: 114790
2010-09-25 11:05:21 +00:00
Marcin Swiderski c0ca7316bc Added:
- definitions of interfaces for CFGInitializer and CFGAutomaticObjDtor,
- support for above classes to print_elem function (renamed print_stmt),
- support for VarDecls in StmtPrinterHelper.

llvm-svn: 114403
2010-09-21 05:58:15 +00:00
Zhongxing Xu d38fb8466c Tidy up.
llvm-svn: 114062
2010-09-16 03:28:18 +00:00
Zhongxing Xu 2cd7a78c76 Introduce new CFGElement hierarchy to support C++ CFG, based on Marcin's patch
and discussions with Ted and Jordy.

llvm-svn: 114056
2010-09-16 01:25:47 +00:00
Ted Kremenek 7b31a61d10 Relax assertion in CFG builder when processing ForStmts. This fixes an assertion failure
on code containing GNU statement expressions reported in PR 8141.

llvm-svn: 113953
2010-09-15 07:01:20 +00:00
Ted Kremenek e97b1ebef1 Add CFG::BuildOptions class to pass in CFG builder options under on parameter. Patch by Marcin Świderski!
llvm-svn: 113898
2010-09-14 23:41:16 +00:00
Ted Kremenek 8abff774aa Fix CFGBuilder crash reported in PR 8141.
llvm-svn: 113826
2010-09-14 01:13:32 +00:00
Ted Kremenek 35965b972e Remove from the CFG the half-implemented support for scoping information. We decided that scope information doesn't belong in the CFG at all, since it is a lexical construct.
Patch by Marcin Świderski!

llvm-svn: 113798
2010-09-13 22:25:54 +00:00
Ted Kremenek ed12f1b9f9 Add ObjCAtSynchronizedStmt to the CFG and add GRExprEngine support (PreVisit for checkers).
llvm-svn: 113572
2010-09-10 03:05:33 +00:00
Ted Kremenek f146cd1fa3 Remove stray ';' and convert tabs to spaces.
llvm-svn: 113466
2010-09-09 02:57:48 +00:00
Ted Kremenek b037185b52 Add 'filtered_pred_iterator' and 'filtered_succ_iterator' to CFGBlock. This allows a client
to selectively walk successors/predecessors based on commonly used filters.  For starters, add
a filter to ignore 'default:' cases for SwitchStmts when all enum values are covered by CaseStmts.

llvm-svn: 113449
2010-09-09 00:06:04 +00:00
Zhongxing Xu 33dfc07b00 FinishBlock() is essentially doing nothing except returning '!badCFG'.
llvm-svn: 113149
2010-09-06 07:32:31 +00:00
Zhongxing Xu b1e10aa670 Simplify CFG construction: bail out early when we have a bad CFG.
llvm-svn: 113148
2010-09-06 07:04:06 +00:00
Ted Kremenek 0f5d8bc5fc Improve CFG printing support for CXXOperatorCallExpr and CXXBindTemporaryExpr.
llvm-svn: 112619
2010-08-31 18:47:37 +00:00
Ted Kremenek 128d04dfe8 Explicitly handle CXXOperatorCallExpr when building CFGs. We should treat it the same as CallExprs.
Fixes: <rdar://problem/8375510> [Boost] CFGBuilder crash in Boost.Graph
llvm-svn: 112618
2010-08-31 18:47:34 +00:00
Douglas Gregor 79a2788512 Revert my lame attempt at appeasing the CFGBuilder
llvm-svn: 112580
2010-08-31 05:36:56 +00:00
Douglas Gregor f5d453d067 Teach the CFGBuilder not do die on CXXBindTemporaryExpr, CXXOperatorCallExpr. Fixes a Boost.Graph crasher.
llvm-svn: 112578
2010-08-31 05:10:27 +00:00
Ted Kremenek 82bfc86792 Explicitly handle CXXExprWithTemporaries during CFG construction by just visiting the subexpression. While we don't do anything intelligent right now, this obviates a bogus -Wunreahable-code warning reported in PR 6130.
llvm-svn: 112334
2010-08-28 00:19:02 +00:00
John McCall e302792b61 GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.

llvm-svn: 112047
2010-08-25 11:45:40 +00:00
Ted Kremenek 4f2ab5a549 Fix horrible CFG bug caused by a series of NullStmts appearing at the beginning of a do...while loop. This would cause
the body of the DoStmt to be disconnected from the preceding code.

llvm-svn: 111283
2010-08-17 21:00:06 +00:00
Ted Kremenek 110974dfa4 CFGBuilder: don't create the empty "loop back" block for DoStmts if the loop edge can never be taken.
llvm-svn: 111282
2010-08-17 20:59:56 +00:00
Ted Kremenek 60fa657aa2 Fix CFGBuilder to not blow out the stack when processing deeply nested CaseStmts. Fixes <rdar://problem/8268753>.
llvm-svn: 110286
2010-08-04 23:54:30 +00:00
Ted Kremenek dc03bd0894 Add 'AnalysisContext::getUnoptimizedCFG()' to allow clients to get access to the original
CFG without any edges pruned out because of trivially solvable conditions (e.g., 'if (0)').

llvm-svn: 110085
2010-08-02 23:46:59 +00:00
Zhongxing Xu ea9fcffe03 Make addStmt always add stmt. Delegate other cases to Visit() directly.
llvm-svn: 105384
2010-06-03 06:43:23 +00:00
Zhongxing Xu 41cdf585c2 CFG: add all LHS of assingments as lvalue. This improves support for C++ reference. Patch by Jordy.
llvm-svn: 105383
2010-06-03 06:23:18 +00:00
Ted Kremenek 304a9537e1 Fix crash in CFG construction for 'break' statements appearing in statement expressions
within the increment code of a for loop.

llvm-svn: 104375
2010-05-21 20:30:15 +00:00
Ted Kremenek ecc31c93c2 Don't add a null successor to a CFGBlock when the contents of an @synchronized statement is empty.
Fixes <rdar://problem/7979430>.

llvm-svn: 103717
2010-05-13 16:38:08 +00:00