Commit Graph

11308 Commits

Author SHA1 Message Date
Francois Pichet 7f1e2a5c03 Use -ffreestanding with clang_cc1 to make the test picks the clang builtin include.
llvm-svn: 135766
2011-07-22 10:49:54 +00:00
John McCall cf1667022f Document the existing objc_precise_lifetime attribute.
Introduce and document a new objc_returns_inner_pointer
attribute, and consume it by performing a retain+autorelease
on message receivers when they're not immediately loaded from
an object with precise lifetime.

llvm-svn: 135764
2011-07-22 08:53:00 +00:00
Francois Pichet 969c32acb2 Fix test on MSVC: since the test includes a system header it cannot use clang_cc1.
llvm-svn: 135763
2011-07-22 08:52:55 +00:00
Eric Christopher 516a79e32c Bring over a test from llvm/test/FrontendC that is for Sema and not CodeGen.
llvm-svn: 135753
2011-07-22 07:26:22 +00:00
Chris Lattner e135b089d8 fix PR10384: C++ allows external arrays of incomplete type as well.
Many thanks to Eli for reducing this great testcase.

llvm-svn: 135752
2011-07-22 06:27:26 +00:00
Chris Lattner 43cae02689 rename test.
llvm-svn: 135751
2011-07-22 06:26:12 +00:00
Chandler Carruth 4dd6c043ae Move duplicate uninitialized warning suppression into the
AnalysisBasedWarnings Sema layer and out of the Analysis library itself.
This returns the uninitialized values analysis to a more pure form,
allowing its original logic to correctly detect some categories of
definitely uninitialized values. Fixes PR10358 (again).

Thanks to Ted for reviewing and updating this patch after his rewrite of
several portions of this analysis.

llvm-svn: 135748
2011-07-22 05:27:52 +00:00
John McCall 24fada127f In ARC, non-atomic getters do not need to retain and autorelease
their loaded values, although it still worth doing this for __weak
properties to get the autoreleased-return-value optimization.

llvm-svn: 135747
2011-07-22 05:23:13 +00:00
John McCall d2930c2100 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.

llvm-svn: 135743
2011-07-22 02:45:48 +00:00
Fariborz Jahanian dff8de77a6 objective-c: Any use of @synthesize or @dynamic lexically after a method (or C function) implementation
will be rejected with a compilation error in ARC mode, and a compiler warning otherwise.
This may cause breakage in non-arc (and arc) tests which don't expect warning/error. Feel free
to fix the tests, or reverse the patch, if I am unavailable. // rdar://9818354 - WIP

llvm-svn: 135740
2011-07-22 01:06:53 +00:00
Alexis Hunt 82bb089e87 Add a missing test for the limits on wchar
llvm-svn: 135708
2011-07-21 22:01:12 +00:00
Argyrios Kyrtzidis 4145732818 Fix diagnostic when loading a PCH which has different enabled/disabled state of -fobjc-arc. rdar://9818341
llvm-svn: 135707
2011-07-21 21:56:04 +00:00
Fariborz Jahanian b21138fc25 Add FixIt hint for missing 'id' type.
// rdar://9615045

llvm-svn: 135685
2011-07-21 17:38:14 +00:00
Fariborz Jahanian b5a52ca0c9 objc - Diagnose missing method return type specifier under
a warning flag. // rdar://9615045

llvm-svn: 135681
2011-07-21 17:00:47 +00:00
Richard Trieu 713f429d8c Fix a test in warn-sign-conversion.cpp. Removed a part of a directory path so that the directory seperator, which may change on different platforms, is no longer part of the string checked for.
llvm-svn: 135665
2011-07-21 03:20:52 +00:00
Richard Trieu bb43dec255 Remove warning for conditional operands of differend signedness from -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion.
llvm-svn: 135664
2011-07-21 02:46:28 +00:00
Douglas Gregor 63745d5935 New libclang API to expose container type for code completion, from
Connor Wakamo!

llvm-svn: 135651
2011-07-21 01:05:26 +00:00
Anna Zaks 9ccf84e35d Addressing code review comments for commit 135509 - Add FixItHints in case a C++ function call is missing * or & operators on
llvm-svn: 135643
2011-07-21 00:34:39 +00:00
Fariborz Jahanian 53a495bd75 Removes a comment.
llvm-svn: 135640
2011-07-20 23:53:57 +00:00
Fariborz Jahanian 517695b27c objc-arc: Fixes a crash @throw'ing an objc message.
// pr10411

