summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFRefCount.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek2010-01-251-3790/+0
| | | | | | | | | | | | | | | | | | | | | | | | | (1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. llvm-svn: 94406
* Fix pasto.Benjamin Kramer2010-01-111-1/+1
| | | | llvm-svn: 93181
* Avoid use of deprecated functions (CStrInCStrNoCase and StringsEqualNoCase).Benjamin Kramer2010-01-111-12/+13
| | | | llvm-svn: 93175
* Add transfer functions support for visiting an Objective-C message ↵Ted Kremenek2009-12-221-4/+5
| | | | | | expression as an lvalue when the return type is a C++ reference. llvm-svn: 91926
* Use the FunctionDecl's result type to know exactly if it returns a reference.Zhongxing Xu2009-12-191-0/+10
| | | | llvm-svn: 91751
* Teach RetainSummaryManager::getSummary(FunctionDecl* FD) that ↵Ted Kremenek2009-12-161-1/+5
| | | | | | 'FD->getIdentifier()' will not always return a non-null IdentifierInfo*. llvm-svn: 91512
* update to match LLVM API change:Chris Lattner2009-12-151-4/+2
| | | | | | | | | Remove isPod() from DenseMapInfo, splitting it out to its own isPodLike type trait. This is a generally useful type trait for more than just DenseMap, and we really care about whether something acts like a pod, not whether it really is a pod. llvm-svn: 91422
* Add analysis support for blocks. This includes a few key changes:Ted Kremenek2009-12-071-1/+18
| | | | | | | | | | | | | | | | | - Refactor the MemRegion hierarchy to distinguish between different StackSpaceRegions for locals and parameters. - VarRegions for "captured" variables now have the BlockDataRegion as their super region (except those passed by reference) - Add transfer function support to GRExprEngine for BlockDeclRefExprs. This change also supports analyzing blocks as an analysis entry point (top-of-the-stack), which required pushing more context-sensitivity around in the MemRegion hierarchy via the use of LocationContext objects. Functionally almost everything is the same, except we track LocationContexts in a few more areas and StackSpaceRegions now refer to a StackFrameContext object. In the future we will need to modify MemRegionManager to allow multiple StackSpaceRegions in flight at once (for the analysis of multiple stack frames). llvm-svn: 90809
* Add value invalidation logic for block-captured variables. Conceptually ↵Ted Kremenek2009-12-031-2/+10
| | | | | | invoking a block (without specific reasoning of what the block does) can invalidate any value to it by reference when the block was created. llvm-svn: 90431
* Add batch version of 'StoreManager::InvalidateRegion()' for invalidating ↵Ted Kremenek2009-12-031-17/+32
| | | | | | multiple regions as once. After adopting this in the CFRefCount::EvalCall(), we see a reduction in analysis time of 1.5% when analyzing all of SQLite3. llvm-svn: 90405
* Hard bifurcate the state into nil receiver and non-nil receiver, so thatZhongxing Xu2009-12-021-22/+9
| | | | | | | | | | | we don't need to use the DoneEvaluation hack when check for ObjCMessageExpr. PreVisitObjCMessageExpr() only checks for undefined receiver or arguments. Add checker interface EvalNilReceiver(). This is a 'once-and-done' interface. llvm-svn: 90296
* Port BugReporter and BugType to StringRef.Benjamin Kramer2009-11-291-6/+6
| | | | llvm-svn: 90086
* lib/Analysis: Remove VISIBILITY_HIDDEN from definitions in anonymous namespaceKovarththanan Rajaratnam2009-11-281-26/+25
| | | | llvm-svn: 90028
* Add a PostVisitBlockExpr() method to RetainReleaseChecker to query forTed Kremenek2009-11-261-1/+27
| | | | | | | | the set of variables "captured" by a block. Until the analysis gets more sophisticated, for now we stop the retain count tracking of any objects (transitively) referenced by these variables. llvm-svn: 89929
* Refine MemRegions for blocks. Add a new region calledTed Kremenek2009-11-251-1/+1
| | | | | | | | | | | 'BlockDataRegion' to distinguish between the code associated with a block (which is represented by 'BlockTextRegion') and an instance of a block, which includes both code and data. 'BlockDataRegion' has an associated LocationContext, which can be used to eventually model the lifetime of a block object once LocationContexts can represent scopes (and iterations around a loop, etc.). llvm-svn: 89900
* Add a new RetainReleaseChecker class (that subclasses CheckerVisitor) to ↵Ted Kremenek2009-11-251-0/+22
| | | | | | extend the functionality of the retain/release checker using the new Checker interface. Pieces of CFRefCount will gradually be migrated to this new class over time. llvm-svn: 89889
* Move RegisterChecks() to the end of the file. No functionality change.Ted Kremenek2009-11-251-57/+59
| | | | llvm-svn: 89888
* Add really basic support for blocks in the retain/release checker. For now, ↵Ted Kremenek2009-11-251-3/+14
| | | | | | anytime we pass a tracked object to a block call we stop tracking it. llvm-svn: 89831
* Refactor NilReceiverStructRet and NilReceiverLargerThanVoidPtrRet into Zhongxing Xu2009-11-241-0/+10
| | | | | | CallAndMessageChecker. llvm-svn: 89745
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* Pull static variable within function (for slightly faster startup time).Ted Kremenek2009-11-131-2/+4
| | | | llvm-svn: 87065
* retain/release checker: refactor some of the summary lookup logic for ↵Ted Kremenek2009-11-131-288/+293
| | | | | | instance method summaries. No real functionality change, but it paves the way for new enhancements. llvm-svn: 87062
* Rename: StripCasts describes what it does better. Zhongxing Xu2009-11-101-1/+1
| | | | | | getBaseRegion will be used in another method. llvm-svn: 86649
* Change GRTransferFuncs::RegisterChecks() to take a GRExprEngine& instead of ↵Ted Kremenek2009-11-031-2/+4
| | | | | | a BugReporter&. This paves the way for pulling some of the retain/release checker into a "Checker" class. llvm-svn: 85971
* Move 'static inline' functions GetNullarySelector() and GetUnarySelector() ↵Ted Kremenek2009-11-031-14/+0
| | | | | | from CFRefCount.cpp to ASTContext.h. These functions are likely to be generally useful. llvm-svn: 85886
* retain/release checker: CGBitmapContextCreateWithData() returns an owned object.Ted Kremenek2009-11-031-1/+4
| | | | llvm-svn: 85867
* retain/release checker: Add special handling of CGBitmapContextCreateWithData().Ted Kremenek2009-11-031-0/+11
| | | | | Fixes: <rdar://problem/7358899> llvm-svn: 85864
* retain/release checker: allow 'new', 'copy', 'alloc', 'init' prefix to start ↵Ted Kremenek2009-10-201-4/+6
| | | | | | | before '_' when determining Cocoa fundamental rule. Fixes: <rdar://problem/7265711> llvm-svn: 84569
* PR5218: Replace IdentifierInfo::getName with StringRef version, now that clientsDaniel Dunbar2009-10-181-1/+1
| | | | | | are updated. llvm-svn: 84447
* Move clients to use IdentifierInfo::getNameStart() instead of getName()Daniel Dunbar2009-10-181-1/+1
| | | | llvm-svn: 84436
* Simplify more.Daniel Dunbar2009-10-171-9/+5
| | | | llvm-svn: 84342
* Simplify.Daniel Dunbar2009-10-171-25/+4
| | | | llvm-svn: 84341
* retain/release checker: Stop tracking reference counts for any symbols ↵Ted Kremenek2009-10-161-8/+7
| | | | | | | | touched by StoreManager::InvalidateRegion(). This fixes <rdar://problem/7257223> and <rdar://problem/7283470>. llvm-svn: 84223
* Educate the retain/release checker about [NSCursor dragCopyCursor].Ted Kremenek2009-10-151-0/+5
| | | | | | This fixes <rdar://problem/7306898> llvm-svn: 84213
* retain/release checker: Use simpler utility method for creating class method ↵Ted Kremenek2009-10-151-7/+5
| | | | | | summaries. No functionality change. llvm-svn: 84210
* Remove stale comment.Ted Kremenek2009-10-141-3/+1
| | | | llvm-svn: 84157
* retain/release checker: Recognize that calls toTed Kremenek2009-10-141-3/+26
| | | | | | | | | | 'CVPixelBufferCreateWithPlanarBytes()' and 'CVPixelBufferCreateWithBytes' (Core Video API) can indirectly release a pixel buffer object via a callback. This fixes <rdar://problem/7283567>. llvm-svn: 84064
* retain/release checker: retained objects passed to pthread_create (asTed Kremenek2009-10-131-1/+7
| | | | | | | | the data argument) should not be tracked further until we support full IPA. (fixes <rdar://problem/7299394>) llvm-svn: 84047
* Fix bad grammar in static analyzer diagnostic. Reported by Robert Purves!Ted Kremenek2009-10-011-2/+2
| | | | llvm-svn: 83204
* Fix:Ted Kremenek2009-09-271-1/+1
| | | | | | | | | | | | | | | | <rdar://problem/6914474> checker doesn't realize that variable might have been assigned if a pointer to that variable was passed to another function via a structure The problem here was the RegionStoreManager::InvalidateRegion didn't invalidate the bindings of invalidated regions. This required a rewrite of this method using a worklist. As part of this fix, changed ValueManager::getConjuredSymbolVal() to require a 'void*' SymbolTag argument. This tag is used to differentiate two different symbols created at the same location. llvm-svn: 82920
* Fix: <rdar://problem/7242015> [RegionStore] variable passed-by-reference ↵Ted Kremenek2009-09-221-8/+9
| | | | | | (via integer) to function call not invalidated llvm-svn: 82523
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-7/+7
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Fix: <rdar://problem/5905851> do not report a leak when post-dominated by a callTed Kremenek2009-09-141-0/+4
| | | | | | to a noreturn or panic function llvm-svn: 81803
* Make AnalysisManager stateless. Now other analyzer components only depends onZhongxing Xu2009-09-101-5/+5
| | | | | | local node information. llvm-svn: 81433
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-638/+637
| | | | llvm-svn: 81346
* retain/release checker: [CIContext createCGImage...] and friends returned CFTed Kremenek2009-08-281-5/+8
| | | | | | | objects that are not automatically garbage collected. This fixes <rdar://problem/7174400>. llvm-svn: 80387
* Rename 'bindExpr' to 'BindExpr'.Ted Kremenek2009-08-271-5/+5
| | | | llvm-svn: 80294
* Simplify 'Environment' to contain only one map from 'const Stmt*' to SVals, ↵Ted Kremenek2009-08-271-5/+5
| | | | | | greatly simplifying the logic of the analyzer in many places. We now only distinguish between block-level expressions and subexpressions in Environment::RemoveDeadBindings and GRState pretty-printing. llvm-svn: 80194
* Remove CodeDecl and CFG from GRExprEngine and GRStateManager.Zhongxing Xu2009-08-251-7/+7
| | | | | | | Now AnalysisManager is the only place we can get CodeDecl. This leads to an API change: GRState::bindExpr() now takes the CFG argument. llvm-svn: 79980
* Remove Decl and CFG from ExplodedGraph. This leads to a series small changes.Zhongxing Xu2009-08-251-1/+1
| | | | llvm-svn: 79973
OpenPOWER on IntegriCloud