aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
AgeCommit message (Collapse)Author
2009-02-10BugReporter: Use llvm::raw_string_stream instead of std::ostringstream.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64259 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07Use BugReport::getDescription() for the compiler warning text.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64038 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04Overhaul BugReporter interface and implementation. The new interface cleans upTed Kremenek
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-01-27PathDiagnostics:Ted Kremenek
- Add the distinction between the 'bug type' and the 'bug description' HTMLDiagnostics: - Output the bug type field as HTML comments scan-build: - Use the bug type field instead of the bug description for the HTML table. - Radar filing now automatically picks up the bug description in the title (addresses <rdar://problem/6265970>) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63084 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24More hacking on static analyzer diagnostics. When emitting summary ↵Ted Kremenek
diagnostics the code paths for diagnostics involving paths or single locations are now unified. This patch also constifies many arguments/methods that are touched by this logic, leading to a nice overall code cleanup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62903 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23Output summary diagnostic for each bug report.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23Added virtual method DiagnosticClient::IncludeInDiagnosticCounts(). This is ↵Ted Kremenek
used by Diagnostics to determine if a diagnostic sent to a given DiagnosticClient should be included in the count of diagnostics. The default implementation of this method returns 'true'. Implemented DiagCollector::IncludeInDiagnosticCounts() to return 'false' so that the batching of diagnostics for use with BugReporter doesn't mess up the count of real diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62873 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16more SourceLocation lexicon change: instead of referring to theChris Lattner
"logical" location, refer to the "instantiation" location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62316 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-20Fix <rdar://problem/6454568>: BugReporter should correctly handle switch ↵Ted Kremenek
statements with no default case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61270 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05Rename SymbolID to SymbolRef. This is a precursor to some overhauling of ↵Ted Kremenek
the representation of symbolic values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60575 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner
uses of getName() with uses of getDeclName(). This upgrades a bunch of diags to take DeclNames instead of std::strings. This also tweaks a couple of diagnostics to be cleaner and changes CheckInitializerTypes/PerformInitializationByConstructor to pass around DeclarationNames instead of std::strings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59947 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18This reworks some of the Diagnostic interfaces a bit to change how diagnosticsChris Lattner
are formed. In particular, a diagnostic with all its strings and ranges is now packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a ton of random stuff. This has the benefit of simplifying the interface, making it more extensible, and allowing us to do more checking for things like access past the end of the various arrays passed in. In addition to introducing DiagnosticInfo, this also substantially changes how Diagnostic::Report works. Instead of being passed in all of the info required to issue a diagnostic, Report now takes only the required info (a location and ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to stuff strings and ranges into the DiagnosticInfo with the << operator. When the dtor runs on the DiagnosticInfo object (which should happen at the end of the statement), the diagnostic is actually emitted with all of the accumulated information. This is a somewhat tricky dance, but it means that the accumulated DiagnosticInfo is allowed to keep pointers to other expression temporaries without those pointers getting invalidated. This is just the minimal change to get this stuff working, but this will allow us to eliminate the zillions of variant "Diag" methods scattered throughout (e.g.) sema. For example, instead of calling: Diag(BuiltinLoc, diag::err_overload_no_match, typeNames, SourceRange(BuiltinLoc, RParenLoc)); We will soon be able to just do: Diag(BuiltinLoc, diag::err_overload_no_match) << typeNames << SourceRange(BuiltinLoc, RParenLoc)); This scales better to support arbitrary types being passed in (not just strings) in a type-safe way. Go operator overloading?! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18eliminate dependence of strange "Diagnostic::Report" method, Chris Lattner
delete huge trailing whitespace to fit in 80 cols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59497 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17This patch did the following renaming. There should be no functional changes.Zhongxing Xu
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-06Use DeclStmt::decl_iterator instead of using Decl::getDecl(). Soon ↵Ted Kremenek
DeclStmts will wrap group of Decls. Added FIXME. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57189 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04This is a big patch, but the functionality change is small and the rest of ↵Ted Kremenek
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-09-20Add "category" to BugTypes, allowing bugs to be grouped.Ted Kremenek
Changed casing of many bug names. The convention will be to have bug names (mostly) lower cased, and categories use some capitalization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56385 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16ProgramPoint now takes the space of two pointers instead of one. This change wasTed Kremenek
motivated because it became clear that the number of subclasses of ProgramPoint would expand and we ran out of bits to represent a pointer variant. As a plus of this change, BlockEdge program points can now be represented explicitly without using a cache of CFGBlock* pairs in CFG. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-12Add missing spaces in path diagnostics.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56166 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23adjust to changes in various APIs from LLVM. We can't printChris Lattner
an APInt directly to an ostream now, so add some hacks. It would be better to switch all of the bugreport (and friends) stuff over to raw_ostream. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55264 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17various updates to match r54873 on mainline.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13Rename ValueState -> GRState.Ted Kremenek
Rename ValueStateManager -> GRStateManager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54721 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14Refactor Dead Stores error reporting to use the simplified ↵Ted Kremenek
BugReporter::EmitBasicReport interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53573 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14Added method "EmitBasicReport" to BugReporter to simplify the emission of ↵Ted Kremenek
simple bug diagnostics. Refactored error reporting in CheckObjCDealloc and CheckObjCInstMethSignature to use this new bug reporting interface (major code simplification). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53560 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10Refactored most of the "Store" piece of ValueState into a Store type. TheTed Kremenek
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-03Have BugReporter::getCFG and BugReporter::getLiveVariables returns pointers ↵Ted Kremenek
instead of references, because they can both fail on functions we cannot construct full CFGs for yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53081 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02Refactored some of the BugReporter interface so that data such as the ↵Ted Kremenek
ASTContext&, PathDiagnosticClient*, can be provided by an external source. Split BugReporter into BugReporter and GRBugReporter so checkers not based on GRExprEngine can still use the BugReporter mechanism. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53048 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20Modified the dead stores checker to...Ted Kremenek
1) Check if a dead store appears as a subexpression. For such cases, we emit a verbose diagnostic so that users aren't confused. This addresses: <rdar://problem/5968508> checker gives misleading report for dead store in loop 2) Don't emit a dead store warning when assigning a null value to a pointer. This is a common form of defensive programming. We may wish to make this an option to the the checker one day. This addresses the feature request in the following email: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-June/001978.html git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52555 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18Added a new ProgramPoint: PostPurgeDeadSymbols. This new program point ↵Ted Kremenek
distinguishes between the cases when we just evaluated the transfer function of a Stmt* (PostStmt) or performed a load (PostLoad). This solves a caching bug observed in a recent bug report. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52443 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17Fix non-termination bug reported by Thomas Clement!Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52426 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-22Prototyped support in the BugReporter to emit diagnostics of the form "p now ↵Ted Kremenek
aliases q". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51453 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16Partitioned BugTypeCachedLocation::isCached() into two methods: one that ↵Ted Kremenek
accepts and ExplodedNode, and the other that accepts a ProgramPoint. The default behavior is to cache bug reports by the location they occur (the end node). Subclasses can override this behavior by providing a different ProgramPoint. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51197 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06More refactorings in GeneratePathDiagnostic: use ExecutionContinues to displayTed Kremenek
"Execution continues..." message, which does a better job at handling corner cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50751 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02Rename member variable.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01Added line number diagnostics to indicate the allocation site of the leaked ↵Ted Kremenek
object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50553 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01Do not highlight bogus ranges for leaks.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50549 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30added preliminary diagnostics in scan-build results to denote whetherTed Kremenek
a CF memory leak occurred with GC enabled, etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50507 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25Fix bug in BugReporter where we didn't handle emitting diagnostics forTed Kremenek
empty CFGBlocks that only contained a terminator. Added improved diagnostics for break and continue statements and default branches in switch statements. This fixes <rdar://problem/5889244>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50286 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25Don't emit empty strings for path diagnostics when taking the default branch ↵Ted Kremenek
of a switch statement that has no label. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50242 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25Do a better job at computing dead symbols.Ted Kremenek
Implemented support for better localized leaks in the CF reference count checker. Now leaks should be flagged close to where they occur. This should implement the desired functionality in <rdar://problem/5879592>, although the diagnostics still need to be improved. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50241 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23For case statements involving enums, BugReporter now generates PathDiagnosticsTed Kremenek
that say that we are jumping to "case a" instead of "case 0". This is a feature implementation for <rdar://problem/5880430>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50197 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23Fix minor regression in bug report generation.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50195 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23When building PathDiagnostics for bug reports, generate a trimmed ↵Ted Kremenek
ExplodedGraph with a single path that BugReport objects can safely walk and introspect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50194 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22For default branches in switch statements with no default label, print outTed Kremenek
the line we are going to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50113 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22PathDiagnosticClients now retain ownership of passed PathDiagnostics, requiringTed Kremenek
them to not be stack-allocated. HTMLDiagnostics now batches PathDiagnostics before emitting HTML in its dtor. This is a workaround for a problem when we trampled the Preprocessor state when highlighting macros (sometimes resulting in an assertion failure). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50102 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18Another bug fix in emitting warnings without a path: construct a unit ↵Ted Kremenek
PathDiagnostic as we did before. This allows the HTMLDiagnostic object to retrieve the bug type, bug description, etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49939 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18Reenable using the PathDiagnosticClient for BugReports without paths.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49934 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18Generalize caching mechanism for bugs reports. Now individual BugTypesTed Kremenek
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-18BugReport::VisitNode now takes BugReporter& instead of ASTContext&.Ted Kremenek
Shuffled around code in CFRefCount to better pair classes with implementation, and started adding subclasses of RangedBugReport to handle better diagnostics for reference count bugs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49889 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18Added null check.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49887 91177308-0d34-0410-b5e6-96231b3b80d8