llvm-svn: 135638
2011-07-20 23:39:56 +00:00
Ted Kremenek 81383c20e4 Fix -Wuninitialized regression involving functions invalidating parameters passed by reference.
llvm-svn: 135610
2011-07-20 19:49:47 +00:00
Chad Rosier 7802c389da Whitespace.
llvm-svn: 135605
2011-07-20 19:27:01 +00:00
Chad Rosier 5371243dab If -ccc-host-triple i386-pc-win32-macho or -ccc-host-triple
x86_64-pc-win32-macho is used in conjunction with -no-integrated-as go ahead and
use the Darwin system assembler.
rdar://9785470

llvm-svn: 135604
2011-07-20 19:14:30 +00:00
Fariborz Jahanian a644f9cb73 arc-objc++: Issue an arc specific diagnostic when overload resolution
fails because of lifetime differences of parameter and argument type.
// rdar://9790531

llvm-svn: 135593
2011-07-20 17:14:09 +00:00
NAKAMURA Takumi 6657e979f5 test/CMakeLists.txt: Re-indent.
llvm-svn: 135591
2011-07-20 16:35:49 +00:00
Chris Lattner 7369c14b6a fix rdar://9780211 - Clang crashes with an assertion failure building WKView.mm from WebKit
This is something of a hack, the problem is as follows:

1. we instantiate both copied of RetainPtr with the two different argument types
   (an id and protocol-qualified id).
2. We refer to the ctor of one of the instantiations when introducing global "x",
   this causes us to emit an llvm::Function for a prototype whose "this" has type
   "RetainPtr<id<bork> >*".
3. We refer to the ctor of the other instantiation when introducing global "y",
   however, because it *mangles to the same name as the other ctor* we just use
   a bitcasted version of the llvm::Function we previously emitted.
4. We emit deferred declarations, causing us to emit the body of the ctor, however
   the body we emit is for RetainPtr<id>, which expects its 'this' to have an IR
   type of "RetainPtr<id>*".

Because of the mangling collision, we don't have this case, and explode.

This is really some sort of weird AST invariant violation or something, but hey
a bitcast makes the pain go away.

llvm-svn: 135572
2011-07-20 06:29:00 +00:00
Chris Lattner 71bd0c3263 fix PR10395 - array decay can produce an interesting type when
decaying an array of incomplete type (which has type [0 x i8]*) to a
normal pointer (which has incompletetype*).

llvm-svn: 135565
2011-07-20 04:31:01 +00:00
Joerg Sonnenberger 869f0b70d4 PR10392: "#pragma GCC visibility" must not expand macros in its
arguments.

llvm-svn: 135552
2011-07-20 01:03:50 +00:00
Richard Smith e3daab2449 Replace r134583's fix for PR10290 with one which also works for non-value-dependent cases.
llvm-svn: 135543
2011-07-20 00:12:52 +00:00
Ted Kremenek 65b3e0649c Fix false negative in -Wuninitialized involving a () wrapping an lvalue-to-rvalue conversion in a DeclStmt.
llvm-svn: 135525
2011-07-19 21:41:51 +00:00
Ted Kremenek 5d855bf7f2 Fix assertion failure in UninitializedValues.cpp where an lvalue to rvalue conversion is wrapped in a parenthesis.
llvm-svn: 135519
2011-07-19 20:33:49 +00:00
Jordy Rose d9c522100e [analysis] Add checks for double-locking and lock order reversal bugs for
pthread and XNU locks. Patch by Rui Paulo!

llvm-svn: 135515
2011-07-19 20:21:41 +00:00
Anna Zaks df92ddf846 Add FixItHints in case a C++ function call is missing * or & operators on one/several of it's parameters (addresses http://llvm.org/PR5941).
llvm-svn: 135509
2011-07-19 19:49:12 +00:00
Argyrios Kyrtzidis d571363e45 [arcmt] Add some additional driver flags to optionally emit or save the pre-migration ARC errors.
-arcmt-migrate-emit-errors : Emits the pre-migration ARC errors but it doesn't affect anything else
-arcmt-migrate-report-output : Writes out the pre-migration ARC errors to the provided plist file

rdar://9791454

llvm-svn: 135491
2011-07-19 17:20:03 +00:00
Douglas Gregor 925296b4c2 Revamp the SourceManager to separate the representation of parsed
source locations from source locations loaded from an AST/PCH file.

Previously, loading an AST/PCH file involved carefully pre-allocating
space at the beginning of the source manager for the source locations
and FileIDs that correspond to the prefix, and then appending the
source locations/FileIDs used for parsing the remaining translation
unit. This design forced us into loading PCH files early, as a prefix,
whic has become a rather significant limitation.

