Commit Graph

7058 Commits

Author SHA1 Message Date
Douglas Gregor c45c287ab6 Overriding the predefined Protocol isn't something that's actually
done and is likely to not work well anyway; take away this unnecessary
complexity.

llvm-svn: 137465
2011-08-12 17:09:30 +00:00
Douglas Gregor 801c99d22d Switch the __int128_t and __uint128_t types over to predefined types
in the AST format, which are built lazily by the ASTContext when
requested.

llvm-svn: 137437
2011-08-12 06:49:56 +00:00
Douglas Gregor 52e02808c5 Switch the Objective-C 'SEL' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.

llvm-svn: 137434
2011-08-12 06:17:30 +00:00
Douglas Gregor 0a58618a09 Switch the Objective-C 'Class' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.

llvm-svn: 137431
2011-08-12 05:59:41 +00:00
Douglas Gregor 3ea7269b54 Move the creation of the predefined typedef for Objective-C's 'id'
type over into the AST context, then make that declaration a
predefined declaration in the AST format. This ensures that different
AST files will at least agree on the (global) declaration ID for 'id',
and eliminates one of the "special" types in the AST file format.

llvm-svn: 137429
2011-08-12 05:46:01 +00:00
Richard Trieu aee9e76722 The current warning in -Wnull-arithmetic for comparisons between NULL and non-pointers is not very helpful. This patch will update the wording to be more helpful to users.
Old warning:

warning: use of NULL in arithmetic operation [-Wnull-arithmetic]
  return 10 <= NULL;
            ^  ~~~~

New warning:

warning: comparison between NULL and non-pointer ('int' and NULL) [-Wnull-arithmetic]
  return 10 <= NULL;
         ~~ ^  ~~~~
llvm-svn: 137377
2011-08-11 22:38:21 +00:00
Douglas Gregor 9767347b11 Encapsulate the Objective-C id/Class/SEL "redefinition" types in
ASTContext with accessors/mutators. The only functional change is that
the AST writer won't bother writing the id/Class/SEL redefinition type
if it hasn't been explicitly set; previously, it ended up being
written as a synonym for the built-in id/Class/SEL.

llvm-svn: 137349
2011-08-11 20:58:55 +00:00
Richard Trieu 73088053f5 Refactoring of DiagnoseBitwisePrecedence() in SemaExpr.cpp to reduce code duplication.
llvm-svn: 137259
2011-08-10 22:41:34 +00:00
Douglas Gregor de0a43f772 When performing the lookup in the current scope for a member access to
a member template, e.g.,

  x.f<int>

if we have found a template in the type of x, but the lookup in the
current scope is ambiguous, just ignore the lookup in the current
scope.  Fixes <rdar://problem/9915664>.

llvm-svn: 137255
2011-08-10 21:59:45 +00:00
Kaelyn Uhrain 0fb0bb179a Add a test case for the divide-by-zero fix in r137234
llvm-svn: 137240
2011-08-10 19:47:25 +00:00
Kaelyn Uhrain e535376b14 Make sure ptrarith_typesize is at least 1 to avoid division by zero
llvm-svn: 137234
2011-08-10 18:49:28 +00:00
Fariborz Jahanian 3c12dd7675 objective-c: Using existing infrastructure for finding
overridden  methods to diagnose their type mismatch.
This is a general solution for previous fixes
for // rdar://6191214 and // rdar://9352731
and removes lots of duplicate code.

llvm-svn: 137222
2011-08-10 17:16:30 +00:00
Douglas Gregor 5c076db18e When adding the base and member initializers for an implicitly-defined
special member function, make sure to classify an explicitly-defaulted
copy constructor as a "copy" operation. Fixes PR10622.

llvm-svn: 137219
2011-08-10 16:51:53 +00:00
Douglas Gregor 05a51ae0cf Update a comment to match the recently-changed code
llvm-svn: 137216
2011-08-10 16:09:55 +00:00
Douglas Gregor 6f47e5cabf For the availability attribute, allow a declaration to be deprecated
in the same version that it is introduced. Stuff happens.

llvm-svn: 137214
2011-08-10 15:31:35 +00:00
Douglas Gregor 493627ba8b Rewrite default initialization of anonymous structs/unions within a
constructor. Previously, we did some bogus recursion into the fields
of anonymous structs (recursively), which ended up building invalid
ASTs that would cause CodeGen to crash due to invalid GEPs.

Now, we instead build the default initializations based on the
indirect field declarations at the top level, which properly generates
the sequence of GEPs needed to initialize the proper member. Fixes
PR10512 and <rdar://problem/9924046>.

llvm-svn: 137212
2011-08-10 15:22:55 +00:00
John McCall 9a877fef91 Change an assert into a check. I'm pretty sure there was a point
in time when this assert was valid, but it's not valid now.
Also teach this code to correctly introduce function-to-pointer
decay.

llvm-svn: 137201
2011-08-10 04:12:23 +00:00
Caitlin Sadowski 4b1e8399c2 Thread Safety: Added basic argument parsing for all new attributes.
This patch special cases the parser for thread safety attributes so that all
attribute arguments are put in the argument list (instead of a special
parameter) since arguments may not otherwise resolve correctly without two-token
lookahead.

This patch also adds checks to make sure that attribute arguments are
lockable objects.

llvm-svn: 137130
2011-08-09 17:59:31 +00:00
Douglas Gregor 3d63a9e501 Make sure to canonicalize the argument type of a non-type template
argument of enumeration type when checking template arguments. Fixes PR10579.

llvm-svn: 137101
2011-08-09 01:55:14 +00:00
Fariborz Jahanian c1a151bed9 Don't emit memcpy for copying fields of arrays of volatile elements.
Use the the path that generates a loop. This fixes
bogus error that clang puts out. // rdar://9894548

llvm-svn: 137080
2011-08-09 00:26:11 +00:00
Fariborz Jahanian 5ac085ab3a objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) 
"conformsTo" two protocols which conflict (have methods which conflict).
This patch fixes the previous patch where warnings were coming out in
non-deterministic order.  This is 2nd part of // rdar://6191214.

llvm-svn: 137055
2011-08-08 18:03:17 +00:00
Kaelyn Uhrain 6242220966 Make sure FunctionDecls aren't considered during overload resolution if there
are explicit template args.

llvm-svn: 137054
2011-08-08 17:35:31 +00:00
David Chisnall 9291851b13 Silence the category-replacing-class-method warning for +load: category
implementations of +load do not replace the class definition in a meaningful
sense, they are run when the category loads, the +load method for class is run
when the class is loaded.

