summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BasicObjCFoundationChecks.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove some uses of TypedViewRegion, and use getBaseRegion() in a context whereTed Kremenek2009-07-291-8/+5
| | | | | | we don't care about ElementRegions layered on top of a base region. llvm-svn: 77484
* Refactor 'PostStmt' and 'PreStmt' to subclass a common parent 'StmtPoint'.Ted Kremenek2009-07-221-13/+14
| | | | | | | | | | | | Educate GRExprEngine::VisitGraph() about 'PreStmt'. Mark the constructor of 'PostStmt' to be explicit, preventing implicit conversions and the selection of the wrong 'generateNode' method in GRStmtNodeBuilder. Constify a bunch of arguments, which falls out of the changes to ProgramPoint. llvm-svn: 76809
* Add basic checking for passing NULL to CFRetain/CFRelease, since those functionsTed Kremenek2009-07-141-3/+79
| | | | | | | are not explicitly marked as not accepting NULL pointers. This check illustrates how we need more refactoring in the custom-check logic. llvm-svn: 75570
* This patch includes a conceptually simple, but very intrusive/pervasive change. Steve Naroff2009-07-101-19/+12
| | | | | | | | | | | | The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches. This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic. By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks. llvm-svn: 75314
* Move clients over from using GRStateManager::BindXXX and friends toTed Kremenek2009-06-181-26/+15
| | | | | | GRState->bindXXX and friends (and constify some arguments along the way). llvm-svn: 73740
* As discussed with Ted, rename TypedRegion::getObjectType() to Zhongxing Xu2009-05-091-1/+1
| | | | | | TypedRegion::getValueType(). llvm-svn: 71321
* rename: MemRegion:Zhongxing Xu2009-05-091-1/+1
| | | | | | | | | RValueType => ObjectType LValueType => LocationType No functionality change. llvm-svn: 71304
* get a CodeTextRegion when visiting FunctionDecl reference.Zhongxing Xu2009-04-201-2/+2
| | | | | | get FunctionDecl with more general utility method. llvm-svn: 69570
* Rename AnonTypedRegion to TypedViewRegion.Ted Kremenek2009-03-011-1/+1
| | | | llvm-svn: 65764
* Overhaul BugReporter interface and implementation. The new interface cleans upTed Kremenek2009-02-041-138/+48
| | | | | | | | | | | | | | | | | | | | | the ownership of BugTypes and BugReports. Now BugReports are owned by BugTypes, and BugTypes are owned by the BugReporter object. The major functionality change in this patch is that reports are not immediately emitted by a call to BugReporter::EmitWarning (now called EmitReport), but instead of queued up in report "equivalence classes". When BugReporter::FlushReports() is called, it emits one diagnostic per report equivalence class. This provides a nice cleanup with the caching of reports as well as enables the BugReporter engine to select the "best" path for reporting a path-sensitive bug based on all the locations in the ExplodedGraph that the same bug could occur. Along with this patch, Leaks are now coalesced into a common equivalence class by their allocation site, and the "summary" diagnostic for leaks now reports the allocation site as the location of the bug (this may later be augmented to also provide an example location where the leak occurs). llvm-svn: 63796
* MemRegion:Ted Kremenek2008-12-131-3/+6
| | | | | | | | | | | | | | | | | | | | | | - Overhauled the notion of "types" for TypedRegions. We now distinguish between the "lvalue" of a region (via getLValueRegion()) and the "rvalue" of a region (va getRValueRegion()). Since a region represents a chunk of memory it has both, but we were conflating these concepts in some cases, leading to some insidious bugs. - Removed AnonPointeeType, partially because it is unused and because it doesn't have a clear notion of lvalue vs rvalue type. We can add it back once there is a need for it and we can resolve its role with these concepts. StoreManager: - Overhauled StoreManager::CastRegion. It expects an *lvalue* type for a region. This is actually what motivated the overhaul to the MemRegion type mechanism. It also no longer returns an SVal; we can just return a MemRegion*. - BasicStoreManager::CastRegion now overlays an "AnonTypedRegion" for pointer-pointer casts. This matches with the MemRegion changes. - Similar changes to RegionStore, except I've added a bunch of FIXMEs where it wasn't 100% clear where we should use TypedRegion::getRValueRegion() or TypedRegion::getLValueRegion(). AuditCFNumberCreate check: - Now blasts through AnonTypedRegions that may layer the original memory region, thus checking if the actually memory block is of the appropriate type. This change was needed to work with the changes to StoreManager::CastRegion. GRExprEngine::VisitCast: - Conform to the new interface of StoreManager::CastRegion. Tests: - None of the analysis tests fail now for using the "basic store". - Disabled the tests 'array-struct.c' and 'rdar-6442306-1.m' pending further testing and bug fixing. llvm-svn: 60995
* Rename Selector::getName() to Selector::getAsString(), and addChris Lattner2008-11-241-2/+2
| | | | | | | | | | | | | a new NamedDecl::getAsString() method. Change uses of Selector::getName() to just pass in a Selector where possible (e.g. to diagnostics) instead of going through an std::string. This also adds new formatters for objcinstance and objcclass as described in the dox. llvm-svn: 59933
* Added method "getSelfRegion" to Store. This method returns the region ↵Ted Kremenek2008-10-241-1/+1
| | | | | | associated with the "this" or "self" object (C++ and Objective-C respectively). llvm-svn: 58107
* - constify some uses of MemRegion* (MemRegion should be immutable).Ted Kremenek2008-10-171-3/+3
| | | | | | | | | - Added new region "SymbolicRegion", which maps symbol values to the region domain. - Enhanced BasicStore::getFieldLValue() to return a FieldRegion (using SymbolicRegion) - Added some utility methods to GRState for fetch svals from the store. - Fixed regression in CheckNSError (we weren't getting the value bound to the parameter) llvm-svn: 57717
* This patch did the following renaming. There should be no functional changes.Zhongxing Xu2008-10-171-11/+11
| | | | | | | | | | RVal => SVal LVal => Loc NonLVal => NonLoc lval => loc nonlval => nonloc llvm-svn: 57671
* This is a big patch, but the functionality change is small and the rest of ↵Ted Kremenek2008-10-041-5/+11
| | | | | | | | | | | | | | the patch consists of deltas due to API changes. This patch overhauls the "memory region" abstraction that was prototyped (but never really used) as part of the Store.h. This patch adds MemRegion.h and MemRegion.cpp, which defines the class MemRegion and its subclasses. This classes serve to define an abstract representation of memory, with regions being layered on other regions to to capture the relationships between fields and variables, variables and the address space they are allocated in, and so on. The main motivation of this patch is that key parts of the analyzer assumed that all value bindings were to VarDecls. In the future this won't be the case, and this patch removes lval::DeclVal and replaces it with lval::MemRegionVal. Now all pieces of the analyzer must reason about abstract memory blocks instead of just variables. There should be no functionality change from this patch, but it opens the door for significant improvements to the analyzer such as field-sensitivity and object-sensitivity, both which were on hold until the memory abstraction got generalized. The memory region abstraction also allows type-information to literally be affixed to a memory region. This will allow the some now redundant logic to be removed from the retain/release checker. llvm-svn: 57042
* The checks in BasicObjCFoundationChecks now have a category: "API Misuse ↵Ted Kremenek2008-09-211-3/+10
| | | | | | (Apple)" llvm-svn: 56403
* Change implementation of NSError** coding-style check to be invoked at the ↵Ted Kremenek2008-09-181-1/+4
| | | | | | end of the retain/release analysis. llvm-svn: 56312
* Remove dead method.Ted Kremenek2008-08-291-1/+0
| | | | llvm-svn: 55526
* Rename ValueState -> GRState.Ted Kremenek2008-08-131-20/+20
| | | | | | Rename ValueStateManager -> GRStateManager. llvm-svn: 54721
* More #include cleaningDaniel Dunbar2008-08-111-0/+1
| | | | | | | | - Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h - Moved Sema::getCurMethodDecl() out of line (dependent on ObjCMethodDecl via dyn_cast). llvm-svn: 54629
* change more instances of QualType::getCanonicalType to callChris Lattner2008-07-261-2/+1
| | | | | | ASTContext::getCanonicalType instead (PR2189) llvm-svn: 54105
* Moved registration of basic path-sensitive checks from GRSimpleVals.cpp to ↵Ted Kremenek2008-07-221-0/+15
| | | | | | GRExprEngineInternalChecks.cpp. llvm-svn: 53909
* Added path-sensitive checking for null pointer values passed to function ↵Ted Kremenek2008-07-221-4/+5
| | | | | | | | arguments marked nonnull. This implements <rdar://problem/6069935> llvm-svn: 53891
* Refactored most of the "Store" piece of ValueState into a Store type. TheTed Kremenek2008-07-101-3/+3
| | | | | | | | | current store implementation is now encapsulated by BasicStore. These changes prompted some long due constification of ValueState. Much of the diffs in this patch include adding "const" qualifiers. llvm-svn: 53423
* Added a simple static analysis check to look for improper uses of ↵Ted Kremenek2008-06-261-0/+257
| | | | | | CFCreateNumber. llvm-svn: 52799
* - Move ObjC Expresssion AST's from Expr.h => ExprObjC.hSteve Naroff2008-05-291-0/+1
| | | | | | - #include ExprObjC.h in many places llvm-svn: 51703
* fix warning with gcc 4.1 (ptr to bool convertion)Nuno Lopes2008-05-201-2/+2
| | | | llvm-svn: 51324
* Do not highlight bogus ranges for leaks.Ted Kremenek2008-05-011-1/+2
| | | | llvm-svn: 50549
* More cleanups with ObjCQualifiedIdType in the static analyzer.Ted Kremenek2008-04-301-8/+8
| | | | llvm-svn: 50503
* Teach more of the static analyzer about ObjCQualifiedIdType.Ted Kremenek2008-04-301-4/+1
| | | | llvm-svn: 50494
* Gracefully handle when the receiver of a message expression is not a pointer ↵Ted Kremenek2008-04-191-1/+5
| | | | | | type. llvm-svn: 49959
* Generalize caching mechanism for bugs reports. Now individual BugTypesTed Kremenek2008-04-181-1/+1
| | | | | | | | can decide the policy on how to cache related bugs. This allows us to properly to handle warning about multiple leaks in the same location in the ref count checker (not yet done). llvm-svn: 49918
* Simplified internal logic of BugReporter, consolidating EmitWarning andTed Kremenek2008-04-181-1/+1
| | | | | | | | EmitPathWarning into one method. We now properly handle emitting warnings without a PathDiagnosticClient when the warning does not involve a particular statement. llvm-svn: 49884
* Hooked up the dead-store checker to the BugReporter interface. Now dead-storeTed Kremenek2008-04-141-25/+10
| | | | | | warnings are emitted as part of the warnings registered by GRSimpleVals. llvm-svn: 49658
* Fixed regressions in error reporting due to copy-paste errors (using the "begin"Ted Kremenek2008-04-101-0/+7
| | | | | | | iterator instead of "end") and not implementing "getDescription()" for Nil argument checks. llvm-svn: 49485
* Major refactoring/cleanup of GRExprEngine, ExplodedGraph, and BugReporter.Ted Kremenek2008-04-091-43/+49
| | | | | | | | | | | | | | | Bugs are now reported using a combination of "BugType" (previously BugDescription) and Bug "BugReport" objects, which are fed to BugReporter (which generates PathDiagnostics). This provides a far more modular way of registering bug types and plugging in diagnostics. GRExprEngine now owns its copy of GRCoreEngine, and is not owned by the ExplodedGraph. ExplodedGraph is no longer templated on the "checker", but instead on the state contained in the nodes. llvm-svn: 49453
* Added investigate patch for an occasionally failing assertion (heisenbug?)Ted Kremenek2008-04-031-2/+5
| | | | llvm-svn: 49193
* Hooked up GRSimpleAPICheck and the simple Objective-C Foundation checks to useTed Kremenek2008-04-031-59/+85
| | | | | | the new BugReporter interface. llvm-svn: 49180
* Added skeleton checking for NSString's method initWithFormat: (do not pass ↵Ted Kremenek2008-03-281-3/+12
| | | | | | | | nil). This won't be useful in most cases right now because the analyzer isn't tracking expected types for an object, and [NSString alloc] just runs "id". llvm-svn: 48917
* Expanded NSString checking to check for nil for a few more methods.Ted Kremenek2008-03-271-31/+92
| | | | llvm-svn: 48898
* Add line SourceLocation to NSString checks.Ted Kremenek2008-03-271-10/+24
| | | | | | Added test case to test warning about passing 'nil' to NSString's compare: method. llvm-svn: 48896
* Hooked up initial NSString interface checking to GRSimpleVals.Ted Kremenek2008-03-271-9/+37
| | | | llvm-svn: 48895
* Add creation of BasicObjCFoundationChecks when running GRSimpleVals from the ↵Ted Kremenek2008-03-271-0/+10
| | | | | | driver. llvm-svn: 48886
* Added "GRAuditor" and "GRSimpleAPICheck" interface to allow simple stateless ↵Ted Kremenek2008-03-271-0/+139
checkers to be injected into the analyzer. Added "AnnotatedPath" class to record an annotated path that will be useful for inspecting paths. Added some boilerplate code for simple checks of Apple's Foundation API. llvm-svn: 48867
OpenPOWER on IntegriCloud