Commit Graph

638 Commits

Author SHA1 Message Date
Ted Kremenek f6d9cebafd Enhance understanding of VarRegions referenced by a block whose declarations are outside the current stack frame. Fixes <rdar://problem/7462324>.
llvm-svn: 91107
2009-12-11 06:43:27 +00:00
Ted Kremenek 8573913760 Fix null dereference in OSAtomicChecker and special case SymbolicRegions. We still aren't handling them correctly; I've added to failing test cases to test/Analysis/NSString-failed-cases.m that should pass and then be merged in to test/Analysis/NSString.m.
llvm-svn: 90993
2009-12-09 23:29:55 +00:00
Zhongxing Xu 1d153328be OSAtomic simulation: use the original region as the location to load from,
instead of the ElementRegion obtained from casts.

Test cast: the leak cannot occur bacause the true branch cannot be taken.

llvm-svn: 90964
2009-12-09 08:32:57 +00:00
Zhongxing Xu 39644a62f9 Add notes to a test case.
llvm-svn: 90947
2009-12-09 04:22:30 +00:00
Ted Kremenek 32c32892f7 Fix a horrid bug in GRExprEngine::CheckerVisit() that was identified
by the test case in PR 5627.  Essentially we shouldn't clear the
ExplodedNodeSet where we deposit newly constructed nodes if that set
is the 'Dst' set passed in.  It is not okay to clear that set because
it may already contain nodes.

llvm-svn: 90931
2009-12-09 02:45:41 +00:00
Zhongxing Xu efd9ae8a85 Add test case for mktemp. Patch by Lei Zhang.
llvm-svn: 90706
2009-12-06 12:45:46 +00:00
Ted Kremenek 2a3dbb5749 Add another blocks test case illustrating how parameters passed-by-reference in block invocations are invalidated (just like function calls).
llvm-svn: 90466
2009-12-03 18:29:20 +00:00
Ted Kremenek 5bee5c4ff0 Add value invalidation logic for block-captured variables. Conceptually invoking a block (without specific reasoning of what the block does) can invalidate any value to it by reference when the block was created.
llvm-svn: 90431
2009-12-03 08:25:47 +00:00
Ted Kremenek f66b72094a Add a heuristic to the dead stores checker to prune dead stores for variables annotated with '__block'. This is overly conservative, but now the analyzer doesn't report dead stores for variables that can be updated by a block call.
llvm-svn: 90364
2009-12-03 00:46:16 +00:00
Ted Kremenek 733a3e6104 Added dead-stores test cases that involve the use of blocks.
llvm-svn: 90277
2009-12-01 23:04:14 +00:00
Ted Kremenek b2dc72d2d0 Add new test case file that focuses on testing analyzer support for blocks.
llvm-svn: 90274
2009-12-01 22:47:46 +00:00
Daniel Dunbar 4e7596cc3a Normalize options to use '-FOO' instead of '--FOO'.
llvm-svn: 90071
2009-11-29 09:33:10 +00:00
Ted Kremenek 2350e0c3ba Improve diagnostics in ReturnStackAddressChecker for returning a stack-allocated block. Implements the rest of <rdar://problem/7387385>.
llvm-svn: 89940
2009-11-26 07:14:50 +00:00
Ted Kremenek e5d8dd808e Add test case that shows that dead stores checking now works in the presence of blocks.
llvm-svn: 89939
2009-11-26 06:55:36 +00:00
Ted Kremenek f89dcdaf19 Add a PostVisitBlockExpr() method to RetainReleaseChecker to query for
the set of variables "captured" by a block.  Until the analysis gets
more sophisticated, for now we stop the retain count tracking of any
objects (transitively) referenced by these variables.

llvm-svn: 89929
2009-11-26 02:38:19 +00:00
Ted Kremenek e6a2780c96 Add really basic support for blocks in the retain/release checker. For now, anytime we pass a tracked object to a block call we stop tracking it.
llvm-svn: 89831
2009-11-25 01:35:18 +00:00
Ted Kremenek 239b930ae1 Convert test case to FileCheck to test the behavior of the nil-receiver checker when the code is targetted for either Tiger or Leopard.
llvm-svn: 89810
2009-11-24 22:56:53 +00:00
Ted Kremenek 1fc1f20efd For the nil-receiver checker, take into account the behavioral changes that got introduced in Mac OS X 10.5 and later, notably return values of double, float, etc., will not be garbage. Fixes <rdar://problem/6829160>.
llvm-svn: 89809
2009-11-24 22:48:18 +00:00
Ted Kremenek 005e8a06f2 Cleanups and fixes to the nil-receiver checker, some of it fallout the
initial transition of the nil-receiver checker to the Checker
interface as done in r89745.  Some important changes include:

1) We consolidate the BugType object used for nil receiver bug
reports, and don't include the type of the returned value in the
BugType (which would be wrong if a nil receiver bug was reported more
than once)

2) Added a new (temporary) flag to CheckerContext: DoneEvauating.
This is used by GRExprEngine when evaluating message expressions to
not continue evaluating the message expression if this flag is set.
This flag is currently set by the nil receiver checker.  This is an
intermediate solution to allow the nil-receiver checker to properly
work as a plug-in outside of GRExprEngine.  Basically, this flag
indicates that the entire message expression has been evaluated, not
just a precondition (which is what the nil-receiver checker does).
This flag *should not* be repurposed for general use, but just to pull
more things out of GRExprEngine that already in there as we devise a
better interface in the Checker class.

3) Cleaned up the logic in the nil-receiver checker, making the
control-flow a lot easier to read.

llvm-svn: 89804
2009-11-24 21:41:28 +00:00
Ted Kremenek c0229557dd Enhance null dereference diagnostics by indicating what variable (if any) was dereferenced. Addresses <rdar://problem/7039161>.
llvm-svn: 89726
2009-11-24 01:33:10 +00:00
Ted Kremenek 02d6aca867 Tweak UndefBranchChecker to register the most nested "undefined" expression with bugreporter::registerTrackNullOrUndefValue instead of the condition itself.
llvm-svn: 89682
2009-11-23 18:12:03 +00:00
Fariborz Jahanian 0afc555196 Make 'SEL' pointer to a builtin type and not an
objective-c pointer type. This was a serious mishap and
luckily, Ted's test caught that (and patch fixes the test case).

llvm-svn: 89680
2009-11-23 18:04:25 +00:00
Ted Kremenek d4dca6fde6 Cleanup title/description of "undefined branch" BugType and add some test cases for this check.
llvm-svn: 89679
2009-11-23 17:58:48 +00:00
Ted Kremenek 12b64959ce Change CheckDeadStores to use Expr::isNullPointerConstant, which will correctly determine whether an expression is a null pointer constant.
Patch by Kovarththanan Rajaratnam!

llvm-svn: 89621
2009-11-22 20:26:21 +00:00
Fariborz Jahanian 252ba5fb6f This patch implements objective-c's 'SEL' type as a built-in
type and fixes a long-standing code gen. crash reported in
at least two PRs and a radar. (radar 7405040 and pr5025). 
There are couple of remaining issues that I would like for
Ted. and Doug to look at:

Ted, please look at failure in Analysis/MissingDealloc.m.
I have temporarily added an expected-warning to make the
test pass. This tests has a declaration of 'SEL' type which
may not co-exist with the new changes.

Doug, please look at a FIXME in PCHWriter.cpp/PCHReader.cpp.
I think the changes which I have ifdef'ed out are correct. They
need be considered for in a few Indexer/PCH test cases.