llvm-svn: 137053
2011-08-08 17:32:19 +00:00
John McCall 5939b16135 Do l-value conversion, etc., on a switch condition expression in
ActOnStartOfSwitchStmt (i.e. before binding up a full-expression)
instead of ActOnFinishSwitchStmt.

Among other things, this means that property l-values are properly
converted inside the full-expression.

llvm-svn: 137014
2011-08-06 07:30:58 +00:00
Benjamin Kramer 8c54367935 Only look at decls after the current one when checking if it's the last field in a record.
llvm-svn: 137009
2011-08-06 03:04:42 +00:00
Ted Kremenek 1cd34b8fea Revert 136984 and 136927.
llvm-svn: 136998
2011-08-05 23:31:22 +00:00
Kaelyn Uhrain 2e7aa5ae1f Perform array bounds checking in more situations and properly handle special
case situations with the unary operators & and *. Also extend the array bounds
checking to work with pointer arithmetic; the pointer arithemtic checking can
be turned on using -Warray-bounds-pointer-arithmetic.

The changes to where CheckArrayAccess gets called is based on some trial &
error and a bunch of digging through source code and gdb backtraces in order
to have the check performed under as many situations as possible (such as for
variable initializers, arguments to function calls, and within conditional in
addition to the simpler cases of the operands to binary and unary operator)
while not being called--and triggering warnings--more than once for a given
ArraySubscriptExpr.

llvm-svn: 136997
2011-08-05 23:18:04 +00:00
Roman Divacky 30097b7c41 Let attribute((cdecl)) and company override -mrtd default calling convention.
llvm-svn: 136971
2011-08-05 16:37:22 +00:00
Chandler Carruth 28389f0cdf Flesh out the -Warray-bounds detection of C89 tail-padded one-element
arrays. This now suppresses the warning only in the case of
a one-element array as the last field in a struct where the array size
is a literal '1' rather than any macro expansion or template parameter.

This doesn't distinguish between the language standard in use to allow
code which dates from C89 era to compile without the warning even in C99
and C++ builds. We could add a separate warning (under a different flag)
with fixit hints to switch to a flexible array, but its not clear that
this would be desirable. Much of the code using this idiom is striving
for maximum portability.

Tests were also fleshed out a bit, and the diagnostic itself tweaked to
be more pretty w.r.t. single elment arrays. This is more ugly than
I would like due to APInt's not being supported by the diagnostic
rendering engine.

A pseudo-patch for this was proposed by Nicola Gigante, but I reworked
it both for several correctness issues and for code style.

Sorry this was so long in coming.

llvm-svn: 136965
2011-08-05 09:10:50 +00:00
Chandler Carruth 126b155429 Finally getting around to re-working this to more accurately white-list
1-element character arrays which are serving as flexible arrays. This is
the initial step, which is to restrict the 1-element array whitelist to
arrays that are member declarations. I'll refine it from here based on
the proposed patch.

llvm-svn: 136964
2011-08-05 08:07:29 +00:00
Matt Beaumont-Gay 3c48990a46 Extend memset/memcpy/memmove checking to include memcmp
llvm-svn: 136950
2011-08-05 00:22:34 +00:00
Kaelyn Uhrain 4283092a4b Have the typo correction in DiagnoseEmptyLookup properly handle template
functions when performing function overload resolution.

llvm-svn: 136948
2011-08-05 00:09:52 +00:00
Kaelyn Uhrain ea350180d2 Fix a small bug where DiagnoseEmptyLookup would no longer print any messages
when performing typo correction involving any overloaded template functions.

The added test cases, while currently demontrating sub-optimal behavior, will
not trigger any messages without the 1-line change to SemaExpr.cpp.

llvm-svn: 136943
2011-08-04 23:30:54 +00:00
Matt Beaumont-Gay a17cf6330f Specialize diag::warn_unused_call for the "warn_unused_result" attribute, so
it can be controlled with a distinct flag.

llvm-svn: 136941
2011-08-04 23:11:04 +00:00
Fariborz Jahanian 6a86844161 objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) 
"conformsTo" two protocols which conflict (have methods which conflict).
This is 2nd part of // rdar://6191214.

llvm-svn: 136927
2011-08-04 21:28:44 +00:00
Kaelyn Uhrain 7d9bc633d2 Match type names and give more info for out-of-line function definition errors.
Having a function declaration and definition with different types for a
parameter where the types have same (textual) name can occur when an unqualified
type name resolves to types in different namespaces in each location.

The error messages have been extended by adding notes that point to the first
parameter of the function definition that doesn't match the declaration, instead
of a generic "member declaration nearly matches". The generic message is still
used in cases where the mismatch is not in the paramenter list, such as
mismatched cv qualifiers on the member function itself.

llvm-svn: 136891
2011-08-04 17:40:00 +00:00
Fariborz Jahanian 7de631cc40 Refactoring of my last patch.
llvm-svn: 136841
2011-08-03 23:44:01 +00:00
Kaelyn Uhrain acbdc5748e Improve overloaded function handling in the typo correction code.
Change TypoCorrection to store a set of NamedDecls instead of a single
NamedDecl. Also add initial support for performing function overload
resolution to Sema::DiagnoseEmptyLookup.

llvm-svn: 136807
2011-08-03 20:36:05 +00:00
Fariborz Jahanian 2bda1b65b1 objective-c: Methods declared in methods must type match
those declated in its protocols. First half or // rdar://6191214

llvm-svn: 136794
2011-08-03 18:21:12 +00:00
Douglas Gregor 1d394809b4 Make the type of the IntegerLiteral for bitfield paddings an actual
integer, and initialise its TypeSourceInfo. The initialisation fixes a
crash when using pre-compiled preambles with C++ code-completion. From
Erik Verbruggen! Fixes PR10511.

llvm-svn: 136786
2011-08-03 16:26:46 +00:00
John McCall 32a4da04c2 In ARC, don't try to reclaim the result of a call to performSelector
unless done in a context where the value is used retained.

llvm-svn: 136769
2011-08-03 07:02:44 +00:00
Chris Lattner f51dae0378 disable array bounds overflow warning for cases where an array
has a single element.  This disables the warning in cases where
there is a clear bug, but this is really rare (who uses arrays
with one element?) and it also silences a large class of false
positive issues with C89 code that is using tail padding in structs.

