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

136 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek 7fa9b4f258 static analyzer: add inlining support for directly called blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157833 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 20:04:04 +00:00
Fariborz Jahanian 350e956532 -Wdeprecated warning to include reference (as a note)
to the declaration in this patch. // rdar://10893232


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157537 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-27 16:59:48 +00:00
Jordy Rose 70fdbc366d [analyzer] RetainCountChecker: track ObjC boxed expression objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156699 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-12 05:10:43 +00:00
Anna Zaks caa62af79d [analyzer] Allow pointers to escape through selector callbacks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 17:23:11 +00:00
Ted Kremenek c91fdf662d Teach the static analyzer that NSLog() and friends do not hold on to object references (thus extending their lifetime).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156346 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:12:09 +00:00
Anna Zaks 58822c403c [analyzer] RetainCountChecker: Allow objects to escape through callbacks
Fixes radar://10973977.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156215 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-04 22:18:39 +00:00
Anna Zaks e7958da55e [analyzer] RetainRelease: Self assignment should not suppress a leak
warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155966 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 00:15:40 +00:00
Ted Kremenek befc6d2eae Teach RetainCountChecker that it doesn't quite understand pthread_setspecific and it should just give up when it sees it. Fixes <rdar://problem/11282706>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155613 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-26 04:32:23 +00:00
Patrick Beard b2f6820773 Added a new attribute, objc_root_class, which informs the compiler when a root class is intentionally declared.
The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger
the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154187 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 18:12:22 +00:00
Ted Kremenek de5b4fbe31 Change RetainCountChecker to eagerly "escape" retained objects when they are
assigned to a struct.  This is fallout from inlining results, which expose
far more patterns where people stuff CF objects into structs and pass them
around (and we can reason about it).  The problem is that we don't have
a general way to detect when values have escaped, so as an intermediate step
we need to eagerly prune out such tracking.

Fixes <rdar://problem/11104566>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153489 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 01:12:45 +00:00
Ted Kremenek 7acf23f03e Teach RetainCountChecker about mixing method families with explicit annotations. Fixes <rdar://problem/10824732>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152448 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 23:34:08 +00:00
Ted Kremenek 1a45a5ff5d Add static analyzer support for new NSArray/NSDictionary/NSNumber literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152139 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-06 20:06:12 +00:00
Anna Zaks 212000e24c [analyzer] Retain release: drop the line number info from the leak
message.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151657 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-28 21:49:08 +00:00
Ted Kremenek a979712238 Teach analyzer about NSAutoreleasePool -allocWithZone:. Fixes <rdar://problem/10640253>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150892 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-18 21:37:48 +00:00
Ted Kremenek 1c87980ef1 Teach the static analyzer to not treat XPC types as CF types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147506 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-04 00:35:48 +00:00
Ted Kremenek 93edbc5269 Fix major regression in RetainCountChecker. DefaultSummaries were not being used when they were meant to be. Fixes <rdar://problem/10241614>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 23:54:29 +00:00
Anna Zaks 09ca9ef5f9 [analyzer] Fix a bug where PathDiagnosticLocation did not generate a valid range and add asserts to check validity of locations early on. Ignore invalid ranges in PathDiagnosticPiece (they could be added by checker writers).
Addresses radar://10124836 and radar://radar10102244.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140218 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-21 00:35:58 +00:00
Jordy Rose 17a38e2636 [analyzer] Move the knowledge of whether or not GC is enabled for the current analysis from CFRefCount to ExprEngine.
Remove TransferFuncs from ExprEngine and AnalysisConsumer.

Demote RetainReleaseChecker to a regular checker, and give it the name osx.cocoa.RetainCount (class name change coming shortly). Update tests accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138998 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 05:55:19 +00:00
Ted Kremenek a4c7a4314f Really remove FlatStoreManager and BasicStoreManager, this time from the driver. Also remove associated tests. Sorry for the messy commits; this is the result of a botched Git merge.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136422 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 23:08:16 +00:00
Ted Kremenek 8829989238 [analyzer] Overhaul how the static analyzer expects CFGs by forcing CFGs to be linearized only when used by the static analyzer. This required a rewrite of LiveVariables, and exposed a ton of subtle bugs.
The motivation of this large change is to drastically simplify the logic in ExprEngine going forward.

Some fallout is that the output of some BugReporterVisitors is not as accurate as before; those will
need to be fixed over time.  There is also some possible performance regression as RemoveDeadBindings
will be called frequently; this can also be improved over time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136419 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 23:07:59 +00:00
John McCall 6c2c250db1 In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those
declared in protocols and categories.  There are mismatches
that we would like to diagnose but aren't yet, but this   
is fine for now.

