Commit Graph

873 Commits

Author SHA1 Message Date
Ted Kremenek 0203db73ee Fix PR 2514: Do not flag dead initializations for variables initialized to a constant global variable.
llvm-svn: 64149
2009-02-09 18:01:00 +00:00
Ted Kremenek eae2a0eb8f Fix null dereference.
llvm-svn: 64044
2009-02-07 22:54:59 +00:00
Ted Kremenek 2a4028b728 For retain/release leaks, have the BugReport description indicate the allocation site and initial bindings.
llvm-svn: 64041
2009-02-07 22:38:00 +00:00
Ted Kremenek 79f955bfed Tidy up bug descriptions.
llvm-svn: 64039
2009-02-07 22:37:02 +00:00
Ted Kremenek 252b90ece6 Use BugReport::getDescription() for the compiler warning text.
llvm-svn: 64038
2009-02-07 22:36:41 +00:00
Ted Kremenek 008242f6ea Determining the allocation site for a leak when constructing a CFRefLeakReport. This avoids repeated calls to GetAllocationSite when Profiling a CFRefLeakReport object.
llvm-svn: 64036
2009-02-07 22:19:59 +00:00
Ted Kremenek 14036554d2 Split logic for 'getEndPath()' for CFRefReport and CFRefLeakReport.
llvm-svn: 64034
2009-02-07 22:04:05 +00:00
Ted Kremenek da545836f0 Convert a use of 'std::ostringstream' to 'llvm::raw_string_ostream'.
llvm-svn: 64033
2009-02-07 21:59:45 +00:00
Mike Stump 1f36fb1de0 Ensure that we assert if given an unhandled value.
llvm-svn: 64004
2009-02-07 03:46:08 +00:00
Ted Kremenek 5d7662cfe0 GRExprEngine: When processing compound assignments, do a switch table lookup to get the non-compound opcode from the compound opcode instead of relying on the order of BinaryOperator::opcode values. This unbreaks the misc-ps.c test.
llvm-svn: 63991
2009-02-07 00:52:24 +00:00
Zhongxing Xu e42755334c SymbolicRegions really have unknown sizes.
llvm-svn: 63929
2009-02-06 08:51:30 +00:00
Zhongxing Xu dec48a50df Create ElementRegion when the base is SymbolicRegion. This is like what we do
for FieldRegion. This enables us to track more values.

Simplify SymbolicRegion::getRValueType(). We assume the symbol always has
pointer type.

llvm-svn: 63928
2009-02-06 08:44:27 +00:00
Chris Lattner b05f49e7fd handle fatal errors, rely on warnings to point out missing cases.
llvm-svn: 63913
2009-02-06 03:57:44 +00:00
Ted Kremenek 0ca23d3f73 Add 'AppendValue' to the list of magic CF function names that cause a tracked object to escape. Fixes <rdar://problem/6560661>.
llvm-svn: 63891
2009-02-05 22:34:53 +00:00
Zhongxing Xu 9103df1688 Make SymbolicRegion subclass TypedRegion, for symbols usually have types, so
do the symblic regions associated with them and we need them to be typed.

Current SymbolicRegion::getRValueType() method is very restricting. It may be
modified when we are more clear about what could be the types of symblic
regions.

BasicConstraintManager::Assume() is changed due to that now SymblicRegion is a
subclass of SubRegion.
 

llvm-svn: 63844
2009-02-05 06:57:29 +00:00
Ted Kremenek 400aae7fa4 Remove a bunch of obscene double-buffering of BugReports in the retain/release
checker. This was previously needed because BugReport objects were previously
allocated on the stack and not owned by BugReporter. Now we can just issue them
on the fly. This change was motivated because we were seeing some weird cases
where some really long paths would get issued for bugs (particularly leaks)
because of some double-caching.

llvm-svn: 63840
2009-02-05 06:50:21 +00:00
Ted Kremenek fb379b2660 Fix regression: Leak (BugType) object should have 'isLeak()' return true.
llvm-svn: 63803
2009-02-05 00:38:00 +00:00
Ted Kremenek fc5d067ea0 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).

llvm-svn: 63796
2009-02-04 23:49:09 +00:00
Zhongxing Xu 6d5fe08e1b Remove dead code.
llvm-svn: 63715
2009-02-04 02:30:11 +00:00
Chris Lattner e4ad417664 make SM::getColumnNumber take a predecomposed FileID/offset, which
makes it clear to clients that they have to pick an instantiation
or spelling location before calling it and allows optimization based
on that.

llvm-svn: 63698
2009-02-04 00:55:58 +00:00
Ted Kremenek 378e7fd330 Fix horrible non-termination bug in LiveVariables. The issue was that
the liveness state of block-level expressions could oscillate because
of two issues:
- The initial value before a merge was not always set to "Top"
- The set of live block-level expressions is a union, not an intersection

This fixes <rdar://problem/650084>.

llvm-svn: 63421
2009-01-30 21:35:30 +00:00
Ted Kremenek 0b0a64830a Move method out-of-line.
llvm-svn: 63412
2009-01-30 19:27:39 +00:00
Douglas Gregor ddb2485eb6 Switch Type::isAggregateType to use the C++ definition of "aggregate
type" rather than the C definition. We do this because both C99 and
Clang always use "aggregate type" as "aggregate or union type", and
the C++ definition includes union types.

llvm-svn: 63395
2009-01-30 17:31:00 +00:00
Chris Lattner 34beb046ea update for change in API.
llvm-svn: 63363
2009-01-30 01:58:33 +00:00
Ted Kremenek 7594e2a59a Fix a couple bugs:
- NonLoc::MakeVal() would use sizeof(unsigned) (literally) instead of consulting
  ASTContext for the size (in bits) of 'int'. While it worked, it was a
  conflation of concepts and using ASTContext.IntTy is 100% correct.
- RegionStore::getSizeInElements() no longer assumes that a VarRegion has the
  type "ConstantArray", and handles the case when uses use ordinary variables
  as if they were arrays.