A better version of this patch would detect when an array is in
a tail position in a struct, but at least patch fixes the huge
false positives that are hitting postgres and other code.

llvm-svn: 136724
2011-08-02 21:44:23 +00:00
Benjamin Kramer 3c05b7c161 Make helper functions static.
llvm-svn: 136679
2011-08-02 04:50:49 +00:00
Richard Trieu cfc491d308 Fix formatting of SemaExpr.cpp, mainly fixing lines greater than 80 characters.
No functional change.

llvm-svn: 136678
2011-08-02 04:35:43 +00:00
Fariborz Jahanian e1506cbfda objective-c: reverse patch for // rdar://9818354
llvm-svn: 136658
2011-08-01 22:39:49 +00:00
Douglas Gregor 5ff4e98c61 Introduce a Fix-It for the "missing sentinel" warning, adding an
appropriate sentinel at the end of the argument list. Also, put the
sentinel warnings under -Wsentinel. Fixes <rdar://problem/8764236>.

llvm-svn: 136566
2011-07-30 08:57:03 +00:00
Douglas Gregor 4ecb7209bf Add code completion to produce "else" blocks after an "if"
statement. Fixes <rdar://problem/9229438>.

llvm-svn: 136564
2011-07-30 08:36:53 +00:00
Douglas Gregor 0c50531a46 When producing code completion results for variadic macros, fold the
variadic bit (", ..." or ", args...") into the prior placeholder, like
we do with functions and methods. Fixes <rdar://problem/9740808>.

llvm-svn: 136563
2011-07-30 08:17:44 +00:00
Douglas Gregor 8f08d74ee5 Add the various parameter-passing keywords for Distributed Objects
(such as in, inout, byref, and oneway) to code completion
results. Fixes <rdar://problem/8844158>.

llvm-svn: 136562
2011-07-30 07:55:26 +00:00
Douglas Gregor 2c595adf2e When performing code completion after at @interface, allow both
already-defined and forward-declared results. Already-defined results
are fine because they could be the start of a category. Fixes
<rdar://problem/9811691>.

llvm-svn: 136559
2011-07-30 06:55:39 +00:00
Douglas Gregor 7e1eb935db When complaining about a non-POD second argument to va_arg, use a
special diagnostic for ARC ownership-qualified types. We wouldn't want
to expose Objective-C programmers to the term "POD", would we? Fixes
<rdar://problem/9772982>.

llvm-svn: 136558
2011-07-30 06:45:27 +00:00
Peter Collingbourne 3bc84ca376 Fix an inconsistency in Sema::ConvertArgumentsForCall in that
the callee note diagnostic was not emitted in the case where
there were too few arguments.

llvm-svn: 136437
2011-07-29 00:24:42 +00:00
Fariborz Jahanian 9f8b19e9ae objective-c: warn if implementation of a method in category
masks an existing method in its primary class, class extensions,
and primary class's non-optional protocol methods; as primary
class, or one of its subclass's will implement this method.
This warning has potential of being noisy so it has its own
group.  // rdar://7020493

llvm-svn: 136426
2011-07-28 23:19:50 +00:00
Anna Zaks 964f4c6147 Add a fixit for removal of unused label.
llvm-svn: 136389
2011-07-28 20:52:06 +00:00
Caitlin Sadowski 63fa667c68 Added basic parsing for all remaining attributes, thread safety
analysis. This includes checking that the attributes are applied in the
correct contexts and with the correct number of arguments.

llvm-svn: 136383
2011-07-28 20:12:35 +00:00
Anna Zaks 3b402716b1 Add */& mismatch fixit generation to the Sema::DiagnoseAssignmentResult().
llvm-svn: 136379
2011-07-28 19:51:27 +00:00
Douglas Gregor e39f97c869 Make the deserialization of Sema::PendingInstantiations lazy. At this
point, ASTReader::InitializeSema() has very little interesting work,
*except* issues stemming from preloaded declarations. That's something
we'll still need to cope with.

llvm-svn: 136378
2011-07-28 19:49:54 +00:00
Anna Zaks 1b06812f46 Refactor the */& mismatch fixit generation out of SemaOverload and provide a simple conversion checking function.
llvm-svn: 136376
2011-07-28 19:46:48 +00:00
Douglas Gregor 4daf6a30e7 Lazily deserialize Sema::VTableUses. Plus, fix the utterly and
completely broken deserialization mapping code we had for VTableUses,
which would have broken horribly as soon as our local-to-global ID
mapping became interesting.

llvm-svn: 136371
2011-07-28 19:11:31 +00:00
Douglas Gregor 1c4bfe5ac6 Make Sema::WeakUndeclaredIdentifiers lazily deserialized.
llvm-svn: 136368
2011-07-28 18:09:57 +00:00
Caitlin Sadowski aac4d21ba7 Added parsing for guarded_var, pt_guarded_var, lockable,
scoped_lockable, and no_thread_safety_analysis attributes, all for thread safety analysis

llvm-svn: 136364
2011-07-28 17:21:07 +00:00
Douglas Gregor 72e357fc60 Make Sema::ReferencedSelectors lazily deserialized.
llvm-svn: 136357
2011-07-28 14:54:22 +00:00
Douglas Gregor dc5c958602 Make Sema::LocallyScopedExternalDecls lazily deserialized. In theory,
we could turn this into an on-disk hash table so we don't load the
whole thing the first time we need it. However, it tends to be very,
very small (i.e., empty) for most precompiled headers, so it isn't all
that interesting.

llvm-svn: 136352
2011-07-28 14:20:37 +00:00
Douglas Gregor 32002197b2 Switch Sema::DynamicClasses over to LazyVector
llvm-svn: 136317
2011-07-28 00:53:40 +00:00
Douglas Gregor b7098a38b3 Switch Sema::ExtVectorDecls over to LazyVector.
llvm-svn: 136314
2011-07-28 00:39:29 +00:00
Douglas Gregor bae31201bb Turn Sema::DelegatingCtorDecls into a LazyVector.
llvm-svn: 136273
2011-07-27 21:57:17 +00:00
John McCall d9bb743e0d The lock operand to an @synchronized statement is also
supposed to be a full-expression;  make it so.  In ARC, make sure
we retain the lock for the entire protected block. 

llvm-svn: 136271
2011-07-27 21:50:02 +00:00
Douglas Gregor a94a1544d8 Switch Sema::UnusedFileScopedDecls over to a LazyVector.
- Added LazyVector::erase() to support this use case.
  - Factored out the LazyDecl-of-Decls to RecordData translation in
  the ASTWriter. There is still a pile of code duplication here to
  eliminate.