I looked at approaches that avoided doing this lookup 
unless we needed it, but the infer-related-result-type
checks were doing it anyway, so I left it with the same
fast-path check for no previous declartions of that 
selector.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135743 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 02:45:48 +00:00
Ted Kremenek 797a7be0de [analyzer] Per discussions with the Cocoa team, extend CF naming conventions to extend to camel case functions instead of just title case functions. Fixes <rdar://problem/9732321>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-16 19:50:36 +00:00
Jordy Rose deefaf6eac Update retain-release.m to match updated warnings from r135310
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135317 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 22:38:26 +00:00
Douglas Gregor 786dcd9dca Teach the static analyzer's interpretation of Cocoa conventions to
obey the objc_method_family attribute when provided. Fixes
<rdar://problem/9726279>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134493 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 16:00:34 +00:00
Douglas Gregor 4c4efee6d3 Eliminate the -f[no]objc-infer-related-result-type flags; there's no
reason to allow the user to control these semantics through a flag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132919 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 16:42:53 +00:00
Ted Kremenek d368d71169 Enhance retain/release checker to flag warnings when functions returning CG types do not follow the Core Foundation naming conventions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132048 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 06:19:45 +00:00
Ted Kremenek 35bdbf4062 Augment retain/release checker to not warn about tracked objects passed as arguments to C++ constructors. This is a stop-gap measure for Objective-C++ code that uses smart pointers to manage reference counts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130711 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 19:42:42 +00:00
Ted Kremenek b94dd9e76b Adjust test/Analysis/retain-release.m to also test the retain/release checker in Objective-C++ mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-29 23:15:53 +00:00
John McCall 98b8f16a0b When updating the retain summary based on {cf,ns}_consumed attributes,
be sure to consume the argument index that actually had the attribute
rather than always the first.  rdar://problem/9234108



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128998 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-06 09:02:12 +00:00
Ted Kremenek 5188507b9a Rework checker "packages" and groups to be more hierarchical.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128187 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-24 00:28:47 +00:00
Argyrios Kyrtzidis c4d2c9074b [analyzer] Remove '-analyzer-check-objc-mem' flag, the nominee for best misnomer award.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126676 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-28 19:49:42 +00:00
Argyrios Kyrtzidis 3267d9563f [analyzer] Migrate NoReturnFunctionChecker to CheckerV2.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126613 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-28 01:27:17 +00:00
Argyrios Kyrtzidis 38c8fe705e Allow passing a list of comma separated checker names to -analyzer-checker, e.g:
-analyzer-checker=cocoa,unix

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126372 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 08:42:20 +00:00
Chandler Carruth 21206d5e31 Implement a warning for known shift overflows on constant shift
expressions. Consider the code:

  int64_t i = 10 << 30;

This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.

The warning is currently gated behind -Wshift-overflow.

There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.

Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126342 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 23:34:11 +00:00
Argyrios Kyrtzidis 0b1ba6227c [analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker
  CFNumberCreateChecker
  NSAutoreleasePoolChecker
  CFRetainReleaseChecker
  ClassReleaseChecker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125636 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 01:40:52 +00:00
Ted Kremenek 11fe175346 Wire up attributes 'ns_consumed' and 'cf_consumed' in the static analyzer's ObjC retain/release checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124386 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 18:43:03 +00:00
Ted Kremenek 12b9434d5b Hook up attribute ns_consumes_self in the ObjC retain/release checker in the static analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124360 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 06:54:14 +00:00
John McCall d6b8de0e7b Change the wording of the bad-decl-for-attribute warning and error
to make it clear that we're talking about the declarations and not the types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124175 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 03:51:08 +00:00
John McCall c7ad38168d Add the ns_consumes_self, ns_consumed, cf_consumed, and ns_returns_autoreleased
attributes for the benefit of the static analyzer.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124174 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 03:31:58 +00:00
Argyrios Kyrtzidis d7a31ba6db [analyzer] Introduce ObjCSelfInitChecker, which checks initialization methods to verify that they assign 'self' to the
result of an initialization call (e.g. [super init], or [self initWith..]) before using any instance variable or
returning 'self'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123264 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 19:45:25 +00:00
Ted Kremenek af86b0c160 Revise Cocoa conventions detection: 'copy' and 'mutableCopy'
only indicates the create rule if it starts
at the beginning of the method name, not
within the method name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122036 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 04:44:43 +00:00
Ted Kremenek 83300e884d Add test case for r120795.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120796 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 06:53:12 +00:00
Ted Kremenek cf38af20eb Add test case for <rdar://problem/8356342>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117525 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-28 02:50:32 +00:00
Ted Kremenek 4019c4f692 Correctly handle 'Class<...>' when examining Cocoa conventions in the static analyzer. Fixes a crash reported in <rdar://problem/8272168>. Patch by Henry Mason!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110289 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-05 00:19:24 +00:00
Jordy Rose b829d72294 Oops, tabs --> spaces in test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107634 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06 02:42:09 +00:00
Jordy Rose 61fb55c879 Improve NULL-checking for CFRetain/CFRelease. We now remember that the argument was non-NULL, and we report where the null assumption came from (like AttrNonNullChecker already did).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107633 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06 02:34:42 +00:00
Ted Kremenek d775c66b3a Update retain-release checker to understand changes to how 'super' is represented
in the ASTs.  Fixes <rdar://problem/8015556>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104389 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21 21:57:00 +00:00
Ted Kremenek cfd8ea930a Fix NoReturnFunctionChecker to properly look at a function's type
when determining if it returns.  Fixes <rdar://problem/7796563>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99663 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26 22:57:13 +00:00
Ted Kremenek 6041111f37 Recognize attributes ns_returns_not_retained and cf_returns_not_retained
in the static analyzer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96539 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 00:06:12 +00:00
Ted Kremenek 565e465c6d Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95348 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 02:06:54 +00:00