- Fixed ElementRegion::getRValueType() to just return the rvalue type of its
  "array region" in the case the array didn't have ArrayType.
- All of this fixes <rdar://problem/6541136>

llvm-svn: 63347
2009-01-30 00:08:43 +00:00
Ted Kremenek ed90de4caa retain/release checker: When generating summaries for CF/CG functions, allow arguments to "escape" if they are passed to a function containing the terms "InsertValue", "SetValue", or "AddValue". This fixes <rdar://problem/6539791>.
llvm-svn: 63341
2009-01-29 22:45:13 +00:00
Chris Lattner 60f36223a9 move library-specific diagnostic headers into library private dirs. Reduce
redundant #includes.  Patch by Anders Johnsen!

llvm-svn: 63271
2009-01-29 05:15:15 +00:00
Ted Kremenek b4dd3f8685 Remove '#if 0' code.
llvm-svn: 63250
2009-01-28 22:35:55 +00:00
Ted Kremenek 2e561dd491 Remove method 'AddNE' from the public interface of ConstraintManager.
llvm-svn: 63249
2009-01-28 22:27:59 +00:00
Ted Kremenek c783209605 retain/release checker: Always generate an "autorelease" summary for an "autorelease" message, and have the summary processing logic treat it as a no-op in GC mode. This change is motivated to encode more of the semantics in the summaries themselves for eventual better diagnostics.
llvm-svn: 63241
2009-01-28 21:44:40 +00:00
Ted Kremenek 4daeccf28f retain/release checker: Improve diagnostics to indicate that CF objects are not automatically garbage collected.
llvm-svn: 63187
2009-01-28 06:25:48 +00:00
Ted Kremenek f0ec316a04 retain/release checker: Indicate whether a tracked object is a Core Foundation or Objective-C object.
llvm-svn: 63186
2009-01-28 06:06:36 +00:00
Ted Kremenek bdaa384453 retain/release checker: More diagnostic refactoring.
llvm-svn: 63184
2009-01-28 06:01:42 +00:00
Ted Kremenek aeb115f93a retain/release checker: Embed an "object type" into the RetEffect/RetVal objects to help distinguish between Objective-C and Core Foundation objects (for better diagnostics).
llvm-svn: 63183
2009-01-28 05:56:51 +00:00
Ted Kremenek 21114f21c4 retain/release checker: More cleanups (no real functionality change).
llvm-svn: 63181
2009-01-28 05:29:13 +00:00
Ted Kremenek ff3c2bdfee Fix diagnostic truncated by my last patch.
llvm-svn: 63180
2009-01-28 05:18:08 +00:00
Ted Kremenek 758fda632b retain/release checker: More diagnostic refactoring.
llvm-svn: 63179
2009-01-28 05:15:02 +00:00
Ted Kremenek c4118ac79c retain/release checker: Output the name of the function that allocates an object.
llvm-svn: 63178
2009-01-28 05:06:46 +00:00
Ted Kremenek 424c61ff6d Refactor some diagnostic code to use raw_string_ostream. No functionality change.
llvm-svn: 63177
2009-01-28 04:47:13 +00:00
Ted Kremenek 99ae4120d6 Remove '#if 0' code.
llvm-svn: 63176
2009-01-28 04:37:52 +00:00
Chris Lattner 7368d581c1 Split the single monolithic DiagnosticKinds.def file into one
.def file for each library.  This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.

Patch by Anders Johnsen!

llvm-svn: 63111
2009-01-27 18:30:58 +00:00
Ted Kremenek 422d81dcd4 Fix bug in BasicStore::getLValueElement where if the base of an array subscript expression was an ElementRegion we stacked another ElementRegion on top of that.
This fixes PR 3422.

llvm-svn: 63110
2009-01-27 18:29:03 +00:00
Chris Lattner f1ca7d3e02 Introduce a new PresumedLoc class to represent the concept of a location
as reported to the user and as manipulated by #line.  This is what __FILE__,
__INCLUDE_LEVEL__, diagnostics and other things should follow (but not 
dependency generation!).  

This patch also includes several cleanups along the way: 

- SourceLocation now has a dump method, and several other places 
  that did similar things now use it.
- I cleaned up some code in AnalysisConsumer, but it should probably be
  simplified further now that NamedDecl is better.
- TextDiagnosticPrinter is now simplified and cleaned up a bit.

This patch is a prerequisite for #line, but does not actually provide 
any #line functionality.

llvm-svn: 63098
2009-01-27 07:57:44 +00:00
Ted Kremenek a3f462e49a PathDiagnostics:
- 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>)

llvm-svn: 63084
2009-01-27 01:53:39 +00:00
Sebastian Redl 54cb4c88e1 Correct size assumption; fixes a crash on amd64.
llvm-svn: 63031
2009-01-26 19:54:12 +00:00
Ted Kremenek e9193283c6 Use tag classes instead of typedefs for GDM entries 'ConstNotEq' and 'ConstEq'. This avoids collisions in the GDM.
llvm-svn: 63002
2009-01-26 06:04:53 +00:00
Eli Friedman 7139af42ce Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more
accurately states what the function is trying to do and how it is 
different from Expr::isEvaluatable.  Also get rid of a parameter that is both 
unused and inaccurate.

llvm-svn: 62951
2009-01-25 02:32:41 +00:00
Ted Kremenek b3fcaa7a77 Fix crash ElementRegion::getRValueType() when the RvalueType of the ArrayRegion is a typedef and not (directly) a pointer.
llvm-svn: 62909
2009-01-24 06:11:36 +00:00
Ted Kremenek f08ac278ed More hacking on static analyzer diagnostics. When emitting summary 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.
llvm-svn: 62903
2009-01-24 00:55:43 +00:00
Ted Kremenek 864ead2076 Output summary diagnostic for each bug report.
llvm-svn: 62885
2009-01-23 22:22:49 +00:00
Ted Kremenek ea06ec1cad Added virtual method DiagnosticClient::IncludeInDiagnosticCounts(). This is 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.

