Граф коммитов

36 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek cf118d41f7 Overhaul BugReporter interface and implementation. The new interface cleans up
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).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 23:49:09 +00:00
Ted Kremenek 6eddeb1534 MemRegion:
- 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 21:49:13 +00:00
Chris Lattner 077bf5e2f4 Rename Selector::getName() to Selector::getAsString(), and add
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59933 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 03:33:13 +00:00
Ted Kremenek 9deb0e35de Added method "getSelfRegion" to Store. This method returns the region associated with the "this" or "self" object (C++ and Objective-C respectively).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58107 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 20:32:16 +00:00
Ted Kremenek 993f1c7291 - constify some uses of MemRegion* (MemRegion should be immutable).
- 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)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57717 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 20:28:54 +00:00
Zhongxing Xu 1c96b24285 This patch did the following renaming. There should be no functional changes.
RVal => SVal
LVal => Loc
NonLVal => NonLoc
lval => loc
nonlval => nonloc


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57671 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 05:57:07 +00:00
Ted Kremenek 9e24049bef This is a big patch, but the functionality change is small and the rest of 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 05:50:14 +00:00
Ted Kremenek b344f91f00 The checks in BasicObjCFoundationChecks now have a category: "API Misuse (Apple)"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-21 19:01:39 +00:00
Ted Kremenek cfdf9b4edf Change implementation of NSError** coding-style check to be invoked at the end of the retain/release analysis.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56312 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-18 21:25:13 +00:00
Ted Kremenek d70900be3c Remove dead method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55526 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-29 03:55:31 +00:00
Ted Kremenek 4adc81e540 Rename ValueState -> GRState.
Rename ValueStateManager -> GRStateManager.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54721 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 04:27:00 +00:00
Daniel Dunbar c4a1dea2dc More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 05:35:13 +00:00
Chris Lattner b77792eabf change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54105 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 22:17:49 +00:00
Ted Kremenek 78d46242e3 Moved registration of basic path-sensitive checks from GRSimpleVals.cpp to GRExprEngineInternalChecks.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53909 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-22 16:21:24 +00:00
Ted Kremenek 584def7364 Added path-sensitive checking for null pointer values passed to function arguments marked nonnull.
This implements <rdar://problem/6069935>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53891 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-22 00:46:16 +00:00
Ted Kremenek 4323a57627 Refactored most of the "Store" piece of ValueState into a Store type. The
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53423 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 22:03:41 +00:00
Ted Kremenek 04bc87683a Added a simple static analysis check to look for improper uses of CFCreateNumber.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 23:59:48 +00:00
Steve Naroff f494b579b2 - Move ObjC Expresssion AST's from Expr.h => ExprObjC.h
- #include ExprObjC.h in many places


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51703 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 21:12:08 +00:00
Nuno Lopes f74279447d fix warning with gcc 4.1 (ptr to bool convertion)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51324 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 17:33:56 +00:00
Ted Kremenek bb77e9b908 Do not highlight bogus ranges for leaks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50549 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 22:50:36 +00:00
Ted Kremenek c1ff3cd5fe More cleanups with ObjCQualifiedIdType in the static analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50503 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 22:48:21 +00:00
Ted Kremenek c0c3f5dbc9 Teach more of the static analyzer about ObjCQualifiedIdType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 20:17:27 +00:00
Ted Kremenek 6bdafbfec5 Gracefully handle when the receiver of a message expression is not a pointer type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49959 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-19 19:12:50 +00:00
Ted Kremenek 95cc1bae89 Generalize caching mechanism for bugs reports. Now individual BugTypes
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).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49918 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 20:54:29 +00:00
Ted Kremenek 75840e1501 Simplified internal logic of BugReporter, consolidating EmitWarning and
EmitPathWarning into one method.  We now properly handle emitting warnings
without a PathDiagnosticClient when the warning does not involve a particular
statement.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49884 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 01:56:37 +00:00
Ted Kremenek d2f642b56e Hooked up the dead-store checker to the BugReporter interface. Now dead-store
warnings are emitted as part of the warnings registered by GRSimpleVals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49658 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-14 17:39:48 +00:00
Ted Kremenek 4d35dacf85 Fixed regressions in error reporting due to copy-paste errors (using the "begin"
iterator instead of "end") and not implementing "getDescription()" for Nil
argument checks.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49485 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 16:05:13 +00:00
Ted Kremenek 50a6d0ce34 Major refactoring/cleanup of GRExprEngine, ExplodedGraph, and BugReporter.
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49453 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-09 21:41:14 +00:00
Ted Kremenek 7956f754f8 Added investigate patch for an occasionally failing assertion (heisenbug?)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49193 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-03 21:44:24 +00:00
Ted Kremenek f1ae705460 Hooked up GRSimpleAPICheck and the simple Objective-C Foundation checks to use
the new BugReporter interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-03 17:57:38 +00:00
Ted Kremenek 8730e130ab Added skeleton checking for NSString's method initWithFormat: (do not pass 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".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48917 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-28 16:09:38 +00:00
Ted Kremenek 4ba6283f9c Expanded NSString checking to check for nil for a few more methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48898 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-27 22:05:32 +00:00
Ted Kremenek 9b3fdeaca3 Add line SourceLocation to NSString checks.
Added test case to test warning about passing 'nil' to NSString's compare: method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48896 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-27 21:23:57 +00:00
Ted Kremenek e5d5c204c7 Hooked up initial NSString interface checking to GRSimpleVals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48895 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-27 21:15:17 +00:00
Ted Kremenek 527556184b Add creation of BasicObjCFoundationChecks when running GRSimpleVals from the driver.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48886 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-27 17:17:22 +00:00
Ted Kremenek 99c6ad3f22 Added "GRAuditor" and "GRSimpleAPICheck" interface to allow simple stateless 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48867 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-27 07:25:52 +00:00