llvm-svn: 136270
2011-07-27 21:45:57 +00:00
Douglas Gregor eb08bd48e6 Introduce a new data structure, LazyVector, which is a vector whose
contents are lazily loaded on demand from an external source (e.g., an
ExternalASTSource or ExternalSemaSource). The "loaded" entities are
kept separate from the "local" entities, so that the two can grow
independently.

Switch Sema::TentativeDefinitions from a normal vector that is eagerly
populated by the ASTReader into one of these LazyVectors, making the
ASTReader a bit more like me (i.e., lazy).

llvm-svn: 136262
2011-07-27 20:58:46 +00:00
Peter Collingbourne 8f5f520653 Forbid address-space-qualified function types, per TR 18037
llvm-svn: 136257
2011-07-27 20:30:05 +00:00
Peter Collingbourne 78769e691a Fix TR 18037 citation in SemaType.cpp
llvm-svn: 136256
2011-07-27 20:29:53 +00:00
Douglas Gregor fb65e592e0 Add support for C++0x unicode string and character literals, from Craig Topper!
llvm-svn: 136210
2011-07-27 05:40:30 +00:00
John McCall 538482373b Clean up the analysis of the collection operand to ObjC
for-in statements;  specifically, make sure to close over any
temporaries or cleanups it might require.  In ARC, this has
implications for the lifetime of the collection, so emit it
with a retain and release it upon exit from the loop.

rdar://problem/9817306

llvm-svn: 136204
2011-07-27 01:07:15 +00:00
Francois Pichet b23dc0950b In Microsoft mode, if we are within a templated function and we can't resolve Identifier during BuildCXXNestedNameSpecifier, then extend the SS with Identifier. This will have the effect of resolving Identifier during template instantiation. The goal is to be able to resolve a function call whose nested-name-specifier is located inside a dependent base class.
class C {
public:
    static void foo2() {  }
};

template <class T> class A {
public:
   typedef C D;
};

template <class T> class B : public A<T> {
public:
  void foo() { D::foo2(); }
};

Note that this won't work if the NestedNameSpecifier refers to a type.
This fixes 1 error when parsing the MSVC 2010 standard headers file with clang.

llvm-svn: 136203
2011-07-27 01:05:24 +00:00
Eli Friedman 1b71a22b28 Re-fix r136172 so it isn't an error; apparently, some people are fond of their undefined behavior.
llvm-svn: 136183
2011-07-26 23:27:24 +00:00
Jeffrey Yasskin a6667816d5 This patch implements as much of the narrowing conversion error specified by
[dcl.init.list] as is possible without generalized initializer lists or full
constant expression support, and adds a c++0x-compat warning in C++98 mode.

The FixIt currently uses a typedef's basename without qualification, which is
likely to be incorrect on some code.  If it's incorrect on too much code, we
should write a function to get the string that refers to a type from a
particular context.

The warning is currently off by default. I'll fix LLVM and clang before turning
it on.

llvm-svn: 136181
2011-07-26 23:20:30 +00:00
Eli Friedman 1260f59f5e Diagnose trying to delete a pointer to an abstract class with a non-virtual destructor. PR10504.
I'm not completely sure the standard allows us to reject this, but if it doesn't, it should. :)

llvm-svn: 136172
2011-07-26 22:50:18 +00:00
Eli Friedman ae4280f721 A couple minor issues with Sema for delete:
1. Attempting to delete an expression of incomplete class type should be an error, not a warning.

2. If someone tries to delete a pointer to an incomplete class type, make sure we actually emit
the delete expression after we warn.

llvm-svn: 136161
2011-07-26 22:25:31 +00:00
Argyrios Kyrtzidis e3be9795c8 In ARC we emit an error when compiling:
@interface Foo : NSObject
@property (readonly) id myProp;
@end

@implementation Foo
@synthesize myProp;
@end

t.m:9:13: error: ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute
@synthesize myProp;
            ^

which is fine, we want the ownership of the synthesized ivar to be explicit. But we should _not_ emit an error
for the following cases, because we can get the ownership either from the declared ivar or from the property type:

@interface Foo : NSObject {
	__weak id _myProp1;
	id myProp2;
}
@property (readonly) id myProp1;
@property (readonly) id myProp2;
@property (readonly) __strong id myProp3;
@end

@implementation Foo
@synthesize myProp1 = _myProp1;
@synthesize myProp2;
@synthesize myProp3;
@end

rdar://9844006.

llvm-svn: 136155
2011-07-26 21:48:26 +00:00
Kaelyn Uhrain c45dcd2594 Revert r136046 while fixing handling of e.g. &foo[index_one_past_size]
llvm-svn: 136113
2011-07-26 18:36:36 +00:00
Fariborz Jahanian 6507135e12 Provide fixit for static use of objective-c type
in few more places and in each instance, fix up
the type to the expected type. // rdar://9603056

llvm-svn: 136103
2011-07-26 17:58:54 +00:00
Benjamin Kramer 632500cb85 Eliminate a bunch of temporary strings.
llvm-svn: 136092
2011-07-26 16:59:25 +00:00
Douglas Gregor ea777403f9 Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!

llvm-svn: 136084
2011-07-26 15:24:30 +00:00
Douglas Gregor 72912fb9a4 When we decide not to rebuild an instantiated C++ 'new' expression
that allocates an array of objects with a non-trivial destructor, be
sure to mark the destructor is "used". Fixes PR10480 /
<rdar://problem/9834317>.

llvm-svn: 136081
2011-07-26 15:11:03 +00:00
Douglas Gregor a4f2b430e0 Objective-C++ ARC: When performing template argument deduction for a
lifetime-qualified template parameter, ensure that the deduced
template argument is a lifetime type. Fixes <rdar://problem/9828157>.

llvm-svn: 136078
2011-07-26 14:53:44 +00:00
Chandler Carruth c22845abe2 Cleanup the stray comments and variables I could dig out of Sema to
refer to 'expansion' instead of 'instantiation'.

llvm-svn: 136060
2011-07-26 05:40:03 +00:00
Kaelyn Uhrain 980bdb9dfb Expand array bounds checking to work in the presence of unary & and *,
and to work with pointer arithmetic in addition to array indexing.

The new pointer arithmetic porition of the array bounds checking can be
turned on by -Warray-bounds-pointer-arithmetic (and is off by default).