llvm-svn: 62873
2009-01-23 20:28:53 +00:00
Zhongxing Xu e37f9afb2e Implement retrieval of the default value of element and field regions.
llvm-svn: 62847
2009-01-23 11:22:12 +00:00
Zhongxing Xu 804f26a60a Now this comment should be resolved. See the comments for the KillSet.
llvm-svn: 62846
2009-01-23 10:42:17 +00:00
Zhongxing Xu 570e088e4b When getting the element region type, we should get the rvalue type of the super
region. Otherwise we would get an extra level of pointer type.

llvm-svn: 62844
2009-01-23 10:19:29 +00:00
Ted Kremenek 2e1dfe25c5 For now, return UnknownVal() in RegionStore::getElementsSize() for AnonTypedRegions. It wasn't really doing the right thing and was crashing on rdar-6442306-1.m. This fix causes all path-sensitive test cases to pass with RegionStore.
llvm-svn: 62816
2009-01-22 23:56:56 +00:00
Ted Kremenek fe0f1788ca Add RegionStore support for the implicit object region that 'self' references. This causes tests 'ObjCProperties.m' and 'refcnt_naming.m' to now pass with RegionStore.
llvm-svn: 62814
2009-01-22 23:43:57 +00:00
Ted Kremenek 92d48a71f5 Fix RegionStore::getLValueElement() to handle the case when the base region is not an ElementRegion (also do some cleanups of its core logic).
This gets array-struct.c to work with RegionStore.

llvm-svn: 62781
2009-01-22 20:27:48 +00:00
Ted Kremenek 2dd9c9cbd7 SymbolReaper::isLive(SymbolRef) now always returns true for SymbolRegionRvalues because these represent the symbolic values for parameters/globals upon entry to the function. These values are always ;live' because they represent constraints on the context of how the function was called. This will be useful for both summary generation but is also necessary to get RegionStore's lazy-binding of locations to symbols to work in practice with RemoveDeadBindings.
llvm-svn: 62771
2009-01-22 18:51:33 +00:00
Ted Kremenek 74040833e4 Static analyzer: Remove a bunch of outdated SymbolData objects and
their associated APIs.  We no longer need separate SymbolData objects
for fields, variables, etc.  Instead, we now associated symbols with
the "rvalue" of a MemRegion (i.e., the value stored at that region).
Now we only have two kinds of SymbolData objects: SymbolRegionRValue
and SymbolConjured.

This cleanup also makes the distinction between a SymbolicRegion and a
symbolic value that is a location much clearer.  A SymbolicRegion
represents a chunk of symbolic memory, while a symbolic location is
just a "pointer" with different possible values.  Without any specific
knowledge, a symbolic location resolves (i.e., via a dereference) to a
SymbolicRegion.  In the future, when we do better alias reasoning, a
symbolic location can become an alias for another location, thus
merging the constraints on the referred SymbolicRegion with the other
region.

llvm-svn: 62769
2009-01-22 18:23:34 +00:00
Ted Kremenek 1322ca1364 Combine two branches into one. No functionality change.
llvm-svn: 62727
2009-01-21 22:58:50 +00:00
Ted Kremenek 16fbfe699e Static Analyzer: Replace LiveSymbols/DeadSymbols sets with a new object called "SymbolReaper". Right now it just consolidates the two and cleans up some client code, but shortly it will be used to enable "lazy computation" of live symbols for use with RegionStore.
llvm-svn: 62722
2009-01-21 22:26:05 +00:00
Ted Kremenek fe32cc0ba6 Get RegionStore to work with the retain/release checker and its test cases.
Because the RegionStore can reason about values beyond the reasoning power of BasicStore, this patch splits some of the test cases for the retain/release checker to have versions that are handled by RegionStore (more warnings) and BasicStore (less warnings).

llvm-svn: 62667
2009-01-21 06:57:53 +00:00
Douglas Gregor 6e6ad602e5 Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.

Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.

The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.

llvm-svn: 62562
2009-01-20 01:17:11 +00:00
Ted Kremenek e5fe617e2b Dead stores checker: Fix <rdar://problem/6506065> by being more selective when say that a store is dead even though the computed value is used in the enclosing expression.
llvm-svn: 62552
2009-01-20 00:47:45 +00:00
Ted Kremenek 1ab188f48a Fix analyzer crash found when scanning Wine sources where the analyzer used old logic to determine the value of a switch 'case' label.
llvm-svn: 62395
2009-01-17 01:54:16 +00:00
Ted Kremenek 0755a34604 StringRegion::print: Remove copy/paste code and just call Stmt::printPretty() for the StringLiteral.
llvm-svn: 62340
2009-01-16 19:26:50 +00:00
Ted Kremenek 86afde337d Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using typedefs.
llvm-svn: 62331
2009-01-16 18:40:33 +00:00
Chris Lattner 8a42586c54 more SourceLocation lexicon change: instead of referring to the
"logical" location, refer to the "instantiation" location.

llvm-svn: 62316
2009-01-16 07:36:28 +00:00
Chris Lattner 53e384f633 Change some terminology in SourceLocation: instead of referring to
the "physical" location of tokens, refer to the "spelling" location.
This is more concrete and useful, tokens aren't really physical objects!

llvm-svn: 62309
2009-01-16 07:00:02 +00:00
Daniel Dunbar 435bbe0254 Fix some unused variable, control reaches end of non-void function,
and uninitialized use options.

llvm-svn: 62270
2009-01-15 18:32:35 +00:00
Zhongxing Xu 2436f86024 add a fixme.
llvm-svn: 62142
2009-01-13 03:07:41 +00:00
Zhongxing Xu cff637a568 Add KillStruct to region store.
- put the killed region in the kill set.
 - set its default value to unknown.
 - removes all bindings for its subregions.  

