Zhongxing Xu
a1a9ba11b7
Let StackFrameContext represent if the call expr is evaluated as lvalue.
...
This is required for supporting const reference to temporary objects.
llvm-svn: 120093
2010-11-24 13:08:51 +00:00
Zhongxing Xu
9b6e6b087f
print asLValue attribute of CFGStmt.
...
llvm-svn: 120086
2010-11-24 06:33:02 +00:00
Zhanyong Wan
b5d11c127a
Refactor AddStmtChoice to make it easier to use; also add comments on how the class works. Reviewed by kremenek.
...
llvm-svn: 120080
2010-11-24 03:28:53 +00:00
Zhanyong Wan
59f09c7483
Stylistic changes to CFG.cpp:
...
1. "no 'else' after 'return'" -- this is for conformance with the
coding standards.
2. move 'else' to the line of the previous '}' -- this is for consistency.
Reviewed by kremenek.
llvm-svn: 119983
2010-11-22 19:32:14 +00:00
Zhanyong Wan
6dace61730
Fix PR8419. Reviewed by kremenek and xuzhongxing.
...
llvm-svn: 119960
2010-11-22 08:45:56 +00:00
Anders Carlsson
a369f8dc3a
The 'X' printf type has a valid alternative form. Fixes PR8641.
...
llvm-svn: 119946
2010-11-21 18:34:21 +00:00
Ted Kremenek
18fb1665bf
Remove invalid assertion from CFG builder. When building the CFG pieces for a ternary '?' expression,
...
it is possible for the confluence block to only have a single predecessor due to calls to 'noreturn'
functions. Fixes assertion failure reported in PR 8619.
llvm-svn: 119284
2010-11-15 22:59:22 +00:00
Zhongxing Xu
fee455fcf5
Revert r118991.
...
Elidable CXXConstructExpr should inhibit calling destructor for temporary
that is copied, not the one created. This is because eliding copy constructor
means that the object that was to be copied will be constructed directly in
memory the copy would be constructed in.
llvm-svn: 119044
2010-11-14 15:23:50 +00:00
Zhongxing Xu
1b038fa00f
Do not add implicit dtors for CXXBindTemporaryExpr with elidable
...
CXXConstructExpr.
llvm-svn: 118991
2010-11-13 07:30:59 +00:00
Anders Carlsson
3fd50319d3
Don't warn when matching %p to nullptr.
...
llvm-svn: 118344
2010-11-06 14:58:53 +00:00
Zhongxing Xu
fb2f8164ae
Do not add elidable CXXConstructExpr as block-level expr.
...
llvm-svn: 118165
2010-11-03 11:14:06 +00:00
Marcin Swiderski
3ab17ad8ec
Added generating destructors for temporary objects. Two cases I know of, that are not handled properly:
...
1. For statement: const C& c = C(0) ?: C(1) destructors generated for condition will not differ from those generated for case without prolonged lifetime of temporary,
2. There will be no destructor for constant reference member bound to temporary at the exit from constructor.
llvm-svn: 118158
2010-11-03 06:19:35 +00:00
Zhongxing Xu
e1dbeb28da
Explicitly handle CXXBindTemporaryExpr, CXXFunctionalCastExpr,
...
and ImplicitCastExpr to propagate asLValue AddStmtChoice property.
But do not propagate AlwaysAdd property.
llvm-svn: 117909
2010-11-01 13:04:58 +00:00
Zhongxing Xu
0b51d4db8c
Make all CXXConstructExpr's block-level expressions. This is required by
...
method inlining. Temporarily fail a test case.
llvm-svn: 117907
2010-11-01 06:46:05 +00:00
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
Ted Kremenek
12a37de003
Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
...
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints.
Patch by Justin Bogner!
llvm-svn: 116996
2010-10-21 04:00:58 +00:00
John McCall
1c9c3fd50a
Death to blocks, or at least the word "block" in one particular obnoxiously
...
ambiguous context.
llvm-svn: 116567
2010-10-15 04:57:14 +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
99a9040a1f
Added two new command line arguments:
...
-cfg-add-implicit-dtors - sets CFG::BuildOptions::AddImplicitDtors for AnalysisCosumer to true,
-cfg-add-initializers - sets CFG::BuildOptions::AddInitializers for AnalysisCosumer to true.
llvm-svn: 115142
2010-09-30 07:41:24 +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
Michael J. Spencer
09476212de
Revert "CMake: Update to use standard CMake dependency tracking facilities instead"
...
This reverts commit r113631
Conflicts:
CMakeLists.txt
lib/CodeGen/CMakeLists.txt
llvm-svn: 113817
2010-09-13 23:54:41 +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
Michael J. Spencer
0881f4a367
CMake: Update to use standard CMake dependency tracking facilities instead
...
of whatever we were using before...
llvm-svn: 113631
2010-09-10 21:13:16 +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
Douglas Gregor
c9199f522f
Clean up CMake dependencies
...
llvm-svn: 113489
2010-09-09 15:44:58 +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
f2b0a1bfa0
Enhance -Wunreachable-code to not consider the 'default:' branch of a switch statement live if a switch on an enum value has
...
explicit 'case:' statements for each enum value.
llvm-svn: 113451
2010-09-09 00:06:10 +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
52ac860d9c
Delete the relaxedLiveness object in the dtor of AnalysisContext.
...
llvm-svn: 112380
2010-08-28 18:59:04 +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
Tom Care
e5aa30c722
Add alternate version of LiveVariables analysis that does not kill liveness at assignments. This 'relaxed' liveness is useful in path sensitive analysis for situations where the resulting extended liveness allows us to find some bugs.
...
- Added killAtAssign flag to LiveVariables
- Added relaxed LiveVariables to AnalysisContext with an accessor
llvm-svn: 112306
2010-08-27 22:30:10 +00:00
Tom Care
9a68bccd0c
Add missing null checks in PseudoConstantAnalysis
...
llvm-svn: 112100
2010-08-25 22:46:03 +00:00
Tom Care
82b2a1dada
Improved the handling of blocks and block variables in PseudoConstantAnalysis
...
- Removed the assumption that __block vars are all non-constant
- Simplified some repetitive code in RunAnalysis
- Added block walking support
- Code/comments cleanup
- Separated out test for block pseudoconstants
llvm-svn: 112098
2010-08-25 22:37:26 +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
5f0c066062
Fix printf format string checking for '%lc' (which expects a wint_t or compatible argument). Fixes PR 7981.
...
llvm-svn: 111978
2010-08-24 22:24:51 +00:00
Tom Care
a460311710
Improvements to IdempotentOperationChecker and its use of PseudoConstantAnalysis
...
- 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
2010-08-24 21:09:07 +00:00
Tom Care
e332c3b762
Several small changes to PseudoConstantAnalysis and the way 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
2010-08-23 19:51:57 +00:00
Eli Friedman
04831926ec
Detabify.
...
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
Tom Care
b9933f365e
Added psuedo-constant analysis and integrated it into the false positive 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
2010-08-18 21:17:24 +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
Tom Care
ec389da6f2
Fix a bug where child statements could not be identified as being in a CFGBlock in CFGStmtMap::getBlock.
...
llvm-svn: 110881
2010-08-11 23:36:58 +00:00
Ted Kremenek
8a297e9f27
Remove bonehead redeclaration.
...
llvm-svn: 110288
2010-08-05 00:03:46 +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
0950212b50
Add CFGStmtMap, which defines a mapping from Stmt* to CFGBlock*. The immediate intended use is in the unreachable code analysis.
...
llvm-svn: 110230
2010-08-04 18:23:15 +00:00
Ted Kremenek
4a2b237967
Add -cc1 option '-unoptimized-cfg' to toggle using a CFG (for static analysis) that doesn't prune CFG edges.
...
llvm-svn: 110087
2010-08-03 00:09:51 +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
Michael J. Spencer
2c35bc1232
Revert r109428 "Hoist argument type checking into CheckFormatHandler. This is prep for scanf format"
...
Got errors about ASTContext being undefined with Visual Studio 2010.
llvm-svn: 109491
2010-07-27 04:46:02 +00:00
Dan Gohman
28ade550f4
Fix namespace polution.
...
llvm-svn: 109440
2010-07-26 21:25:24 +00:00
Ted Kremenek
df4472bca0
Hoist argument type checking into CheckFormatHandler. This is prep for scanf format
...
string argument type checking.
llvm-svn: 109428
2010-07-26 19:45:54 +00:00
Zhongxing Xu
adf644d05e
Make a bunch of new data structures for the new analysis
...
engine of the new translation unit. State marshal is there but no real
work is done. End nodes are passed back.
llvm-svn: 109105
2010-07-22 13:52:13 +00:00
Ted Kremenek
4407ea4948
Hookup checking for invalid length modifiers in scanf format strings.
...
llvm-svn: 108907
2010-07-20 20:04:47 +00:00
Ted Kremenek
ea28f83a5f
Move 'hasValidLengthModifier' from PrintfFormatSpecifier to FormatSpecifier.
...
llvm-svn: 108906
2010-07-20 20:04:42 +00:00
Ted Kremenek
36521956f7
Cleanup whitespace in switch statement. No functionality change.
...
llvm-svn: 108905
2010-07-20 20:04:36 +00:00
Ted Kremenek
f03e6d85a1
Add 'ConversionSpecifier' root class in 'analyze_format_string' namespace and
...
derived 'PrintfConversionSpecifier' from this class. We will do the same for
'ScanfConversionSpecifier'.
llvm-svn: 108903
2010-07-20 20:04:27 +00:00
Ted Kremenek
348d1499c1
Rename 'UnicodeStrArg' to 'SArg'.
...
llvm-svn: 108901
2010-07-20 20:04:15 +00:00
Ted Kremenek
516ef222ba
Rename 'ConsumedSoFarArg' -> 'nArg' and 'OutIntPtrArg' to 'nArg' (scanf and printf checking).
...
llvm-svn: 108900
2010-07-20 20:04:10 +00:00
Ted Kremenek
1ce32be36a
Rename 'VoidPtrArg' to 'pArg' in printf/scanf checking.
...
llvm-svn: 108899
2010-07-20 20:04:04 +00:00
Ted Kremenek
563e3edbc2
Rename 'CStrArg' to 'sArg' for printf checking to match with the analagous enum for scanf checking.
...
llvm-svn: 108898
2010-07-20 20:03:58 +00:00
Ted Kremenek
ab0fe8a48d
Rename analyze_printf::ConversionSpecifier::IntAsCharArg to 'cArg' to match
...
analagous enum in analyze_scanf. This is prep for refactoring the logic for handling
ConversionSpecifiers for both scanf and printf.
llvm-svn: 108897
2010-07-20 20:03:49 +00:00
Ted Kremenek
5c3e1b9a54
Add missing conversion specifier parsing for 'u', 'x', 'o', and 's'. Fixes <rdar://problem/8204052>.
...
llvm-svn: 108742
2010-07-19 19:47:40 +00:00
Zhongxing Xu
84f65e0692
Reapply r108617.
...
llvm-svn: 108668
2010-07-19 01:31:21 +00:00
Chris Lattner
ad4f38b1a9
BUILD_ARCHIVE is the default for libraries, no need to set it.
...
llvm-svn: 108633
2010-07-18 00:14:47 +00:00
Benjamin Kramer
e2e031ed6f
Revert r108617, it broke the build.
...
llvm-svn: 108621
2010-07-17 13:51:58 +00:00
Zhongxing Xu
4ca4a999b1
Prepare the analyzer for the callee in another translation unit:
...
Let AnalysisContext contain a TranslationUnit.
Let CallEnter refer to an AnalysisContext instead of a FunctionDecl.
llvm-svn: 108617
2010-07-17 11:12:42 +00:00
Ted Kremenek
d7b31cc60d
Hook up warning for an incomplete scanlist in scanf format strings.
...
llvm-svn: 108542
2010-07-16 18:28:03 +00:00
Ted Kremenek
a1ef09407d
Add the main scanf-parsing logic that I meant to include in my previous commit.
...
llvm-svn: 108502
2010-07-16 02:11:31 +00:00