llvm-svn: 89561
2009-11-21 19:53:08 +00:00
Ted Kremenek 775d9c149d Add RegionStore test case that shows that floating point values are also implicitly tracked for undefined values. (test case for <rdar://problem/6811085>).
llvm-svn: 89538
2009-11-21 02:52:12 +00:00
Ted Kremenek f3febe4bdc Add another test case to show the precision of RegionStore over
BasicStore.  In this example, BasicStore would lose information about
the pointer in path after '*path++', causing the analyzer to falsely
flag a null dereference.  This addresses <rdar://problem/7191542>.

llvm-svn: 89533
2009-11-21 02:17:47 +00:00
Ted Kremenek caf2c51fad Pull BadCallChecker int UndefinedArgChecker, and have UndefinedArgChecker also handled undefined receivers in message expressions.
llvm-svn: 89524
2009-11-21 01:25:37 +00:00
Ted Kremenek f7adea43b4 More checker refactoring. Passing undefined values in a message expression is now handled by UndefinedArgChecker.
llvm-svn: 89519
2009-11-21 00:49:41 +00:00
Ted Kremenek a4f7c180ae Add simple static analyzer checker to check for sending 'release', 'retain', etc. directly to a class. Fixes <rdar://problem/7252064>.
llvm-svn: 89449
2009-11-20 05:27:05 +00:00
Ted Kremenek c1f161c012 Unused ivar checker: ivars referenced by lexically nested functions should not be flagged as unused. Fixes <rdar://problem/7254495>.
llvm-svn: 89448
2009-11-20 04:31:57 +00:00
Ted Kremenek a96d02c76b Really fix test case.
llvm-svn: 89430
2009-11-20 01:20:12 +00:00
Ted Kremenek 4b412f51df Fix test case.
llvm-svn: 89429
2009-11-20 01:19:22 +00:00
Ted Kremenek dd2b2b23c8 Fix null dereference in NSAutoreleasePoolChecker when analyzing messages sent to blocks.
llvm-svn: 89413
2009-11-20 00:12:36 +00:00
Ted Kremenek 439a6d146c Fix crash when using --analyzer-store=region when handling initializers with nested arrays/structs whose values are not explicitly specified. Fixes <rdar://problem/7403269>.
llvm-svn: 89384
2009-11-19 20:20:24 +00:00
Daniel Dunbar 484afa2d3b Switch -f{builtin,math-errno,rtti} and -analyzer-purge-dead to -...no... variants instead of using llvm:🆑:init(true) arguments.
llvm-svn: 89315
2009-11-19 04:55:23 +00:00
Daniel Dunbar f6e32e4abe Drop unnecessary #include.
llvm-svn: 89154
2009-11-17 22:25:16 +00:00
Daniel Dunbar fba0b44d35 Use -fblocks and -fobjc-nonfragile-abi when that is what is being tested, instead of forcing the triple.
llvm-svn: 89072
2009-11-17 09:04:12 +00:00
Zhongxing Xu 23baa01af4 Add PreVisitReturn to Malloc checker. Now we can recognize returned memory
block.

llvm-svn: 89071
2009-11-17 08:58:18 +00:00
Daniel Dunbar feedba68b5 Don't #include <stdio.h> when tests don't need it, or use clang instead of clang-cc when they do.
llvm-svn: 89070
2009-11-17 08:57:36 +00:00
Zhongxing Xu 4668c7ed1c Add EvalEndPath interface to Checker. Now we can check memory leaked at the
end of the path. Need to unify interfaces.

llvm-svn: 89063
2009-11-17 07:54:15 +00:00
Ted Kremenek 99b944c037 Add newline at the end of the file.
llvm-svn: 89052
2009-11-17 06:34:24 +00:00
Ted Kremenek 5b2592ed65 Add test to verify that the analyzer plist output is what we expect.
llvm-svn: 89029
2009-11-17 02:31:39 +00:00
Fariborz Jahanian 9290ede494 Handle case of missing '@end' in implementation context
gracefully, on par with gcc, by: Issuing a warning,
doing final sematinc check of its definitions and generating
its meta-data.

llvm-svn: 88934
2009-11-16 18:57:01 +00:00
Eli Friedman b774685c08 Fix a couple of tests.
llvm-svn: 88756
2009-11-14 04:23:25 +00:00
Ted Kremenek 9430bf20ff Remove test case's dependency on header file.
llvm-svn: 88685
2009-11-13 20:03:22 +00:00
Ted Kremenek e5e977013c Add two new test cases for the Malloc/Free checker. Both have to do with
storing malloc'ed memory to global storage.

llvm-svn: 88684
2009-11-13 20:00:28 +00:00
Ted Kremenek c2675568a1 Add test case that shows a leak we don't catch.
llvm-svn: 88683
2009-11-13 19:53:32 +00:00
Ted Kremenek 4ef13f8ac9 Add clang-cc option "--analyzer-experimental-internal-checks". This
option enables new "internal" checks that will eventually be turned on
by default but still require broader testing.

llvm-svn: 88671
2009-11-13 18:46:29 +00:00
Zhongxing Xu c7460964ac Malloc checker basically works now.
llvm-svn: 87094
2009-11-13 07:48:11 +00:00