llvm-svn: 62138
2009-01-13 01:49:57 +00:00
Ted Kremenek eb68db238f static analyzer: Handle casts from arrays to integers. This fixes PR 3297.
llvm-svn: 62130
2009-01-13 01:04:21 +00:00
Ted Kremenek 167f2fa5f4 Invert condition on branch (was causing RegionStore::ArrayToPointer to return 'unknown' on most cases.
llvm-svn: 62129
2009-01-13 01:03:27 +00:00
Ted Kremenek 7e90422e95 retain/release checker:
- Refactor a bunch of logic in the retain/release checker, making it more
  condense and easier to read.
- Add support for "Create" methods in the DiskArbitration framework

retain/release tests:
- Rename CFDate.m to retain-release.m, and move test from CFString.c to
  retain-release.m
- Add DiskArbitration framework tests cases.
- Add/refine and few more retain/release GC test cases.

llvm-svn: 62106
2009-01-12 21:45:02 +00:00
Ted Kremenek 890d44eb7f Dead stores checker: Don't flag dead stores for self-assignments (common escape hatch for 'unused variable' warnings).
llvm-svn: 62010
2009-01-09 22:15:01 +00:00
Zhongxing Xu 550c1c46f9 Add isSubRegionOf() method to SubRegion.
llvm-svn: 61924
2009-01-08 13:17:14 +00:00
Ted Kremenek f929b0aefe Update some doxygen comments to be more rich. Remove StoreManager::GetRegionSVal.
llvm-svn: 61894
2009-01-07 22:56:17 +00:00
Ted Kremenek 682c3a6dd6 Refactor MemRegionManager instance variable into parent class. No functionality change.
llvm-svn: 61888
2009-01-07 22:18:50 +00:00
Ted Kremenek 1d92d2c813 This commit reflects changes to the retain/release checker motivated by my
recent discussions with Thomas Clement and Ken Ferry concerning the "fundamental
rule" for Cocoa memory management
(http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html).

Here is the revised behavior of the checker concerning tracking retain/release
counts for objects returned from message expressions involving instance methods:

1) Track the returned object if the return type of the message expression is
id<..>, id, or a pointer to *any* object that subclasses NSObject. Such objects
are assumed to have a retain count. Previously the checker only tracked objects
when the receiver of the message expression was part of the standard Cocoa API
(i.e., had class names prefixed with 'NS'). This should significantly expand the
amount of checking performed.

2) Consider the object owned if the selector of the message expression contains
"alloc", "new", or "copy". Previously we also considered "create", but this
doesn't follow from the fundamental rule (discussions with the Cocoa folks
confirms this).

llvm-svn: 61837
2009-01-07 00:39:56 +00:00
Ted Kremenek 47ad37dbe4 Return UnknownVal in RegionStoreManager::getSizeInElements() for unsupported regions. This silences a warning when compiling Release-Asserts builds.
llvm-svn: 61818
2009-01-06 19:12:06 +00:00
Douglas Gregor c7acfdfe9a Add QualifiedDeclRefExpr, which retains additional source-location
information for declarations that were referenced via a qualified-id,
e.g., N::C::value. We keep track of the location of the start of the
nested-name-specifier. Note that the difference between
QualifiedDeclRefExpr and DeclRefExpr does have an effect on the
semantics of function calls in two ways:
  1) The use of a qualified-id instead of an unqualified-id suppresses
     argument-dependent lookup
  2) If the name refers to a virtual function, the qualified-id
  version will call the function determined statically while the
  unqualified-id version will call the function determined dynamically
  (by looking up the appropriate function in the vtable).

Neither of these features is implemented yet, but we do print out
qualified names for QualifiedDeclRefExprs as part of the AST printing.

llvm-svn: 61789
2009-01-06 05:10:23 +00:00
Ted Kremenek 2907ab7d77 Add a bunch of comments and FIXMEs.
llvm-svn: 61419
2008-12-24 07:46:32 +00:00
Zhongxing Xu c7a2792817 set region default value if there are not enough init values for array and struct.
llvm-svn: 61418
2008-12-24 07:29:24 +00:00
Ted Kremenek ae189ec1be Comment and fixup GDM entries for RegionStore to use unique 'tag classes' to identify GDM entries.
llvm-svn: 61409
2008-12-24 01:05:03 +00:00
Zhongxing Xu 4ee570a4cb Fix initialization order.
llvm-svn: 61333
2008-12-22 08:30:52 +00:00
Zhongxing Xu 5b0ae81ab1 Add an option to make 'RemoveDeadBindings' a configurable behavior. This enables
us to measure the effect of this optimization.

llvm-svn: 61319
2008-12-22 01:52:37 +00:00
Zhongxing Xu 40b0e50ffd Use utility method.
llvm-svn: 61304
2008-12-21 03:46:11 +00:00
Zhongxing Xu 303a6d4f11 Use utility methods. No functional change.
llvm-svn: 61300
2008-12-21 03:31:01 +00:00
Zhongxing Xu f97d95a782 Remove unused function.
llvm-svn: 61299
2008-12-21 03:26:05 +00:00
Douglas Gregor 2eedc3aa1c Add support for member references (E1.E2, E1->E2) with C++ semantics,
which can refer to static data members, enumerators, and member
functions as well as to non-static data members.

Implement correct lvalue computation for member references in C++. 
Compute the result type of non-static data members of reference type properly.

llvm-svn: 61294
2008-12-20 23:49:58 +00:00
Zhongxing Xu af7415ffb1 Lazy bingding for region-store manager.
* Now Bind() methods take and return GRState* because binding could
  also alter GDM.
* No variables are initialized except those declared with initial
  values.
* failed C test cases are due to bugs in RemoveDeadBindings(),
which removes constraints that is still alive. This will be fixed in later
patch.
* default value of array and struct regions will be implemented in later patch.

llvm-svn: 61274
2008-12-20 06:32:12 +00:00
Ted Kremenek 7d002beb5b Fix <rdar://problem/6454568>: BugReporter should correctly handle switch statements with no default case.
llvm-svn: 61270
2008-12-20 01:41:43 +00:00
Ted Kremenek 5b26c11f56 Fix regression when invalidating reference-counts for objects passed-by-reference to a function/method.
llvm-svn: 61224
2008-12-18 23:34:57 +00:00
Ted Kremenek 62d4c12d2c CF-retain/release checker:
- Fix regression reported in <rdar://problem/6452745>.  After a null check, null references to resources should not have a retain count.  This regression was caused by removing the call to "GRTransferFuncs::EvalAssume" in BasicConstraintManager.
- Added a test case to test this behavior.