This patch splits the SourceManager space into two parts: for source
location "addresses", the lower values (growing upward) are used to
describe parsed code, while upper values (growing downward) are used
for source locations loaded from AST/PCH files. Similarly, positive
FileIDs are used to describe parsed code while negative FileIDs are
used to file/macro locations loaded from AST/PCH files. As a result,
we can load PCH/AST files even during parsing, making various
improvemnts in the future possible, e.g., teaching #include <foo.h> to
look for and load <foo.h.gch> if it happens to be already available.

This patch was originally written by Sebastian Redl, then brought
forward to the modern age by Jonathan Turner, and finally
polished/finished by me to be committed.

llvm-svn: 135484
2011-07-19 16:10:42 +00:00
Ted Kremenek 9e100ea1a8 Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST crawl.
This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG.
This allows us to remove a fair amount of the code for -Wuninitialized.

Some fallout:
- AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized.  This
is a layering violation, since the logic for -Wuninitialized is in libAnalysis.  This can be fixed with the proper refactoring.
- Some of the source locations for -Wunreachable-code warnings have shifted.  While not ideal, this is okay because that analysis
already needs some serious reworking.

llvm-svn: 135480
2011-07-19 14:18:48 +00:00
Devang Patel 11de9a966a Check column number also.
llvm-svn: 135437
2011-07-18 22:18:04 +00:00
Alexis Hunt c6d1d946e7 Remember to add a has_feature macro for __underlying_type now that it is
correctly impelmented

llvm-svn: 135401
2011-07-18 17:08:00 +00:00
Argyrios Kyrtzidis 91c62bfc03 [arcmt] When a NSData's 'bytes' family of methods are used on a local var,
add __attribute__((objc_precise_lifetime)) to make sure that the object
(and its data) will not get released before the var goes out-of-scope.

rdar://9206226

llvm-svn: 135382
2011-07-18 07:44:50 +00:00
Argyrios Kyrtzidis 73a0d32df5 [arcmt] NSInvocation's [get/set]ReturnValue and [get/set]Argument are only safe
with __unsafe_unretained parameters. Emit error for strong/weak ones. rdar://9206226

llvm-svn: 135381
2011-07-18 07:44:45 +00:00
Nick Lewycky ba4cc01a1f Don't crash when codegen'ing an empty redecl of a function in C99 mode, when
neither was inline. Fixes bug introduced in r135377.

llvm-svn: 135380
2011-07-18 07:11:55 +00:00
Nick Lewycky 26da4ddfa6 In C99, emit an inline function when encountering an extern redeclaration.
Fixes PR10233!

llvm-svn: 135377
2011-07-18 05:26:13 +00:00
Chandler Carruth 7cf5a37605 Revert r135217, which wasn't the correct fix for PR10358. With this
patch, we actually move the state-machine for the value set backwards
one step. This can pretty easily lead to infinite loops where we
continually try to propagate a bit, succeed for one iteration, but then
back up because we find an uninitialized use.

A reduced test case from PR10379 is included.

llvm-svn: 135359
2011-07-16 22:27:02 +00:00
Ted Kremenek 6dcbbe8547 [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>.
llvm-svn: 135350
2011-07-16 19:50:36 +00:00
Argyrios Kyrtzidis a6fe4bfdf5 [arcmt] It's not safe to remove the -release on "[[someivar delegate] release];" since it's very likely
that, after migration, the object that was passed to 'setDelegate:' will not be properly retained, e.g:

-whatever {
  id x = [[MyDoHicky alloc] init];
  [someivar setDelegate: x]; // x won't get retained in ARC.
}
-dealloc {
  [[someivar delegate] release]; // give migration error here.
}

rdar://8858009

llvm-svn: 135327
2011-07-15 23:48:56 +00:00
Tanya Lattner 8355938fcd This handles the missing cases of opencl vector literals.
Test cases provided by Anton Lokhmot.

llvm-svn: 135322
2011-07-15 23:07:01 +00:00
Jordy Rose 5737d073bd Update retain-release.m to match updated warnings from r135310
llvm-svn: 135317
2011-07-15 22:38:26 +00:00
Jordy Rose 43426f8fcb Add tests for CFRefReport's path notes, and fix a few typos and non-standard terminology ('+0 retain counts') caught by the tests.
llvm-svn: 135310
2011-07-15 22:17:54 +00:00
Argyrios Kyrtzidis f59daff52e [arcmt] Rewrite to "foo = nil;" not "foo = 0;", as suggested by Jordy.
llvm-svn: 135309
2011-07-15 22:04:00 +00:00
Argyrios Kyrtzidis 6a8a14d217 [arcmt] For:
id x = ...
@try {
 ...
} @finally {
 [x release];
}

Migrator will drop the release. It's better to change it to "x = 0" in a @finally to avoid leak when exception is thrown.

rdar://9398256

llvm-svn: 135301
2011-07-15 21:11:23 +00:00