Commit Graph

14918 Commits

Author SHA1 Message Date
Fariborz Jahanian edc2971c4d objc: improved diagnostic when property autosynthesis may cause
change in behavior. // rdar://11671080

llvm-svn: 158828
2012-06-20 17:18:31 +00:00
Ted Kremenek c26328afa6 Revert "Provide a -no-pedantic to cancel out -pedantic." This needs to be designed
a bit further.  We may wish to just have -Wno flags to silence warnings, and not have a -no-pedantic.

llvm-svn: 158796
2012-06-20 07:03:37 +00:00
John McCall 5fb5df9c83 Restructure how the driver communicates information about the
target Objective-C runtime down to the frontend:  break this
down into a single target runtime kind and version, and compute
all the relevant information from that.  This makes it
relatively painless to add support for new runtimes to the
compiler.  Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z,
available at the driver level as a better and more general
alternative to -fgnu-runtime and -fnext-runtime.  This new
concept of an Objective-C runtime also encompasses what we
were previously separating out as the "Objective-C ABI", so
fragile vs. non-fragile runtimes are now really modelled as
different kinds of runtime, paving the way for better overall
differentiation.

As a sort of special case, continue to accept the -cc1 flag
-fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak.

I won't go so far as to say "no functionality change", even
ignoring the new driver flag, but subtle changes in driver
semantics are almost certainly not intended.

llvm-svn: 158793
2012-06-20 06:18:46 +00:00
Jordan Rose 7d2bdd538d [analyzer] Move failing 'new' test cases back into new.cpp instead of XFAILing.
Per Anna's comment, this is a better way to handle "to-do list"-type failures.
This way we'll know if any of the features get fixed; in an XFAIL file, /all/
the cases have to be fixed before lit would tell us anything.

llvm-svn: 158791
2012-06-20 05:34:32 +00:00
Jordan Rose 44320367ac [analyzer] Invalidate placement args; return the pointer given to placement new
The default global placement new just returns the pointer it is given.
Note that other custom 'new' implementations with placement args are not
guaranteed to do this.

In addition, we need to invalidate placement args, since they may be updated by
the allocator function. (Also, right now we don't properly handle the
constructor inside a CXXNewExpr, so we need to invalidate the placement args
just so that callers know something changed!)

This invalidation is not perfect because CallOrObjCMessage doesn't support
CXXNewExpr, and all of our invalidation callbacks expect that if there's no
CallOrObjCMessage, the invalidation is happening manually (e.g. by a direct
assignment) and shouldn't affect checker-specific metadata (like malloc state);
hence the malloc test case in new-fail.cpp. But region values are now
properly invalidated, at least.

The long-term solution to this problem is to rework CallOrObjCMessage into
something more general, rather than the morass of branches it is today.

<rdar://problem/11679031>