llvm-svn: 61155
2008-12-17 21:50:35 +00:00
Ted Kremenek 300c9cc8c6 Fix <rdar://problem/6451816>:
- Because of the introduction of AnonTypedRegions when reasoning about casts, we
  had a regression in the "symbolication" of variable values passed-by-reference
  to a function. This is now fixed in CFRefCount.cpp (-checker-cfref) by
  blasting through the layer of AnonTypedRegions when symbolicating the value of
  the variable. This logic may get moved elsewhere. Note that this change
  affects only -checker-cfref and not -checker-simple; eventually this logic
  should get pulled out of CFRefCount.cpp into a more common place. All users
  use -checker-cfref by default, and -checker-simple should probably just be
  removed.  
- Updated test 'Analysis/uninit-vals-ps.c' to only use -checker-cfref and added
  a test case for this regression.

llvm-svn: 61147
2008-12-17 19:42:34 +00:00
Ted Kremenek 29d34ec64a Add pretty-printing for AnonTypedRegion.
llvm-svn: 61146
2008-12-17 19:25:50 +00:00
Ted Kremenek d9de9f148e Add new GRWorkList class that uses two queues:
- one queue (FIFO) to queue up nodes at block entrances
- another queue (LIFO) to queue up other nodes
- The idea is to explore basic blocks to completion, but to do a BFS exploration of blocks.

llvm-svn: 61106
2008-12-16 22:13:33 +00:00
Ted Kremenek 9e08ff40da ProgramPoint:
- Added four new ProgramPoint types that subclass PostStmt for use in
  GRExprEngine::EvalLocation:
  - PostOutOfBoundsCheckFailed
  - PostUndefLocationCheckFailed
  - PostNullCheckFailed
  - PostLocationChecksSucceed
  These were created because of a horribly subtle caching bug in EvalLocation
  where a node representing an "bug condition" in EvalLocation (e.g. a null
  dereference) could be re-used as the "non-bug condition" because the Store did
  not contain any information to differentiate between the two. The extra
  program points just disables any accidental caching between EvalLocation and
  its callers.

GRExprEngine:
- EvalLocation now returns a NodeTy* instead of GRState*.  This should be used as the "vetted" predecessor for EvalLoad/EvalStore.

llvm-svn: 61105
2008-12-16 22:02:27 +00:00
Zhongxing Xu c4a4c5f02d Implement RegionStoreManager::Remove().
llvm-svn: 61069
2008-12-16 02:36:30 +00:00
Ted Kremenek 4299d5d2d8 Fix regression in handling sizeof(void) in the static analyzer.
llvm-svn: 61039
2008-12-15 18:51:00 +00:00
Zhongxing Xu b0cc30ddb4 I think we should getRValueType here. The lvaluetype of an array region is 'pointer to array'.
llvm-svn: 61003
2008-12-14 03:14:52 +00:00
Ted Kremenek b5670fd555 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.

llvm-svn: 60995
2008-12-13 21:49:13 +00:00
Ted Kremenek f065b15f7d A series of cleanups/fixes motivated by <rdar://problem/6442306>:
GRExprEngine (VisitCast):
- When using StoreManager::CastRegion, always use the state and value it returns to generate the next node.  Failure to do so means that region values returned that don't require the state to be modified will get ignored.

MemRegion:
- Tighten the interface for ElementRegion.  Now ElementRegion can only be created with a super region that is a 'TypedRegion' instead of any MemRegion.  Code in BasicStoreManager/RegionStoreManager already assumed this, but it would result in a dynamic assertion check (and crash) rather than just having the compiler forbid the construction of such regions.
- Added ElementRegion::getArrayRegion() to return the 'typed version' of an ElementRegion's super region.
- Removed bogus assertion in ElementRegion::getType() that assumed that the super region was an AnonTypedRegion.  All that matters is that it is a TypedRegion, which is now true all the time by design.

BasicStore:
- Modified getLValueElement() to check if the 'array' region is a TypedRegion before creating an ElementRegion.  This conforms to the updated interface for ElementRegion.

RegionStore:
- In ArrayToPointer() gracefully handle things we don't reason about, and only create an ElementRegion if the array region is indeed a TypedRegion.

llvm-svn: 60990
2008-12-13 19:24:37 +00:00
Douglas Gregor 7a4fad1b0b Address some comments on the name lookup/DeclContext patch from Chris
llvm-svn: 60897
2008-12-11 20:41:00 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Zhongxing Xu 26776c2784 Identify AnonPointeeRegion by the symbol that is concretized.
llvm-svn: 60870
2008-12-11 09:08:46 +00:00
Zhongxing Xu 02fe71290a AnonPointeeRegions are now identified by the MemRegion of the pointer pointing
to them.

