Commit Graph

9761 Commits

Author SHA1 Message Date
John McCall f413f5ed44 Move parsing of identifiers in MS-style inline assembly into
the actual parser and support arbitrary id-expressions.

We're actually basically set up to do arbitrary expressions here
if we wanted to.

Assembly operands permit things like A::x to be written regardless
of language mode, which forces us to embellish the evaluation
context logic somewhat.  The logic here under template instantiation
is incorrect;  we need to preserve the fact that an expression was
unevaluated.  Of course, template instantiation in general is fishy
here because we have no way of delaying semantic analysis in the
MC parser.  It's all just fishy.

I've also fixed the serialization of MS asm statements.

This commit depends on an LLVM commit.

llvm-svn: 180976
2013-05-03 00:10:13 +00:00
Douglas Gregor d2472d4cdb Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align((Align)))) char storage[Size];
 };

while this would parse as a "parameter name" 'Align':

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align(Align))) char storage[Size];
 };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align)) char storage[Size];
 };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180973
2013-05-02 23:25:32 +00:00
Douglas Gregor 33ebfe36e5 Revert r180970; it's causing breakage.
llvm-svn: 180972
2013-05-02 23:15:45 +00:00
Douglas Gregor 44dff3f2dc Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align((Align)))) char storage[Size];
  };

while this would parse as a "parameter name" 'Align':

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align(Align))) char storage[Size];
  };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align)) char storage[Size];
  };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180970
2013-05-02 23:08:12 +00:00
Douglas Gregor 39aaeef545 Fix crasher when the range in a C++ range-for loop has an ill-formed initializer.
Fixes <rdar://problem/13712739>.

llvm-svn: 180937
2013-05-02 18:35:56 +00:00
Richard Smith 9f8400eca4 PR15884: In the 'taking the address of a temporary' extension, materialize the
temporary to an lvalue before taking its address. This removes a weird special
case from the AST representation, and allows the constant expression evaluator
to deal with it without (broken) hacks.

llvm-svn: 180866
2013-05-01 19:00:39 +00:00
Argyrios Kyrtzidis bcf2bdc922 Point diagnostics that complain about a use of a selector in an objc message, to the selector location.
Previously it would point to the left bracket or the receiver, which can be particularly
problematic if the receiver is a block literal and we end up point the diagnostic far away
for the selector that is complaining about.

rdar://13620447

llvm-svn: 180833
2013-05-01 00:24:09 +00:00
Richard Smith 3b87038631 Fix PR15845: apparently MSVC does not support implicit int in C++ mode.
llvm-svn: 180822
2013-04-30 22:43:51 +00:00
Richard Smith 061f1e21be When deducing an 'auto' type, don't modify the type-as-written.
llvm-svn: 180808
2013-04-30 21:23:01 +00:00
Richard Smith 27d807cc9c Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.

llvm-svn: 180789
2013-04-30 13:56:41 +00:00
Daniel Jasper 9ba6f9bcc5 Fix very confusing indent in Sema.cpp.
This came up during my Euro LLVM 2013 talk on clang-format and I was
asked to submit it :-).

llvm-svn: 180772
2013-04-30 06:43:16 +00:00
Fariborz Jahanian 3beec2080f Objective-C (mostly arc): Under ARC, we often have unneeded qualifiers
in the diagnostics. Remove them when reporting incompatible
Objective-C pointer types. // rdar://13752880.

llvm-svn: 180765
2013-04-30 00:30:48 +00:00
Fariborz Jahanian 4289a5a429 c language: diagnose use of "[*]" on any array dimension
in the parameter of a function definition. Currently,
it crashes in irgen if it is on other than the 1st dimension.
// rdar://13705391

llvm-svn: 180732
2013-04-29 22:01:25 +00:00
Rafael Espindola 51629dfce2 Use ArrayRef in AddMethodCandidate.
Patch by Robert Wilhelm!