llvm-svn: 158784
2012-06-20 01:32:01 +00:00
Argyrios Kyrtzidis 927a437ac7 [objcmt] Have the modern objc migration warning change from:
[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires a cast

to something like:

[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires casting 'bool' to 'double'

This is way better to fully understand the warning.
rdar://11705106

llvm-svn: 158783
2012-06-20 01:28:32 +00:00
Argyrios Kyrtzidis 692bf8cb64 [arcmt] When migrating to ARC disable -Werror so as to only block migration
for "hard" ARC errors, not warnings.

rdar://11691437

llvm-svn: 158781
2012-06-20 01:10:40 +00:00
Kaelyn Uhrain 272d718808 Add the PCH file name to the message about not being able to read the PCH.
Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.

llvm-svn: 158772
2012-06-20 00:36:03 +00:00
Dmitri Gribenko aab8383a2b Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang

llvm-svn: 158771
2012-06-20 00:34:58 +00:00
Nico Weber 5f96883d44 Do a second lookup for type_info in the global namespace in microsoft mode. PR13153.
llvm-svn: 158768
2012-06-19 23:58:27 +00:00
Alexis Hunt 78e2b91319 Do not crash when we dynamic cast a final type to void*.
llvm-svn: 158763
2012-06-19 23:44:55 +00:00
Tanya Lattner 4fdce3faa8 Extend the support for cl-std to include 1.2.
Add error checking for the static qualifier which is now allowed in certain situations for OpenCL 1.2. Use the CL version to turn on this feature.
Added test case for 1.2 static storage class feature.

llvm-svn: 158759
2012-06-19 23:09:52 +00:00
Fariborz Jahanian 63d40202fb objective-c: warn when autosynthesizing a property which has same
name as an existing ivar since this is common source of error
when people remove @synthesize to take advantage of autosynthesis. 
// rdar://11671080

llvm-svn: 158756
2012-06-19 22:51:22 +00:00
Aaron Ballman 478faed4b0 Reapplying the changes from r158717 as they were rolled back to avoid merge conflicts from a separate problematic patch.
llvm-svn: 158750
2012-06-19 22:09:27 +00:00
Jakob Stoklund Olesen e1c0ae6fda Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

llvm-svn: 158749
2012-06-19 21:48:43 +00:00
Richard Smith 72cd8ea5e5 Fix -Wc++11-narrowing warnings for narrowing negative values to larger unsigned
types to actually includes the value, rather than saying <uninitialized>.

llvm-svn: 158745
2012-06-19 21:28:35 +00:00
David Blaikie 9366d2b32d Enable -Wnull-conversion for non-integral target types (eg: double).
llvm-svn: 158744
2012-06-19 21:19:06 +00:00
Fariborz Jahanian a36cbeb464 objc-arc: captured block variable accessed in its block literal
initializer need be null initialized before initializer takes
hold, just like any other initialized retainable object pointer. 
// rdar://11016025

llvm-svn: 158738
2012-06-19 20:53:26 +00:00
Aaron Ballman 38c9ad9e72 Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
llvm-svn: 158717
2012-06-19 13:49:26 +00:00
Anna Zaks 42908c7ac9 [analyzer] Allow pointers to escape into NSPointerArray.
(Fixes radar://11691035 PR13140)

llvm-svn: 158703
2012-06-19 05:10:32 +00:00
Jordan Rose 8d63d5b8e6 Fix the location of the fixit for -Wnewline-eof.
It turns out SourceManager treating the "one-past-the-end" location as invalid,
but then failing to set the invalid flag properly.

llvm-svn: 158699
2012-06-19 03:09:38 +00:00
Argyrios Kyrtzidis a3fcbeb908 [objcmt] When checking whether the subscripting methods are declared use
ObjCInterfaceDec::lookupInstanceMethod to make sure we check categories as well
and update related tests.

rdar://11695288

llvm-svn: 158697
2012-06-19 02:22:02 +00:00
Rafael Espindola 66aa045fd9 Add a -fuse-init-array option to cc1 and map to the UseInitArray target
option. On the driver, check if we are using libraries from gcc 4.7 or newer
and if so pass -fuse-init-array to the frontend.
The crtbegin*.o files in gcc 4.7 no longer call the constructors listed in
.ctors, so we have to use .init_array.

llvm-svn: 158694
2012-06-19 01:26:10 +00:00
Kaelyn Uhrain 9ea8f7e6c5 Improve the error message when a function overload candidate is rejected
because it expects a reference and receives a non-l-value.

For example, given:

  int foo(int &);
  template<int x> void b() { foo(x); }

clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.

llvm-svn: 158691
2012-06-19 00:37:47 +00:00
Ted Kremenek 9dcc0325de Sink definition of IBOutlet, IBOutletCollection, and IBAction into
the compiler predefines buffer.  These are essentially part of
the Objective-C language.

llvm-svn: 158690
2012-06-19 00:37:39 +00:00
Jordan Rose 8cea63c5cd Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).

This removes the warning entirely from uses in the main source file in C++.

llvm-svn: 158689
2012-06-18 23:58:49 +00:00
Michael J. Spencer c6ad2c4f03 XFAIL linker-opts.c on win32 now that it doesn't pretend that link.exe is ld.
llvm-svn: 158687
2012-06-18 23:00:44 +00:00
Jordan Rose 28cd12f265 Support -Winternal-linkage-in-inline in C++ code.
This includes treating anonymous namespaces like internal linkage, and allowing
const variables to be used even if internal. The whole thing's been broken out
into a separate function to avoid nested ifs.

llvm-svn: 158683
2012-06-18 22:09:19 +00:00
Jordan Rose edff020011 Allow internal decls in inline functions if the function is in the main file.
This handles the very common case of people writing inline functions in their
main source files and not tagging them as inline. These cases should still
behave as the user intended. (The diagnostic is still emitted as an extension.)

I'm reworking this code anyway to account for C++'s equivalent restriction in
[basic.def.odr]p6, but this should get some bots back to green.

llvm-svn: 158666
2012-06-18 17:49:58 +00:00
Michael J. Spencer e2f493604a [VS Toolchain] Correctly forward -l linker inputs to link.exe.
Patch by Nikola Smiljanic!

llvm-svn: 158664
2012-06-18 16:56:04 +00:00
Nuno Lopes e881ce2ef6 fix PR13071 / rdar://problem/11634669 :
crash on invalid function decl with alloc_size attribute

llvm-svn: 158663
2012-06-18 16:39:04 +00:00
Nuno Lopes e44e93aa6b alloc_size attribute: there's nothing wrong with alloc_size(1,1). It just means the function allocates x^2 bytes. GCC also accepts this syntax
llvm-svn: 158662
2012-06-18 16:27:56 +00:00
Alexis Hunt a0e54d453b Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).

llvm-svn: 158661
2012-06-18 16:13:52 +00:00
Michael J. Spencer f97bd8c9cb [MSExtensions] Add support for __forceinline.
__forceinline is a combination of the inline keyword and __attribute__((always_inline))

llvm-svn: 158653
2012-06-18 07:00:48 +00:00
Richard Smith 7b3f322517 Extend the error recovery for a template-argument-list terminated by '>>' to
also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to
deal with cases where the token is followed by an adjacent '=', '==', '>=',
'>>=', or '>>>' token, where a naive fix-it would result in a differing token
stream on a re-lex.

llvm-svn: 158652
2012-06-18 06:11:04 +00:00
Joerg Sonnenberger 5c98e1fb24 Don't warn about address-to-member used as part of initialisation, if
the member expression is in parentheses.

llvm-svn: 158651
2012-06-17 23:10:39 +00:00
Hal Finkel 49bba70ec5 For compatibility with gcc, accept -maltivec as an alias of -faltivec.
llvm-svn: 158613
2012-06-17 02:29:23 +00:00
Richard Smith a8d4f229a6 -Wuninitialized bugfix: when entering the scope of a variable with no
initializer, it is uninitialized, even if we may be coming from somewhere where
it was initialized.

llvm-svn: 158611
2012-06-16 23:34:14 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Eli Friedman 93ee5ca805 Fix Sema and IRGen for atomic compound assignment so it has the right semantics when promotions are involved.
(As far as I can tell, this only affects some edge cases.)

llvm-svn: 158591
2012-06-16 02:19:17 +00:00
Jordan Rose b4712d142a [analyzer] Array CompoundLiteralExprs need to be treated like lvalues.
llvm-svn: 158588
2012-06-16 01:28:03 +00:00
Jordan Rose e42412be39 [analyzer] Return an UnknownVal when we try to get the binding for a VLA.
This happens in C++ mode right at the declaration of a struct VLA;
MallocChecker sees a bind and tries to get see if it's an escaping bind.
It's likely that our handling of this is still incomplete, but it fixes a
crash on valid without disturbing anything else for now.

llvm-svn: 158587
2012-06-16 01:28:00 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00
Jordan Rose de409b6d5f [analyzer] Buffers passed to CGBitmapContextCreate can escape.
Specifically, although the bitmap context does not take ownership of the
buffer (unlike CGBitmapContextCreateWithData), the data buffer can be extracted
out of the created CGContextRef. Thus the buffer is not leaked even if its
original pointer goes out of scope, as long as
- the context escapes, or
- it is retrieved via CGBitmapContextGetData and freed.

Actually implementing that logic is beyond the current scope of MallocChecker,
so for now CGBitmapContextCreate goes on our system function exception list.

llvm-svn: 158579
2012-06-16 00:09:20 +00:00
Eli Friedman 13ffdd86b9 Make the ".*" operator work correctly when the base is a prvalue and the field has a non-trivial copy constructor. PR13097.
llvm-svn: 158578
2012-06-15 23:51:06 +00:00
Kaelyn Uhrain b5b17fe9fc Recover when correcting an unknown type name to a keyword like "struct".
llvm-svn: 158573
2012-06-15 23:45:58 +00:00
Jordan Rose 127f6eef7e [-E] Emit a rewritten _Pragma on its own line.
1. Teach Lexer that pragma lexers are like macro expansions at EOF.
2. Treat pragmas like #define/#undef when printing.
3. If we just printed a directive, add a newline before any more tokens.
(4. Miscellaneous cleanup in PrintPreprocessedOutput.cpp)

PR10594 and <rdar://problem/11562490> (two separate related problems)

llvm-svn: 158571
2012-06-15 23:33:51 +00:00
Alexis Hunt 2178f14c10 Stop referring to functions as methods in per-function fallthrough-checking.
llvm-svn: 158545
2012-06-15 21:22:05 +00:00
Jordan Rose 9da05858b4 [completion] Add completions for @"..." and @(...), and tidy up @[] and @{}.
Specifically, @[] and @{} didn't have a type associated with them; we now
use "NSArray *" and "NSDictionary *", respectively. @"" has the type
"NSString *". @(), unfortunately, has type "id", since it (currently) may
be either an NSNumber or an NSString.

Add a test for all the Objective-C at-expression completions.

<rdar://problem/11507708&11507668&11507711>

llvm-svn: 158533
2012-06-15 18:19:56 +00:00
Jordan Rose 95dfae824e [analyzer] RetainCount: don't track objects init'd with a delegate
We already didn't track objects that have delegates or callbacks or
objects that are passed through void * "context pointers". It's a
not-uncommon pattern to release the object in its callback, and so
the leak message we give is not very helpful.

llvm-svn: 158532
2012-06-15 18:19:52 +00:00