llvm-svn: 60868
2008-12-11 02:27:34 +00:00
Ted Kremenek 42a217f4c0 Fix to BasicStoreManager::getElementLValue: If the base region is a symbol, layer an AnonTypedRegion on top of it.
llvm-svn: 60808
2008-12-09 23:50:57 +00:00
Ted Kremenek 62cc9daae3 Have BasicStoreManager::getLValueElement() have logic similar to BasicStoreManager::getLValueField() (i.e., don't just return the 'base' as the SVal)
llvm-svn: 60795
2008-12-09 21:20:27 +00:00
Ted Kremenek 1857ff4e2c In GRExprEngine treat @throw as an 'abort' that ends the current path. This is a temporary solution.
llvm-svn: 60789
2008-12-09 20:18:58 +00:00
Zhongxing Xu 2e8123e5bb Add utility method. Remove an unused method.
llvm-svn: 60758
2008-12-09 10:51:19 +00:00
Ted Kremenek c28ce29a12 [static analyzer] Extend VLA size checking to look for undefined sizes.
llvm-svn: 60734
2008-12-09 00:44:16 +00:00
Ted Kremenek 6ee0a11814 Fixed LiveVariables bug where we didn't consider block-level expressions that functioned as the size of a VLA to be live.
llvm-svn: 60730
2008-12-09 00:14:14 +00:00
Ted Kremenek 8f7afdd21e Add checking for zero-sized VLAs.
llvm-svn: 60726
2008-12-08 22:47:34 +00:00
Ted Kremenek 96d2eecf85 'self.myIvar = nil' (properties) only releases myIvar when the property has kind 'assign'. This fixes <rdar://problem/6380411>.
llvm-svn: 60717
2008-12-08 21:44:15 +00:00
Ted Kremenek 69d78b9d98 Add bandaid transfer function support for assignments involving ObjCKVCRefExpr.
llvm-svn: 60622
2008-12-06 02:39:30 +00:00
Ted Kremenek c9e7622a52 Add SymbolRef::print() and have SymbolicRegion::print() use this method instead of calling SymbolRef::getNumber().
llvm-svn: 60578
2008-12-05 02:45:20 +00:00
Ted Kremenek 3cb81db1b2 Use trait-based profiling of SymbolRefs, avoiding calling getNumber() (which will soon be removed).
llvm-svn: 60577
2008-12-05 02:39:38 +00:00
Ted Kremenek d8242f19f7 Rename SymbolID to SymbolRef. This is a precursor to some overhauling of the representation of symbolic values.
llvm-svn: 60575
2008-12-05 02:27:51 +00:00
Ted Kremenek 8e942123cb Remove SymbolDataContentsOf (unused).
llvm-svn: 60572
2008-12-05 01:31:31 +00:00
Ted Kremenek d368de794a StoreManager::Retrieve and StoreManager::RemoveDeadBindings now take a GRState* argument instead of a Store. This allows them to use the GDM for storing other data.
llvm-svn: 60570
2008-12-05 00:47:52 +00:00
Ted Kremenek 677779ab36 Revamp RegionStoreManager::RemoveDeadBindings. This method now does a complete mark-and-sweep of the store, removing dead regions and recording the set of live and dead symbols appropriately.
llvm-svn: 60523
2008-12-04 02:08:27 +00:00
Ted Kremenek 8e8cc81aec Update comment.
llvm-svn: 60520
2008-12-04 02:06:04 +00:00
Zhongxing Xu 96c0fa8b42 Add comments.
llvm-svn: 60516
2008-12-04 01:12:41 +00:00
Ted Kremenek fff9f4aaaf BasicConstraintManager:
- Fix nonsensical logic in AssumeSymGE. When comparing 'sym >= constant' and the
  constant is the maximum integer value, add the constraint that 'sym ==
  constant' when the path is deemed feasible.  All other cases are feasible.
- Improve AssumeSymGT. When comparing 'sym > constant' and constant is the
  maximum integer value we know the path is infeasible.
- Add test case for this enhancement to AssumeSymGT.

llvm-svn: 60490
2008-12-03 19:06:30 +00:00
Ted Kremenek f935cfe277 BasicConstraintManager:
- Fix nonsensical logic in AssumeSymLE. When comparing 'sym <= constant' and the
  constant is the minimum integer value, add the constraint that 'sym ==
  constant' when the path is deemed feasible.  All other cases are feasible.
- Improve AssumeSymLT to address <rdar://problem/6407949>.  When comparing
  'sym < constant' and constant is the minimum integer value we know the
  path is infeasible.
- Add test case for <rdar://problem/6407949>.

llvm-svn: 60489
2008-12-03 18:56:12 +00:00
Sebastian Redl 6ef75e9ee8 Make RegionStoreManager::InitializeArray safe against array sizes that don't have pointer width.
This may be the case on 64-bit systems. Whether that fact is a bug is a different question, but it's easy to cure the symptom.

llvm-svn: 60422
2008-12-02 16:47:35 +00:00
Ted Kremenek 817737a002 Add FIXME.
llvm-svn: 60390
2008-12-02 01:26:07 +00:00
Zhongxing Xu d2fa1e0999 Add support for initializing array with string literal.
This fixes PR3127
http://llvm.org/bugs/show_bug.cgi?id=3127

llvm-svn: 60280
2008-11-30 05:49:49 +00:00
Zhongxing Xu 452273d9c6 To be consistent, make the index of the ElementRegion always signed.
llvm-svn: 60248
2008-11-29 12:05:04 +00:00
Zhongxing Xu e31a8ebfdc Fix a serious bug.
When initialized, the index of the ElementRegion was unsigned. But the index
value of the ArraySubscriptExpr is signed. This inconsistency caused the value
of the array element retrieved to be UnknownVal despite it was initialized to
symbolic.

This is only a hack. Real fix of this problem is required.

llvm-svn: 60207
2008-11-28 08:41:39 +00:00
Zhongxing Xu 33178a0993 Code cleanup. No functional change.
llvm-svn: 60206
2008-11-28 08:34:30 +00:00
Zhongxing Xu 85b6e201f4 Use std::make_pair instead of std::pair's ctor.
llvm-svn: 60205
2008-11-28 03:55:52 +00:00
Zhongxing Xu 59e2d41a8e Factory objects should not be temporary. It caches all objects in the set.
llvm-svn: 60151
2008-11-27 06:08:40 +00:00
Zhongxing Xu b670f294c9 RegionViewMap factory is actually not used. All GDMs should use factories from
GDMContext.

llvm-svn: 60150
2008-11-27 06:03:03 +00:00
Zhongxing Xu b94f440754 Add comments.
llvm-svn: 60146
2008-11-27 02:39:34 +00:00
Zhongxing Xu 16e3f0e03f Add support for pluggable components of static analyzer.
- Creator function pointers are saved in ManagerRegistry.
 - The Register* class is used to notify ManagerRegistry new module is 
   available.
 - AnalysisManager queries ManagerRegistry for configurable module. Then it
   passes them to GRExprEngine, in turn to GRStateManager.

llvm-svn: 60143
2008-11-27 01:55:08 +00:00
Nuno Lopes a1232e5d7f remove unused var
llvm-svn: 60018
2008-11-25 12:23:46 +00:00
Sebastian Redl f7cb84d771 Fix the fix of revision 59974. Now array-struct.c passes too.
llvm-svn: 59975
2008-11-24 19:39:40 +00:00
Sebastian Redl 81c1e1306c Fix crash of array bounds checking under 64-bit.
There might be other, similar bugs lurking there.

llvm-svn: 59974
2008-11-24 19:35:33 +00:00
Ted Kremenek 01c414c070 Remove FIXME comment.
llvm-svn: 59973
2008-11-24 19:27:06 +00:00
Zhongxing Xu 9165ed69af Add support for AllocaRegion extent with GDM.
One design problem that is emerging is the signed-ness problem during static
analysis. Many unsigned value have to be converted into signed value because
it partipates in operations with signed values. 

On the other hand, we cannot blindly make all values occuring in static analysis
signed, because we do have cases where unsignedness is required, for example,
integer overflow detection.

llvm-svn: 59957
2008-11-24 09:44:56 +00:00
Zhongxing Xu 1dffa8cd73 Add utility methods.
llvm-svn: 59956
2008-11-24 09:38:21 +00:00
Zhongxing Xu 6587c75488 Cleanup code with utility method.
llvm-svn: 59951
2008-11-24 07:02:06 +00:00
Chris Lattner f3d3faeca6 Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of
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.

llvm-svn: 59947
2008-11-24 05:29:24 +00:00
Zhongxing Xu f556cd6cb9 Strings are NULL terminated. So the region size should plus one.
llvm-svn: 59943
2008-11-24 05:16:01 +00:00
Chris Lattner 1cbaacc4a0 Migrate some stuff from NamedDecl::getName() to
NamedDecl::getNameAsString() to make it more explicit.

llvm-svn: 59937
2008-11-24 04:00:27 +00:00
Chris Lattner e4b95698df 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.

llvm-svn: 59933
2008-11-24 03:33:13 +00:00
Zhongxing Xu 8361d4c51b Add a comment about the signedness.
llvm-svn: 59932
2008-11-24 02:30:48 +00:00
Zhongxing Xu a61731dd0d Add getSize() support for StringRegion.
llvm-svn: 59930
2008-11-24 02:18:56 +00:00
Zhongxing Xu aa86cff14c Add out-of-bound memory access warning report code.
llvm-svn: 59903
2008-11-23 05:52:28 +00:00
Zhongxing Xu cdf25053ee Clean up code by using utility methods.
llvm-svn: 59899
2008-11-23 04:30:35 +00:00
Chris Lattner bd414e34c2 remove a dead enum
llvm-svn: 59879
2008-11-22 20:47:38 +00:00
Fariborz Jahanian 8a1810f06b New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.

llvm-svn: 59874
2008-11-22 18:39:36 +00:00
Zhongxing Xu 4c8bf0086a Remove debug code.
llvm-svn: 59870
2008-11-22 13:23:00 +00:00
Zhongxing Xu 4d45b34a8a Initial support for checking out of bound memory access. Only support
ConcreteInt index for now.

llvm-svn: 59869
2008-11-22 13:21:46 +00:00
Ted Kremenek 0b63f96ab5 - Clean up transfer function logic for 'return' statements.
- Add check for returning an undefined value to a caller.

llvm-svn: 59764
2008-11-21 00:27:44 +00:00
Zhongxing Xu e5816f213d Add support for symbolicating global structs and arrays in RegionStoreManager::getInitialStore().
llvm-svn: 59619
2008-11-19 11:06:24 +00:00
Zhongxing Xu b8e54884c8 Add SymbolData for array elements and struct fields.
llvm-svn: 59618
2008-11-19 11:03:17 +00:00
Chris Lattner 23be067407 rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics.  If you
want a % in a diagnostic, use %%.

llvm-svn: 59596
2008-11-19 06:51:40 +00:00
Ted Kremenek c0145fd0bf Fix warning about RegionStoreManager::Retrieve() not always returning a value.
llvm-svn: 59571
2008-11-19 00:27:37 +00:00
Zhongxing Xu f87a7abcd4 handle the case that the array element is of structure type when bind the whole array to a single value (for example, UnknownVal, UndefinedVal).
llvm-svn: 59521
2008-11-18 13:11:04 +00:00
Chris Lattner 8488c8297c This reworks some of the Diagnostic interfaces a bit to change how diagnostics
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?!

llvm-svn: 59502
2008-11-18 07:04:44 +00:00
Chris Lattner 3de58149bd eliminate dependence of strange "Diagnostic::Report" method,
delete huge trailing whitespace to fit in 80 cols.

llvm-svn: 59497
2008-11-18 06:07:40 +00:00
Chris Lattner 16ba91396a Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.

llvm-svn: 59494
2008-11-18 04:56:44 +00:00
Chris Lattner 53f5d4c1b5 cleanups and simplifications.
llvm-svn: 59491
2008-11-18 04:44:58 +00:00
Ted Kremenek c775712192 Fold assertion into second valid else branch. This removes a compiler warning
where the control reaches the end of a non-void function and also allows the
compiler to generate better code.  When this assertion is false we can easily
add more else cases.

llvm-svn: 59468
2008-11-17 22:55:12 +00:00
Zhongxing Xu 99a96d6ef3 Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.

llvm-svn: 59407
2008-11-16 07:06:26 +00:00
Zhongxing Xu ceca80619f Enhances SCA to process untyped region to typed region conversion.
- RegionView and RegionViewMap is introduced to assist back-mapping from
   super region to subregions.
 - GDM is used to carry RegionView information.
 - AnonTypedRegion is added to represent a typed region introduced by pointer
   casting. Later AnonTypedRegion can be used in other similar cases, e.g.,
   malloc()'ed region.
 - The specific conversion is delegated to store manager.

llvm-svn: 59382
2008-11-16 04:07:26 +00:00
Zhongxing Xu 461b4f4276 Use the allocator of ExplodedGraph. The whole static analysis module uses it.
llvm-svn: 59359
2008-11-15 08:19:58 +00:00
Zhongxing Xu 6a276cf5b7 Improve zero value generation.
llvm-svn: 59356
2008-11-15 05:18:50 +00:00
Ted Kremenek 1b2dace792 Reduce permissiveness of assertion.
llvm-svn: 59354
2008-11-15 05:00:27 +00:00
Ted Kremenek 4413714946 Reverted part of r59335: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081110/009243.html
In that patch I added a bogus type promotion for unary '!'.

The real bug was more fallout from edges cases with compound assignments and conjured symbolic values.  Now the conjured value has the type of the LHS expression, and we do a promotion to the computation type.  We also now correctly do a conversion from the computation type back to the LHS type.

llvm-svn: 59349
2008-11-15 04:01:56 +00:00
Ted Kremenek ac172fc574 Re-enable an assertion that I mistakenly removed.
llvm-svn: 59348
2008-11-15 02:35:08 +00:00
Ted Kremenek 519a223056 Use the correct QualType when creating the '0' constant.
llvm-svn: 59343
2008-11-15 00:40:08 +00:00
Ted Kremenek 1ca3346b19 Implement FIXME in GRExprEngine::VisitUnaryOperator() to handle implicit conversions caused by the '!' operator. This required adding some logic to GRSimpleVals to reason about nonloc::LocAsInteger SVals. This code appears to work fine, but it should eventually be cleaned up.
llvm-svn: 59335
2008-11-15 00:20:05 +00:00
Ted Kremenek 7eee049eea Flush llvm::errs() when printing out SVals.
llvm-svn: 59334
2008-11-15 00:16:53 +00:00
Ted Kremenek fc419a035f Minor tweaks to liveness analysis:
- Block-expression for 'ObjCForCollectionStmt' is not alive before it occurs
- Recursively visit 'element' expression for ObjCForCollectionStmt to get liveness for referenced block-level expressions and variables.

llvm-svn: 59316
2008-11-14 21:07:14 +00:00
Ted Kremenek 537f6387a2 Second attempt at implementation transfer function support for ObjCForCollectionStmt. We now assume that the 'element' expression can be any lvalue.
llvm-svn: 59313
2008-11-14 19:47:18 +00:00
Ted Kremenek 8959a1a69a Flow-sensitive uninitialized values analysis: properly handle the 'element' expression of ObjCForCollectionStmt (can be anything).
llvm-svn: 59312
2008-11-14 18:21:25 +00:00
Douglas Gregor 993603d80d Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)