llvm-svn: 136046
2011-07-26 01:52:28 +00:00
Kaelyn Uhrain 15a67b97df Test commit
llvm-svn: 136044
2011-07-26 01:42:22 +00:00
Fariborz Jahanian 9a14c21cfd objective-c: Provide a 'fixit' when class was used
to declare a static object. // rdar://9603056

llvm-svn: 135970
2011-07-25 21:12:27 +00:00
Douglas Gregor c1679ecf3b Added clang_getCursorReferenceNameRange to libclang to to retrieve parts of
a cursor reference, from Erik Verbruggen!

llvm-svn: 135920
2011-07-25 17:48:11 +00:00
Chandler Carruth 35f5320d8e Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

llvm-svn: 135914
2011-07-25 16:49:02 +00:00
Fariborz Jahanian 4ceec3f0d1 objc: clang should warn if redeclaration of methods
declared in protocol in the class qualified by the
protocol have type conflicts. To reduce amount of
noise, this is done when class is implemented.
// rdar://9352731

llvm-svn: 135890
2011-07-24 20:53:26 +00:00
Douglas Gregor 38b2d3fa3e Tests for explicit conversion operators, along with a fix to avoid
considering explicit conversion operators when determining surrogate
functions. Fixes PR10453. Note that there are a few test cases where
Clang is still wrong because it does not implement DR899; see PR10456.

Patch by Jonathan Sauer!

llvm-svn: 135857
2011-07-23 18:59:35 +00:00
Chris Lattner 54b1677d23 Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon Mulder!
llvm-svn: 135855
2011-07-23 17:14:25 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
David Majnemer fa01a583e7 kill a FIXME in IsIntegralPromotion
IsIntegralPromotion should consider the signedness of FromType when
calculating promotions. This, as of now, cannot be exercised on any
platform so there is no corresponding test.

llvm-svn: 135803
2011-07-22 21:09:04 +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
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 0410e572b9 Move this ObjCImplementationDecl member function into libAST
where it belongs.

llvm-svn: 135746
2011-07-22 04:15:06 +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
Jordy Rose a91768e569 Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.

llvm-svn: 135741
2011-07-22 02:08:32 +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
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
Eric Christopher 6f228b5a53 Speculatively revert 135649 to bring back the g++ testing bots.
llvm-svn: 135668
2011-07-21 05:34:24 +00:00
Ted Kremenek 189ecec4db Simplify passing of CFGBuildOptions around for AnalysisContext. No functionality change.
llvm-svn: 135666
2011-07-21 05:22:47 +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
Alexis Hunt 4ace035c55 When copping out on a friend template declaration, be sure to mark its
access specifier as public.

llvm-svn: 135649
2011-07-21 00:59:23 +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 517695b27c objc-arc: Fixes a crash @throw'ing an objc message.
// pr10411

llvm-svn: 135638
2011-07-20 23:39:56 +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
Chris Lattner 01cf8db38b now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector.  This cleans up the codebase
quite a bit.

llvm-svn: 135576
2011-07-20 06:58:45 +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
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
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
Chris Lattner 83cfc7c03a Use the new llvm::TinyPtrVector class, which implements exactly what
ShadowMapEntry was.

llvm-svn: 135368
2011-07-18 01:54:02 +00:00
Benjamin Kramer e492cb41b7 Zero this struct in a way that neither depends on the size of the struct nor triggers warnings from GCC.
llvm-svn: 135351
2011-07-16 20:13:06 +00:00
Fariborz Jahanian 8809a9d91c Remove a gcc warning.
llvm-svn: 135348
2011-07-16 18:31:33 +00:00
Fariborz Jahanian f9ae68af85 Fix a typo.
llvm-svn: 135328
2011-07-16 00:08:33 +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
Jeffrey Yasskin d0f079dad4 Use the new APFloat::convertToInt(APSInt) function to simplify uses of
convertToInt(integerParts*) and make them more reliable.

llvm-svn: 135279
2011-07-15 17:03:07 +00:00
Douglas Gregor e9d62935d3 Store bracket locations for array subscript expressions, from Erik Verbruggen!
llvm-svn: 135275
2011-07-15 16:25:15 +00:00
Douglas Gregor 397745e540 When creating a property in a class extension, make sure to check its
attributes. Fixes <rdar://problem/9561076>.

llvm-svn: 135273
2011-07-15 15:30:21 +00:00
John McCall 6730e4d904 Restore the C-style cast hack for enum template arguments,
which is required given the current setup for template
argument deduction substitution validation, and add a test
case to make sure we don't break it in the future.

llvm-svn: 135262
2011-07-15 07:47:58 +00:00
John McCall 7c454bb8ce Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.

llvm-svn: 135243
2011-07-15 05:09:51 +00:00
Richard Trieu cfe3926ae9 Remove warnings of constant operands of logical operators from template instantiations. Upon instantiation of template, value-dependent parameters are replaced by equivalent literals, so code like:
template<unsigned int A, unsigned int B> struct S {
  int foo() {
    int x = A && B;
  }
}

will not warn on A && B on every instantiation.  This will still warn on other cases inside templates, which will be caught on checking the template definition.

llvm-svn: 135222
2011-07-15 00:00:51 +00:00
Rafael Espindola 699fc4d15c Revert 135177 to fix PR10363.
Revert "For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either."

This reverts commit ac420c5053d6aa41d59f782caad9e46e5baaf2c2.

llvm-svn: 135210
2011-07-14 22:58:04 +00:00
John McCall 5143181ff9 Teach -Wconversion, -Wsign-compare etc. about division and remainder.
llvm-svn: 135208
2011-07-14 22:39:48 +00:00
Sebastian Redl 9c61809c23 For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either.
This is a first baby step towards supporting generalized initializer lists. This also removes an aggregate
test case that was just plain wrong, assuming that non-aggregates couldn't be initialized with initializer lists
in C++11 mode.

llvm-svn: 135177
2011-07-14 19:08:10 +00:00
Sebastian Redl 112aa826c7 Remove InitializationSequence::ReferenceBinding, the last redundant sequence kind.
llvm-svn: 135175
2011-07-14 19:07:55 +00:00
Douglas Gregor 5cf0e1534a Add a hackaround to avoid the crash in PR10355. However, our recovery
is still terrible here because typo correction is not behaving well in
the presence of overloaded functions.