llvm-svn: 180724
2013-04-29 19:29:25 +00:00
Ben Langmuir e7d7c4cfc2 Small CapturedStmt improvements
Add a CapturedStmt.h similar to Lambda.h to reduce the typing required to get
to the CapturedRegionKind enum. This also allows codegen to access this enum
without including Sema/ScopeInfo.h.

Also removes some duplicated code for capturing 'this' between CapturedStmt and
Lambda.

Differential Revision: http://llvm-reviews.chandlerc.com/D712

llvm-svn: 180710
2013-04-29 13:32:41 +00:00
Ben Langmuir 2e13dd612d Test commit
llvm-svn: 180709
2013-04-29 13:07:42 +00:00
Richard Smith ad5c1ca44d Implement DR580: access checks for template parameters of a class template are
performed within the context of that class template. Patch by Ismail Pazarbasi!

llvm-svn: 180707
2013-04-29 10:13:55 +00:00
Richard Smith a3519fa347 Fix an assertion failure / accepts-invalid in -fms-extensions mode. Don't build
a dependent-scope id expression when a templated member function of a
non-templated class references an unknown identifier, since instantiation won't
rebuild it (and we can tell at parse time that it'll never work). Based on a
patch by Faisal Vali!

llvm-svn: 180701
2013-04-29 08:45:27 +00:00
Dmitri Gribenko e5fde996dc ArrayRef'ize Sema::ActOnEnumBody. No functionality change.
Patch by Robert Wilhelm.

llvm-svn: 180682
2013-04-27 20:23:52 +00:00
Benjamin Kramer 34463cf41d Silence a silly sign compare warning from GCC.
llvm-svn: 180673
2013-04-27 15:07:53 +00:00
Argyrios Kyrtzidis 04703a6efd Fix an assertion hit in Sema::CheckObjCMethodOverrides.
llvm-svn: 180651
2013-04-27 00:10:12 +00:00
Richard Smith 74aeef50a0 Implement C++1y decltype(auto).
llvm-svn: 180610
2013-04-26 16:15:35 +00:00
Richard Smith 3da88fac54 C++1y: support simple variable assignments in constexpr functions.
llvm-svn: 180603
2013-04-26 14:36:30 +00:00
Rafael Espindola 327be3cc20 Add r180263 back, but fix hasBraces() to be correct during parsing.
Original commit message:

Fix a case in linkage computation that should check for single line extern "C".

llvm-svn: 180591
2013-04-26 01:30:23 +00:00
Fariborz Jahanian 73e244a49f Objective-C: This is a small modification to my
patch -n r180198.
When reporting on missing property accessor implementation in
categories, do not report when they are declared in primary class,
class's protocol, or one of it super classes or in of the other
categories. // rdar://13713098

llvm-svn: 180580
2013-04-25 21:59:34 +00:00
Rafael Espindola 3626b7e451 Put friend decls in the correct context.
When we find a friend declaration we have to skip transparent contexts for doing
lookups, but we should not skip them when inserting the new decl if the lookup
found nothing.

Fixes PR15841.

llvm-svn: 180571
2013-04-25 20:12:36 +00:00
Rafael Espindola bff5956cfa Don't mark 'extern "C" void f(void)' as having extern storage class.
Instead, we check for one line extern "C" context in linkage computation and
when deciding if a variable is a definition.

This hopefully completes the transition to having "as written" semantics for
hasExternalStorage.

llvm-svn: 180258
2013-04-25 12:11:36 +00:00
Fariborz Jahanian 6a41337132 Objective-C arc: Improve disgnostics when 'weak'
property cannot be synthesized because its backing
ivar does not support weak references.
// rdar://13676793

llvm-svn: 180211
2013-04-24 19:13:05 +00:00
Fariborz Jahanian eb3f1007d8 Objective-C: When reporting on missing property accessor implementation in
categories, do not report when they are declared in primary class,
class's protocol, or one of it super classes. This is because,
its class is going to implement them. // rdar://13713098

llvm-svn: 180198
2013-04-24 17:06:38 +00:00
Argyrios Kyrtzidis 40bcfd71b6 When modifying an implicit instantiation with information from an explicit one, make sure to reset the "right brace" location.
Otherwise the source range of the explicit instantiation may become invalid (begin location will be after the end location).

rdar://13706991

llvm-svn: 180070
2013-04-22 23:23:42 +00:00
Ted Kremenek ebeabab9a9 Add a warning for Objective-C pointer introspection, which is solely the job of the Objective-C runtime.
llvm-svn: 180062
2013-04-22 22:46:52 +00:00
Chad Rosier 7359d4793e [ms-inline asm] Set the OpDecl to the InlineAsmIdentifierInfo struct.
Part of rdar://13663589

llvm-svn: 180055
2013-04-22 22:05:00 +00:00
Chad Rosier b18a285525 [ms-inline asm] Refactor/clean up the SemaLookup interface. No functional
change indended.
Part of rdar://13663589

llvm-svn: 180027
2013-04-22 17:01:37 +00:00
Richard Smith d9f663b510 C++1y constexpr extensions, round 1: Allow most forms of declaration and
statement in constexpr functions. Everything which doesn't require variable
mutation is also allowed as an extension in C++11. 'void' becomes a literal
type to support constexpr functions which return 'void'.

llvm-svn: 180022
2013-04-22 15:31:51 +00:00
Richard Smith 034185c2f9 The 'constexpr implies const' rule for non-static member functions is gone in
C++1y, so stop adding the 'const' there. Provide a compatibility warning for
code relying on this in C++11, with a fix-it hint. Update our lazily-written
tests to add the const, except for those ones which were testing our
implementation of this rule.

llvm-svn: 179969
2013-04-21 01:08:50 +00:00
Richard Smith 74d0c1eeef Disable VLA diagnostic in C++1y mode, and add some tests.
Still to do here:
  - we have a collection of syntactic accepts-invalids to diagnose
  - support non-PODs in VLAs, including dynamic initialization /
    destruction
  - runtime checks (and throw std::bad_array_length) for bad bound
  - support VLA capture by reference in lambdas
  - properly support VLAs in range-based for (don't recompute bound)

llvm-svn: 179962
2013-04-20 23:28:26 +00:00
Richard Smith 852c9db72b C++1y: Allow aggregates to have default initializers.
Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in
CXXCtorInitializers and in InitListExprs to represent a default initializer.

There's an additional complication here: because the default initializer can
refer to the initialized object via its 'this' pointer, we need to make sure
that 'this' points to the right thing within the evaluation.

llvm-svn: 179958
2013-04-20 22:23:05 +00:00
Richard Smith 0feaf0c7e3 Implement core issue 1608: class members can be found via operator lookup in a trailing return type in that class's body.
llvm-svn: 179941
2013-04-20 12:41:22 +00:00
Chad Rosier 7f2ab89774 [ms-inline asm] The parsing of C++ identifiers is a task of the front-end parser,
not the asm parser.  As such, begin moving the parsing logic in that direction.
This patch is just a temporary hack until the real frontend parser can be hooked
up.  Part of rdar://13663589

llvm-svn: 179882
2013-04-19 20:37:49 +00:00
Chad Rosier 384823dc32 Specify that we're parsing ms-style inline assembly.
llvm-svn: 179762
2013-04-18 15:45:31 +00:00
Richard Trieu e089497121 Switch the note order for -Woverloaded-shift-op-parentheses so that the note
with the silence fix-it comes first.  This is more consistent with the rest
of the warnings in -Wparentheses.

llvm-svn: 179742
2013-04-18 01:04:37 +00:00
Richard Smith 3c626edda2 PR15755: don't drop parameter packs when dropping parameters with default
arguments in the formation of a candidate set of inheriting constructors.

llvm-svn: 179708
2013-04-17 19:00:52 +00:00
Benjamin Kramer 892cb486a4 Sema: Remove unused variable.
llvm-svn: 179701
2013-04-17 18:05:23 +00:00
Richard Smith 3cb4c63073 DR974: Lambdas can have default arguments.
llvm-svn: 179688
2013-04-17 16:25:20 +00:00
Douglas Gregor 19a41f161b Fix PR15291: noreturn adjustment in overload resolution for function templates, from Alexander Zinenko!
llvm-svn: 179680
2013-04-17 08:45:07 +00:00
Richard Trieu fe042e6aab Add warning group -Woverloaded-shift-op-parentheses to -Wparentheses. This
will fire on code such as:

  cout << x == 0;

which the compiler will intrepret as

  (cout << x) == 0;

This warning comes with two fixits attached to notes, one for parentheses to
silence the warning, and another to evaluate the comparison first.

llvm-svn: 179662
2013-04-17 02:12:45 +00:00
Argyrios Kyrtzidis c2091d5d71 Use the extra info in global method pool to speed up looking for ObjC overridden methods.
When we are in a implementation, we check the global method pool whether there were category
methods with the same selector. If there were none (common case) we don't need to do lookups for
overridden methods again.

Note that for an interface method (if we don't encounter its implementation), it is considered that
it overrides methods that were declared before it, not for category methods introduced after it.

This is tradeoff in favor of performance, since it is expensive to do lookups in case there was a
category, and moving the global method pool to ASTContext (so we can check it) would increase complexity.

rdar://13508196

llvm-svn: 179654
2013-04-17 00:09:08 +00:00
Argyrios Kyrtzidis d3da6e01e8 Enhance the ObjC global method pool to record whether there were 0, 1, or >= 2 methods (with a particular selector) inside categories.
This is done by extending ObjCMethodList (which is only used by the global method pool) to have 2 extra bits of information.
We will later take advantage of this info in global method pool for the overridden methods calculation.

llvm-svn: 179652
2013-04-17 00:08:58 +00:00
John McCall 0d9dd73847 Don't put too much thought into whether or not to capture a
type-dependent intermediate result in a postfix ++ pseudo-
object operation.

Test case by Tong Shen.

llvm-svn: 179637
2013-04-16 22:32:04 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D433

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Tareq A. Siraj 24110cc733 Implement CapturedStmt AST
CapturedStmt can be used to implement generic function outlining as described in
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

CapturedStmt is not exposed to the C api.

Serialization and template support are pending.

Author: Wei Pan <wei.pan@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D370

llvm-svn: 179615
2013-04-16 18:53:08 +00:00
Douglas Gregor 8997dac30a Fix handling of atomic shift operations, from Serge Pavlov.
llvm-svn: 179600
2013-04-16 15:41:08 +00:00
Rafael Espindola 3c4a251ce8 Suppress unused warning on static inline function template specializations.
Patch by Halfdan Ingvarsson!

llvm-svn: 179598
2013-04-16 15:21:30 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Rafael Espindola 9dd86de771 Correctly propagate the storage class to function template instantiations.
This fixes pr15753. This is another case of the fuzzy definition of the
"as written" storage class of an instantiation.

llvm-svn: 179581
2013-04-16 02:29:15 +00:00
Joey Gouly 75e81e645d Remove some dead code that has not been used since 2010.
llvm-svn: 179558
2013-04-15 21:13:33 +00:00
Rafael Espindola 5bddd6a92a Remove hasExternalLinkageUncached.
It was being used correctly, but it is a very dangerous API to have around.
Instead, move the logic from the filtering to when we are deciding if we should
link two decls.

llvm-svn: 179523
2013-04-15 12:49:13 +00:00
Rafael Espindola 29cda59a9d Fix the storage class of method instantiations.
We keep the "as written" storage class, but that is a fuzzy concept for
instantiations. With this patch instantiations of methods of class templates
now get a storage class that is based on the semantics of isStatic(). With this
can simplify isStatic() itself.

llvm-svn: 179521
2013-04-15 12:38:20 +00:00
Richard Smith 5990db62f6 Local thread_local variables are implicitly 'static'. (This doesn't apply to _Thread_local nor __thread.)
llvm-svn: 179517
2013-04-15 08:33:22 +00:00
Richard Smith 774672e943 Properly check for a constant initializer for a thread-local variable.
llvm-svn: 179516
2013-04-15 08:07:34 +00:00
Richard Smith 6ea1a4d1dc Diagnose if a __thread or _Thread_local variable has a non-constant initializer
or non-trivial destructor.

llvm-svn: 179491
2013-04-14 20:11:31 +00:00
John McCall ad327cd214 Handle incompatible redeclarations of library builtins better.
Invalid redeclarations of valid explicit declarations shouldn't
take the same path as redeclarations of implicit declarations,
and invalid local extern declarations shouldn't foul things up
for everybody else.

llvm-svn: 179482
2013-04-14 08:50:55 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
John McCall a4da323ee0 Don't replace an existing decl in the scope chains with its
local-extern redeclaration;  type refinements, default arguments,
etc. must all be locally scoped.

rdar://13535367

llvm-svn: 179430
2013-04-13 00:20:21 +00:00
Richard Smith b4a9e86877 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.

llvm-svn: 179424
2013-04-12 22:46:28 +00:00
Benjamin Kramer 1b4342dbda Sema: Give a typically small DenseMap some inline capacity.
Also reflow code a bit, no change in functionality.

llvm-svn: 179382
2013-04-12 15:22:25 +00:00
John McCall bc48989d0d Drop ObjCIndirectCopyRestoreExprs during template instantiation.
It's a kind of implicit conversion, which we generally drop, but
more importantly it's got very specific placement requirements.

rdar://13617051

llvm-svn: 179254
2013-04-11 02:14:26 +00:00
Jordan Rose b1312a5495 Force a load when creating a reference to a temporary copied from a bitfield.
For this source:
  const int &ref = someStruct.bitfield;

We used to generate this AST:

  DeclStmt [...]
  `-VarDecl [...] ref 'const int &'
    `-MaterializeTemporaryExpr [...] 'const int' lvalue
      `-ImplicitCastExpr [...] 'const int' lvalue <NoOp>
        `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...]
          `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X'

Notice the lvalue inside the MaterializeTemporaryExpr, which is very
confusing (and caused an assertion to fire in the analyzer - PR15694).

We now generate this:

  DeclStmt [...]
  `-VarDecl [...] ref 'const int &'
    `-MaterializeTemporaryExpr [...] 'const int' lvalue
      `-ImplicitCastExpr [...] 'int' <LValueToRValue>
        `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...]
          `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X'

Which makes a lot more sense. This allows us to remove code in both
CodeGen and AST that hacked around this special case.

The commit also makes Clang accept this (legal) C++11 code:

  int &&ref = std::move(someStruct).bitfield

PR15694 / <rdar://problem/13600396>

llvm-svn: 179250
2013-04-11 00:58:58 +00:00
Dmitri Gribenko a7d16ceee6 Add an option to parse all comments as documentation comments
Patch by Amin Shali.

llvm-svn: 179180
2013-04-10 15:35:17 +00:00
Ted Kremenek 3365e52fa5 Handle "typeof" in Objective-C format string checking. This previously crashed.
Yes, this came from actual code.

Fixes <rdar://problem/13557053>.

llvm-svn: 179155
2013-04-10 06:26:26 +00:00
Richard Smith b7151b910c Add support for computing the exception specification for an inheriting
constructor. This isn't quite perfect (as usual, we don't handle default
arguments correctly yet, and we don't deal with copy/move constructors for
arguments correctly either, but this will be fixed when we implement core issue
1351.

This completes our support for inheriting constructors.

llvm-svn: 179154
2013-04-10 06:11:48 +00:00
Richard Smith 185be185b2 C++11 inheriting constructors: support for inheriting constructor templates.
llvm-svn: 179151
2013-04-10 05:48:59 +00:00
Douglas Gregor c197057b42 <rdar://problem/13605348> Don't consider invalid user-defined literal operators during overload resolution.
llvm-svn: 179150
2013-04-10 05:18:00 +00:00
Matt Beaumont-Gay e1368a107a Suppress -Wunused-variable for variables declared in headers, which may in
fact be defined and used in another TU.

Reshuffle some test cases because we suppress -Wunused-variable after we've
emitted an error.

This fixes PR15558.

llvm-svn: 179138
2013-04-10 00:47:10 +00:00
Fariborz Jahanian ada44a2063 Objective-C: This patch fixes a none-issuance of warning
when result type of protocol property and getter method
differ by fixing a more serious problem. When a forward
protocol declaration comes between its definition and
its use in class protocol list, the forward protocol
ast was being used in building the protocol list.
// rdar://12522752

llvm-svn: 179108
2013-04-09 17:52:29 +00:00
John McCall 7353c86a4e When checking for illegal expressions in a default-argument
expression, look through pseudo-object expressions.

rdar://13602832

llvm-svn: 179080
2013-04-09 01:56:28 +00:00
Douglas Gregor 8ccbc18efa Skip transparent contexts when looking for using directives in name lookup.
Fixes the bootstrap regression I introduced in r179067.

llvm-svn: 179079
2013-04-09 01:49:26 +00:00
Argyrios Kyrtzidis 25049096cb Mark as referenced the functions from instantiated UserDefinedLiterals.
Fixes rdar://13589856

llvm-svn: 179078
2013-04-09 01:17:02 +00:00
Douglas Gregor ebe2db7ed6 <rdar://problem/13584715> Converted constant expressions are expected to have integral values.
We were assuming that any expression used as a converted constant
expression would either not have a folded constant value or would be
an integer, which is not the case for some ill-formed constant
expressions. Because converted constant expressions are only used
where integral values are expected, we can simply treat this as an
error path. If that ever changes, we'll need to widen the interface of
Sema::CheckConvertedConstantExpression() anyway.

llvm-svn: 179068
2013-04-08 23:24:07 +00:00
Douglas Gregor cc9406c055 <rdar://problem/13540899> Collect using directives from all of the semantic contexts not represented by scopes.
This fixes a regression I introduced in r178136, where we would not
consider the using directives from the semantic declaration contexts
that aren't represented by the lexical scopes (Scope) when performing
unqualified name lookup. This lead to horribly funny diagnostics like
"no identifier named 'foo'; did you mean 'foo'?".

llvm-svn: 179067
2013-04-08 23:11:25 +00:00
Nick Lewycky 0d9b3191f6 Fix typo in assertion.
llvm-svn: 179061
2013-04-08 21:55:21 +00:00
Richard Trieu e373235c7c Fix PR15634, better error message for template deduction failure.
When two template decls with the same name are used in this diagnostic,
force them to print their qualified names.  This changes the bad message of:

candidate template ignored: could not match 'array' against 'array'

to the better message of:

candidate template ignored: could not match 'NS2::array' against 'NS1::array'

llvm-svn: 179056
2013-04-08 21:11:40 +00:00
Douglas Gregor 2eb1c57b9d <rdar://problem/13540921> Fix a crasher when an Objective-C for-in loop gets a non-variable iteration declaration.
llvm-svn: 179053
2013-04-08 20:52:24 +00:00
DeLesley Hutchins fd374bb3dd Thread safety analysis: turn on checking within lock and unlock functions.
These checks are enabled with the -Wthread-safety-beta flag.

llvm-svn: 179046
2013-04-08 20:11:11 +00:00
Douglas Gregor f7106af656 <rdar://problem/13540921> Cope with instantiations of the C++11 range-based for loop that end up being Objective-C fast enumeration loops.
llvm-svn: 179037
2013-04-08 18:40:13 +00:00
Douglas Gregor c430f45d1e <rdar://problem/13540921> Cope with deduced 'auto' in a C++11 for-range loop that is actually an Objective-C fast enumeration loop.
llvm-svn: 179035
2013-04-08 18:25:02 +00:00
Benjamin Kramer 5c488ef85c Sema: Don't crash when trying to emit a warning for a duplicate value in an invalid enum.
Fixes PR15693. A null check on a pointer returned from cast<> is a very dubious
construct, do we have a checker for this somewhere?

llvm-svn: 178975
2013-04-07 14:10:40 +00:00
Ted Kremenek b54457242c Rework how ObjC method inherit deprecated/availability.
New rule:
- Method decls in @implementation are considered "redeclarations"
  and inherit deprecated/availability from the @interface.
- All other cases are consider overrides, which do not inherit
  deprecated/availability.  For example:

  (a) @interface redeclares a method in an adopted protocol.
  (b) A subclass redeclares a method in a superclass.
  (c) A protocol redeclares a method from another protocol it adopts.

The idea is that API authors should have the ability to easily
move availability/deprecated up and down a class/protocol hierarchy.
A redeclaration means that the availability/deprecation is a blank
slate.

Fixes <rdar://problem/13574571>

llvm-svn: 178937
2013-04-06 00:34:27 +00:00
Richard Trieu 05c4d023f3 When -Woverloaded-virtual is triggered, call HandleFunctionTypeMismatch to add
more information to the notes.  This information is already present on other
diagnostic messages that involves overloads.

llvm-svn: 178923
2013-04-05 23:02:24 +00:00
Tanya Lattner 713eef4f7c Add an error to check that all program scope variables are in the constant address space in OpenCL.
llvm-svn: 178906
2013-04-05 20:14:50 +00:00
Tanya Lattner 9a13c3e683 Revert 178811 until I fix the unit tests.
llvm-svn: 178813
2013-04-04 23:45:52 +00:00
Tanya Lattner 9812634c52 Add an error to check that all program scope variables are in the constant address space in OpenCL.
llvm-svn: 178811
2013-04-04 23:36:11 +00:00
Rafael Espindola 8ac2f59017 Don't patch the storage class of static data members.
This removes a bit of patching that survived r178663. Without it we can produce
better a better error message for

const int a = 5;
static const int a;

llvm-svn: 178795
2013-04-04 21:21:25 +00:00
Fariborz Jahanian 83f1be1bfc Objective-C: Issue deprecated warning when using a
deprecated typedef to subclass or invoke a class method.
// rdar://13569424

llvm-svn: 178775
2013-04-04 18:45:52 +00:00
Rafael Espindola 8f45ddf5d9 Use isExternalLinkage instead of hasExternalLinkage.
Having these not be the same makes an easy to misuse API. We should audit the
uses and probably rename to something like

foo->hasExternalLinkage():
  The c++ standard one. That is UniqueExternalLinkage or ExternalLinkage.

foo->hasUniqueExternalLinkage():
  Is UniqueExternalLinkage.

foo->hasCogeGenExternalLinkage():
  Is ExternalLinkage.

llvm-svn: 178768
2013-04-04 17:16:12 +00:00
Rafael Espindola 2b0b13bc44 Fix a recent linkage regression.
Now that we don't have a semantic storage class, use the linkage.

Thanks to Bruce Stephens for reporting this.

llvm-svn: 178766
2013-04-04 16:43:41 +00:00
Ted Kremenek 51b7ed4de5 Revert r177948. We decided that we do not want ObjC property redeclarations to inherit "deprecated".
llvm-svn: 178743
2013-04-04 05:29:15 +00:00
Rafael Espindola 7b51ae8e0e Add hasExternalLinkageUncached back with the test that Richard provided, but
keep the call at the current location.

llvm-svn: 178741
2013-04-04 04:40:17 +00:00
Rafael Espindola 4dc336b20f Avoid computing the linkage instead of avoiding caching it.
This mostly reverts 178733, but keeps the tests.

I don't claim to understand how hidden sub modules work or when we need to see
them (is that documented?), but this has the same semantics and avoids adding
hasExternalLinkageUncached which has the same foot gun potential as the old
hasExternalLinkage.

Last but not least, not computing linkage when it is not needed is more
efficient.

llvm-svn: 178739
2013-04-04 03:27:32 +00:00
Rafael Espindola 869fe0448b Fix linkage related crash.
This test was exactly the opposite of what it should be. We should check if
there old decl has linkage (where it makes sense) and if the new decl has
the extern keyword.

llvm-svn: 178735
2013-04-04 02:47:57 +00:00