I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.

llvm-svn: 59306
2008-11-14 16:09:21 +00:00
Zhongxing Xu c967d03528 Improve comments.
llvm-svn: 59294
2008-11-14 09:23:38 +00:00
Ted Kremenek 99d4ff3c7a Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRefExpr.
llvm-svn: 59290
2008-11-14 01:58:12 +00:00
Ted Kremenek a9d3e6c087 Rename header file.
Update include files.

llvm-svn: 59284
2008-11-14 01:14:18 +00:00
Ted Kremenek 7d5389e4b3 - Revert r59229 and r59232: AllocRegion should be immutable.
- Temporarily disabled test Analysis/array-struct.c for region store.

llvm-svn: 59245
2008-11-13 15:42:31 +00:00
Zhongxing Xu d4e72fca45 Process array base expression of any type.
llvm-svn: 59240
2008-11-13 09:48:44 +00:00
Zhongxing Xu 189a30796a Array index might be unsigned. We have to generate a temporary signed value for
it to be evaluated by APSInt::operators.

llvm-svn: 59238
2008-11-13 09:15:14 +00:00
Zhongxing Xu 29188c2948 Incomplete struct pointer can be used as a function argument.
llvm-svn: 59235
2008-11-13 08:41:36 +00:00
Zhongxing Xu 0dbeeaa886 Lift the pointer to alloca'ed region to the pointer to its first element.
This is required by some operations, e.g., *p = 1; p[0] = 1;.
Also set the AllocaRegion's type during the cast.