llvm-svn: 135128
2011-07-14 04:54:23 +00:00
Richard Smith 48d2464c3f PR8800: When building a conversion to A& using a member operatorA&(), do not require A to be a complete type.
llvm-svn: 135101
2011-07-13 22:53:21 +00:00
Douglas Gregor ad69e65a39 Add 'mutable' to the function declarator chunk, to be used when
parsing lambda expressions, from John Freeman!

llvm-svn: 135090
2011-07-13 21:47:47 +00:00
Douglas Gregor 385cfc073e Fix an incorrect namespace typo-correction diagnostic, from Kaelyn
Uhrain! Fixes PR10318.

llvm-svn: 135086
2011-07-13 21:36:26 +00:00
John McCall 928a25714e Enforce access control for the destructor in a new[] expression and mark
it as used.  Otherwise, we can fail to instantiate or validate the destructor,
which can lead to crashes in IR gen like PR10351.

llvm-svn: 135073
2011-07-13 20:12:57 +00:00
Fariborz Jahanian 9a881019a5 With -Wselector, don't warn about unimplemented optional method
used in @selector expression because, well, their implementation 
is optional. // rdar://9545564

llvm-svn: 135057
2011-07-13 19:05:43 +00:00
John McCall 3f4138c5d0 In debugger mode, make ObjC message sends to unknown selectors return
__unknown_anytype, and rewrite such message sends correctly.

I had to bite the bullet and actually add a debugger support mode for this
one, which is a bit unfortunate, but there really isn't anything else
I could imagine doing;  this is clearly just debugger-specific behavior.

llvm-svn: 135051
2011-07-13 17:56:40 +00:00
Fariborz Jahanian 17585e7940 objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. Use common code for
objc and objc++ so they don't diverge. // rdar://9740328

llvm-svn: 135050
2011-07-13 17:55:01 +00:00
John McCall c368838b20 Make the integer-range analysis recognize ^= correctly,
and (while I'm at it) teach it to grok the results of simple
assignments.

The first is PR10336.

llvm-svn: 135034
2011-07-13 06:35:24 +00:00
Douglas Gregor d29fde248e Eliminate an incomplete/incorrect attempt to provide support for C++0x
unrestricted unions, which ended up attempting to initialize objects
in a union (which CodeGen isn't prepared for). Fixes PR9683.

llvm-svn: 135027
2011-07-13 02:14:02 +00:00
Fariborz Jahanian c0f6af2103 objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. // rdar://9740328

llvm-svn: 135001
2011-07-12 22:05:16 +00:00
Fariborz Jahanian 7f4427fc60 Fix a bug where a local variable named 'self' is causing
implicit ivar accesses to go through the 'self' variable
rather than the real 'self' for the method. // rdar://9730771

llvm-svn: 134992
2011-07-12 17:16:56 +00:00
Benjamin Kramer a4fb836f06 Pop block scope after reading from it.
Found by valgrind.

llvm-svn: 134983
2011-07-12 14:11:05 +00:00
Hans Wennborg 38198ded24 Fix typo correction crash on overloaded functions, pr10283.
It would be cool if we could do overload resolution to suggest
the right function, but at least this fixes the crashing.

llvm-svn: 134976
2011-07-12 08:45:31 +00:00
Douglas Gregor 842806450c Centralize the getCanonicalType() calls in the Itanium C++ mangling
code so that they only occur in a single place. No functionality change.

llvm-svn: 134961
2011-07-12 04:42:08 +00:00
Argyrios Kyrtzidis 52bfc2b668 [ARC] Complain about property without storage attribute when @synthesizing it, not at its declaration.
For this sample:

@interface Foo
@property id x;
@end

we get:

t.m:2:1: error: ARC forbids properties of Objective-C objects with unspecified storage attribute
@property  id x;
^
1 error generated.

The error should be imposed on the implementor of the interface, not the user. If the user uses
a header of a non-ARC library whose source code he does not have, we are basically asking him to
go change the header of the library (bad in general), possible overriding how the property is
implemented if he gets confused and says "Oh I'll just add 'copy' then" (even worse).

Second issue is that we don't emit any error for 'readonly' properties, e.g:

@interface Foo
@property (readonly) id x; // no error  here
@end

@implementation Foo
@synthesize x; // no error here too
@end

We should give an error when the implementor is @synthesizing a property which doesn't have
any storage specifier; this is when the explicit specifier is important, because we are
going to create an ivar and we want its ownership to be explicit.

Related improvements:
-OBJC_PR_unsafe_unretained turned out to not fit in ObjCPropertyDecl's bitfields, fix it.
-For properties of extension classes don't drop PropertyAttributesAsWritten values.
-Have PropertyAttributesAsWritten actually only reflect what the user wrote

rdar://9756610.

llvm-svn: 134960
2011-07-12 04:30:16 +00:00
Chandler Carruth 9312c6464d Style tweak to the more idiomatic 'assert(!bad_state())'.
Patch by Caitlin Sadowski.

llvm-svn: 134938
2011-07-11 23:33:05 +00:00
Chandler Carruth fcc48d9e71 Hoist the logic for checking the number of arguments to an attribute
into a static helper.

Original patch by Caitlin Sadowski, style tweaks by me.

llvm-svn: 134937
2011-07-11 23:30:35 +00:00
Eli Friedman 6290ae476e Add diagnostic for constructs like "va_arg(l, float)" which have undefined behavior. PR10201.
llvm-svn: 134926
2011-07-11 21:45:59 +00:00
Fariborz Jahanian 256d39d47d objc-arc: Diagnose when captured variable in block literals
require destruction and there is possibility of that without
construction. Thanks Johnm for review and suggestions offline.
// rdar://9535237.

llvm-svn: 134906
2011-07-11 18:04:54 +00:00
Douglas Gregor 9824aec830 Don't complain about missing return statements for naked
functions. Fixes <rdar://problem/9731999>.

llvm-svn: 134897
2011-07-11 15:24:01 +00:00
Abramo Bagnara dd8fc04e9b Fixed PR10243.
llvm-svn: 134892
2011-07-11 08:52:40 +00:00
Benjamin Kramer 581f48f583 Initialize all the AnalysisBasedWarnings statistics to zero.
Found by valgrind.

llvm-svn: 134733
2011-07-08 20:38:53 +00:00
Benjamin Kramer 65cc1074f3 Remove unused variable.
llvm-svn: 134731
2011-07-08 20:20:17 +00:00
Fariborz Jahanian f2913401fc objc++-arc: more diagnosis of converting a weak-unavailable
object to a __weak object type. // rdar://9732636

llvm-svn: 134706
2011-07-08 17:41:42 +00:00
Francois Pichet 3a44e43d40 Random cleanup:
- fix a comment.
- Remove an unnecessary { } block.

llvm-svn: 134690
2011-07-08 06:21:47 +00:00
Fariborz Jahanian 7fcce6829d objc++-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
One item is yet todo.

llvm-svn: 134655
2011-07-07 23:04:17 +00:00
Fariborz Jahanian 6f472e803b objc-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
This is objc side of things. objc++ side tbd.

llvm-svn: 134624
2011-07-07 18:55:47 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
John McCall 4db5c3c83a In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value.

As an exception, don't do this when the call is made as the immediate
operand of a __bridge retain.  This is more in the way of a workaround
than an actual guarantee, so it's acceptable to be brittle here.

rdar://problem/9504800

llvm-svn: 134605
2011-07-07 06:58:02 +00:00
Nick Lewycky 365efd62a1 In an in-class initialization, defer checks for value-dependent initialization
expressions.

llvm-svn: 134583
2011-07-07 02:20:13 +00:00
Chandler Carruth 50020d9461 Based on comments from Chris, switch to using CFG::getNumBlockIDs()
rather than a computed std::distance(). At some point I had convinced
myself that these two were different; but as far as I can tell on
re-exampination they aren't, and the number of block IDs is actually
just a count of the blocks in the CFG.

While this removes the primary motivation for guarding all of this with
CollectStats, I have a patch coming up that will almost certainly make
it important again.

llvm-svn: 134552
2011-07-06 22:21:45 +00:00
Douglas Gregor 53e191ed94 Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the
non-volatile automatic object comes from outside the innermost try
scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were
incorrect but it didn't matter because IR generation doesn't actually
apply the NRVO here. In C++0x, however, we were moving from an object
when in fact we should have copied from it. Fixes PR10142 /
<rdar://problem/9714312>.

llvm-svn: 134548
2011-07-06 22:04:06 +00:00
Fariborz Jahanian c6ba959ab1 Some code cleanup of r134522
llvm-svn: 134529
2011-07-06 20:48:48 +00:00
Fariborz Jahanian 1f626d6fd1 objc-arc: Support objc_arc_weak_unavailable on those
classes which are incompatible with weak references.
// rdar://9693477

llvm-svn: 134522
2011-07-06 19:24:05 +00:00
Douglas Gregor 750734c677 Don't try to type-check a copy construction of an exception
declaration with dependent type. Fixes PR10232 /
<rdar://problem/9700653>.

llvm-svn: 134515
2011-07-06 18:14:43 +00:00
Chandler Carruth b4836ea7a8 Build up statistics about the work done for analysis based warnings.
Special detail is added for uninitialized variable analysis as this has
serious performance problems than need to be tracked.

Computing some of this data is expensive, for example walking the CFG to
determine its size. To avoid doing that unless the stats data is going
to be used, we thread a bit into the Sema object to track whether
detailed stats should be collected or not. This bit is used to avoid
computations whereever the computations are likely to be more expensive
than checking the state of the flag. Thus, counters are in some cases
unconditionally updated, but the more expensive (and less frequent)
aggregation steps are skipped.

With this patch, we're able to see that for 'gcc.c':
*** Analysis Based Warnings Stats:
232 functions analyzed (0 w/o CFGs).
  7151 CFG blocks built.
  30 average CFG blocks per function.
  1167 max CFG blocks per function.
163 functions analyzed for uninitialiazed variables
  640 variables analyzed.
  3 average variables per function.
  94 max variables per function.
  96409 block visits.
  591 average block visits per function.
  61546 max block visits per function.

And for the reduced testcase in PR10183:
*** Analysis Based Warnings Stats:
98 functions analyzed (0 w/o CFGs).
  8526 CFG blocks built.
  87 average CFG blocks per function.
  7277 max CFG blocks per function.
68 functions analyzed for uninitialiazed variables
  1359 variables analyzed.
  19 average variables per function.
  1196 max variables per function.
  2540494 block visits.
  37360 average block visits per function.
  2536495 max block visits per function.

That last number is the somewhat scary one that indicates the problem in
PR10183.

llvm-svn: 134494
2011-07-06 16:21:37 +00:00
Rafael Espindola ba195cff81 Use attributes from the definition (if available) when
instantiating functions.

Fixes PR10272.

llvm-svn: 134491
2011-07-06 15:46:09 +00:00
John McCall 542e7c6f64 When tree-transforming an expression sequence, always flag expanded
variadic argument pack expansions as having changed, rather than doing
it for each changed expansion, which leaves out zero-argument packs
with catastrophic consequences.

Fixes PR10260.

llvm-svn: 134483
2011-07-06 07:30:07 +00:00
John McCall 21878760a4 Fixed enum types can be complete without actually being valid to use
as scope specifiers;  diagnose the attempt, rather than letting it go
to an assert.  The rest of PR10264.

llvm-svn: 134479
2011-07-06 06:57:57 +00:00
John McCall 24fc0decfe Change the driver's logic about Objective-C runtimes: abstract out a
structure to hold inferred information, then propagate each invididual
bit down to -cc1.  Separate the bits of "supports weak" and "has a native
ARC runtime";  make the latter a CodeGenOption.

The tool chain is still driving this decision, because it's the place that
has the required deployment target information on Darwin, but at least it's
better-factored now.

llvm-svn: 134453
2011-07-06 00:26:06 +00:00
Fariborz Jahanian b7a773626f objc-arc: enforce performSelector rules in rejecting retaining selectors
passed to it, and unknown selectors causing potential leak.
// rdar://9659270

llvm-svn: 134449
2011-07-05 22:38:59 +00:00
Douglas Gregor b7c0083878 Look through parenthesized declarators when determining whether an
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>. 

llvm-svn: 134426
2011-07-05 18:30:26 +00:00
Douglas Gregor 1fe12c9eba ActOnCXXConditionDeclaration should take into account that
ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg!

llvm-svn: 134416
2011-07-05 16:13:20 +00:00
Benjamin Kramer de1d62314a Initialize member.
llvm-svn: 134403
2011-07-05 09:46:31 +00:00
Anders Carlsson 1052fd76ab Remove unused parameter from ActOnDeclarator.
llvm-svn: 134377
2011-07-04 16:28:17 +00:00
Nick Lewycky 0bdf13ea9a Fix a typo, remove a tab, canonicalize some spacing. No functional change.
llvm-svn: 134305
2011-07-02 02:05:12 +00:00
Douglas Gregor 4326dd9bcc When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"
over "= 0". Fixes <rdar://problem/9714386>.

llvm-svn: 134302
2011-07-02 00:59:18 +00:00
Chandler Carruth edc2c64630 Move the Sema argument to all of the Sema-using helper functions in
SemaDeclAttr to the first argument. This makes them follow the very
consistent policy elsewhere in Sema for helper functions.

Original patch by Caitlin Sadowski, with some tweaking by me.

llvm-svn: 134290
2011-07-02 00:01:44 +00:00
Chandler Carruth 3ed22c35d6 Rename static helpers to use 'camelCaseNames' per the new style
recommendations before adding more of them.

Patch by Caitlin Sadowski.

llvm-svn: 134289
2011-07-01 23:49:16 +00:00
Chandler Carruth ff4c4f0f8a Mechanical rename of 'd' Decl pointer parameters to 'D'. This is more
conventional in the rest of Clang's codebase, and closer to the current
style recommendations. It also makes the code more internally consistent
as FD, VD, etc are used frequently for particular decl variables.

Patch by Caitlin Sadowski.

llvm-svn: 134288
2011-07-01 23:49:12 +00:00
Argyrios Kyrtzidis 8e25253e14 -Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug
-Remove unnecessary 'return'.
-Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null)
-Add a test of transferring ownership to a reference cast type.

llvm-svn: 134285
2011-07-01 23:01:46 +00:00
Argyrios Kyrtzidis 451ccc0892 Fix the warning that is emitted when an ownership attribute is applied incorrectly.
llvm-svn: 134278
2011-07-01 22:23:09 +00:00
Argyrios Kyrtzidis 9ab661b163 Use transferARCOwnershipToDeclaratorChunk in inferARCWriteback, no functionality change.
llvm-svn: 134277
2011-07-01 22:23:05 +00:00
Argyrios Kyrtzidis ea57a9be17 Fix assertion hit in inferARCWriteback.
llvm-svn: 134276
2011-07-01 22:23:03 +00:00
Argyrios Kyrtzidis 7192a3b841 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
(NSString**)&x; // Casting as (__strong NSString**).

llvm-svn: 134275
2011-07-01 22:22:59 +00:00
Argyrios Kyrtzidis d8701b60f7 -Remove Sema::ActOnCastOfParenListExpr and move most of its functionality to
newly introduced Sema::BuildVectorLiteral.
-Make Sema::ActOnCastExpr handle a vector initializer both when the cast'ed expression
 is a ParenListExpr and when it is a ParenExpr.
-Ultimately make Sema::ActOnParenOrParenListExpr independent of what the cast type was.

llvm-svn: 134274
2011-07-01 22:22:54 +00:00
Argyrios Kyrtzidis 7451d1cd00 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
static_cast<NSString**>(&x); // Casting as (__strong NSString**).

This currently only works for C++ named casts, C casts to follow.

llvm-svn: 134273
2011-07-01 22:22:50 +00:00
Argyrios Kyrtzidis e9b5c85041 Break Sema::GetTypeForDeclarator in 2 functions, one for DeclSpec processing and another for the rest.
No functionality change.

llvm-svn: 134272
2011-07-01 22:22:42 +00:00
Argyrios Kyrtzidis 774506918c Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto' in obj-c catch.
llvm-svn: 134271
2011-07-01 22:22:40 +00:00
Douglas Gregor 3b22a88488 When adding boolean keywords for typo correction, add either "bool" or
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".

llvm-svn: 134263
2011-07-01 21:27:45 +00:00
Richard Trieu 95d880933b Fix for PR7410. Allow functions in a derived class that improperly overwrite a virtual function in the base class to be inserted into the derived class function list to prevent extra errors every time the derived class is used.
llvm-svn: 134251
2011-07-01 20:02:53 +00:00
Richard Smith cd1c055528 Fix AST representations of alias-declarations which define tag types. Inside classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch.
llvm-svn: 134250
2011-07-01 19:46:12 +00:00
Douglas Gregor 678d76c026 Introduce the notion of instantiation dependence into Clang's AST. A
type/expression/template argument/etc. is instantiation-dependent if
it somehow involves a template parameter, even if it doesn't meet the
requirements for the more common kinds of dependence (dependent type,
type-dependent expression, value-dependent expression).

When we see an instantiation-dependent type, we know we always need to
perform substitution into that instantiation-dependent type. This
keeps us from short-circuiting evaluation in places where we
shouldn't, and lets us properly implement C++0x [temp.type]p2.

In theory, this would also allow us to properly mangle
instantiation-dependent-but-not-dependent decltype types per the
Itanium C++ ABI, but we aren't quite there because we still mangle
based on the canonical type in cases like, e.g.,

  template<unsigned> struct A { };
  template<typename T>
    void f(A<sizeof(sizeof(decltype(T() + T())))>) { }
  template void f<int>(A<sizeof(sizeof(int))>);

and therefore get the wrong answer.

llvm-svn: 134225
2011-07-01 01:22:09 +00:00
John McCall 0b645e9030 Perform lvalue-to-rvalue conversions on both operands of ->*
and the RHS of .*.  Noticed by Enea Zaffanella!

llvm-svn: 134170
2011-06-30 17:15:34 +00:00
Chandler Carruth 1406d6c037 Improve the wording of the warning when returning a value from
a constructor or destructor.

Patch by Hans Wennborg.

llvm-svn: 134138
2011-06-30 08:56:22 +00:00
John McCall d9dfe3a1f8 Preserve that a TemplateName was arrived at by substituting
for a template template parameter.

Uses to follow.

I've also made the uniquing of SubstTemplateTemplateParmPacks
use a ContextualFoldingSet as a minor space efficiency.

llvm-svn: 134137
2011-06-30 08:33:18 +00:00
Chandler Carruth c91f09d73a Fix an obvious typo in an attribute's diagnostics.
Patch by Caitlin Sadowski.

Unfortunately, this attribute doesn't seem to have a single test. It is
only mentioned in comments in one test, and as a string literal in
a copy of some Clang code checked in as a test for the Indexer. =[ It
dates from 2009 r74280 as part of OpenCL 1.0.

llvm-svn: 134136
2011-06-30 08:14:54 +00:00
Douglas Gregor a82064ca27 Check for deprecated/unavailable/etc attributes on fields that are
initialized via initializer lists. Fixes <rdar://problem/9694686>.

llvm-svn: 134099
2011-06-29 21:51:31 +00:00