llvm-svn: 59232
2008-11-13 07:58:20 +00:00
Zhongxing Xu a70987eb82 Change AllocaRegion to subclass TypedRegion. We need to know ElementRegion's
type when assigning to it.

llvm-svn: 59229
2008-11-13 07:30:58 +00:00
Ted Kremenek 16866d6fd8 GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
llvm-svn: 59225
2008-11-13 06:10:40 +00:00
Ted Kremenek 75db6d7529 Fix uninitialized variable.
llvm-svn: 59222
2008-11-13 05:26:15 +00:00
Ted Kremenek 45698bf05f GRExprEngine::VisitInitListExpr:
- Don't crash on vector types.
- Handle typedefs.

llvm-svn: 59220
2008-11-13 05:05:34 +00:00
Ted Kremenek 65dd30fdea Update CFGStmtVisitor to recognize that ObjCForCollectionStmts are special block-level "expressions".
llvm-svn: 59176
2008-11-12 21:58:46 +00:00
Ted Kremenek df31792a66 Shore up transfer function for ObjCForCollectionStmt.
llvm-svn: 59162
2008-11-12 21:12:46 +00:00
Ted Kremenek 97450fe0a1 Use Stmt* instead of Expr* for block-level expression.
llvm-svn: 59161
2008-11-12 21:12:18 +00:00
Ted Kremenek 1781080c34 Add (preliminary) transfer function support for ObjCForCollectionStmt. Still need to flesh out some logic.
When processing DeclStmt, use the new interface to StateManager::BindDecl.  Conjuring of symbols is now done in VisitDeclStmt.

llvm-svn: 59155
2008-11-12 19:24:17 +00:00
Ted Kremenek 9999d72fe2 Conjured symbols now bind to Stmt* instead of Expr*.
llvm-svn: 59154
2008-11-12 19:22:47 +00:00
Ted Kremenek 60d46414f4 Update method names involving GRStateRef. No functionality change.
llvm-svn: 59153
2008-11-12 19:22:09 +00:00