Commit Graph

10584 Commits

Author SHA1 Message Date
Faisal Vali ab3d646a9d [REFACTOR] Refactored some of the generic-lambda capturing code.
Employed the following refactorings:
  - Renamed some functions
  - Introduced explaining variables
  - Cleaned up & added comments
  - Used Optional<unsigned> for return value instead of an out parameter
  - Added assertions
  - Constified a few member functions
  
No functionality change.
All regressions pass.  

llvm-svn: 196662
2013-12-07 20:22:44 +00:00
Alp Toker c108676822 Eliminate the last trivial NDEBUG uses in clang headers
assert(sanity()) reads so much better than preprocessor conditional blocks.

llvm-svn: 196657
2013-12-07 13:51:35 +00:00
Alp Toker 49d9f488a9 Tweak r196646
There was already a condition earlier in the function so just place the check
there.

Cleanup only.

llvm-svn: 196647
2013-12-07 07:32:31 +00:00
Alp Toker 8baeac7bfd Type traits: No need for switch to handle __builtin_types_compatible_p
__builtin_types_compatible_p() isn't a C++ type trait at all, rather a GNU C
special-case, so it's fine to use BoolTy the default return type for binary
type traits.

This brings BTT in line with other arities that already default to BoolTy.

Cleanup only, no change in behaviour.

llvm-svn: 196646
2013-12-07 07:20:22 +00:00
Argyrios Kyrtzidis e818681c88 Add a SubsetSubject in Attr.td to automate checking of where the objc_designated_initializer
attribute is acceptable.

llvm-svn: 196644
2013-12-07 06:08:04 +00:00
Richard Smith a98f8fc8d8 Give a more appropriate diagnostic when a template specialization or
instantiation appears in a non-enclosing namespace (the previous diagnostic
talked about the C++98 rule even in C++11 mode).

llvm-svn: 196642
2013-12-07 05:09:50 +00:00
Fariborz Jahanian 1f0b3bfd75 ObjectiveC. Continuing implementation of objc_bridge_related
attribute in sema and issuing a variety of diagnostics lazily 
for misuse of this attribute (and what to do) when converting 
from CF types to ObjectiveC types (and vice versa).
// rdar://15499111

llvm-svn: 196629
2013-12-07 00:34:23 +00:00
Aaron Ballman ba0aea16e1 Turning the __w64 attribute into an ignored attribute to match other Microsoft extensions we do not currently support. Note that __w64 has been deprecated in MSVC since 2008.
llvm-svn: 196592
2013-12-06 18:56:03 +00:00
Alp Toker 028ed91127 Fix code typos spotted while working on type traits
llvm-svn: 196587
2013-12-06 17:56:43 +00:00
Aaron Ballman a40bef25ee Reverting changes from r196415; this patch exposed a different, but unrelated bug regarding the __has_attribute implementation. Reverting to unblock the Chrome tsan builds.
llvm-svn: 196583
2013-12-06 15:58:47 +00:00
Dmitri Gribenko e6ac50ad71 -Wassign-enum: compare unqualified types
This commit changes -Wassign-enum to compare unqualified types.  One could
think that this does not matter much, because who wants a value of enum type
that is const-qualified?  But this breaks the intended pattern to silence this
warning with an explicit cast:

    static const enum Foo z = (enum Foo) 42;

In this case, source type is 'enum Foo', and destination type is 'const enum
Foo', and if we compare qualified types, they don't match, so we used warn.

llvm-svn: 196548
2013-12-05 23:06:53 +00:00
Dmitri Gribenko 58683755ed Allow the warning 'case value not in enumerated type' to be silenced with
the following pattern.

If 'case' expression refers to a static const variable of the correct enum
type, then we count this as a sufficient declaration of intent by the user,
so we silence the warning.

llvm-svn: 196546
2013-12-05 22:52:07 +00:00
Fariborz Jahanian f3077a29ce ObjectiveC: Don't warn when method implemented in
category is declared in category's primary
class's super class. Because the super class is
expected to implemented the method. // rdar://15580969

llvm-svn: 196531
2013-12-05 20:52:31 +00:00
Alp Toker a31d1dd179 AttributeList: tweak the conditional order to avoid two strcmps
llvm-svn: 196518
2013-12-05 18:04:42 +00:00
Alp Toker f6a24ce40f Fix a tranche of comment, test and doc typos
llvm-svn: 196510
2013-12-05 16:25:25 +00:00
Richard Smith f03bd30854 PR17983: Fix crasher bug in C++1y mode when performing a non-global array
delete on a class which has no array cookie and has no class-specific operator
new.

llvm-svn: 196488
2013-12-05 08:30:59 +00:00
Richard Smith a230224be4 Implement DR482: namespace members can be redeclared with a qualified name
within their namespace, and such a redeclaration isn't required to be a
definition any more.

Update DR status page to say Clang 3.4 instead of SVN and add new Clang 3.5
category (but keep Clang 3.4 yellow for now).

llvm-svn: 196481
2013-12-05 07:51:02 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Richard Smith 72bcaeca1d Per [dcl.meaning]p1, a name in an inline namespace can be redeclared using a
name from the enclosing namespace set if the name is specified as a
qualified-id.

llvm-svn: 196464
2013-12-05 04:30:04 +00:00
Richard Trieu 314a27360c Remove unused variable.
llvm-svn: 196459
2013-12-05 02:52:09 +00:00
Reid Kleckner 06bd7e64b9 Fix non-MSVC build error in ASTContext::getAdjustedType
Use FunctionTypeUnwrapper like we do in AttributedType to try to keep
some sugar.  We can actually do one better here in the future by
avoiding the AdjustedType node altogether when no sugar would be lost.

llvm-svn: 196455
2013-12-05 01:41:37 +00:00
Faisal Vali 5fb7c3c4ed Fix init-captures for generic lambdas.
For an init capture, process the initialization expression
right away.  For lambda init-captures such as the following:
const int x = 10;
 auto L = [i = x+1](int a) {
   return [j = x+2,
          &k = x](char b) { };
 };
keep in mind that each lambda init-capture has to have:
 - its initialization expression executed in the context
   of the enclosing/parent decl-context.
 - but the variable itself has to be 'injected' into the
   decl-context of its lambda's call-operator (which has
   not yet been created).
Each init-expression is a full-expression that has to get
Sema-analyzed (for capturing etc.) before its lambda's
call-operator's decl-context, scope & scopeinfo are pushed on their
respective stacks.  Thus if any variable is odr-used in the init-capture
it will correctly get captured in the enclosing lambda, if one exists.
The init-variables above are created later once the lambdascope and
call-operators decl-context is pushed onto its respective stack.

Since the lambda init-capture's initializer expression occurs in the
context of the enclosing function or lambda, therefore we can not wait
till a lambda scope has been pushed on before deciding whether the
variable needs to be captured.  We also need to process all
lvalue-to-rvalue conversions and discarded-value conversions,
so that we can avoid capturing certain constant variables.
For e.g.,
 void test() {
  const int x = 10;
  auto L = [&z = x](char a) { <-- don't capture by the current lambda
    return [y = x](int i) { <-- don't capture by enclosing lambda
         return y;
    }
  };
If x was not const, the second use would require 'L' to capture, and
that would be an error.
Make sure TranformLambdaExpr is also aware of this.

Patch approved by Richard (Thanks!!) 
http://llvm-reviews.chandlerc.com/D2092

llvm-svn: 196454
2013-12-05 01:40:41 +00:00
Reid Kleckner 0503a870a9 Add an AdjustedType sugar node for adjusting calling conventions
Summary:
In general, this type node can be used to represent any type adjustment
that occurs implicitly without losing type sugar.  The immediate use of
this is to adjust the calling conventions of member function pointer
types without breaking template instantiation.

Fixes PR17996.

Reviewers: rsmith

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

llvm-svn: 196451
2013-12-05 01:23:43 +00:00
Richard Smith d091dc179d Reject template-ids containing literal-operator-ids that have a dependent
nested-name-specifier, rather than crashing. (In fact, reject all
literal-operator-ids that have a non-namespace nested-name-specifier). The
grammar doesn't allow these in some cases, and in other cases does allow them
but instantiation will always fail.

llvm-svn: 196443
2013-12-05 00:58:33 +00:00
Aaron Ballman 8b9e236bb4 Giving a Subjects list to DllExport, which allows the removal of some custom semantic handling. The same cannot be done for DllImport, and so comments were left explaining why.
llvm-svn: 196429
2013-12-04 23:23:19 +00:00
Aaron Ballman aad23ecadb Common functionality is already checked within SemaDeclAttr.cpp and so it does not need to be re-checked for each target.
llvm-svn: 196428
2013-12-04 23:07:58 +00:00
Reid Kleckner feb8ac9bd1 Factor duplicated code for TransformTypeInObjectScope
Fixes the relevant FIXME about copy-pasted code.

llvm-svn: 196425
2013-12-04 22:51:51 +00:00
Faisal Vali bb9071ea80 Fix for PR18052 - Lambdas within NSDMI's and default arguments in Nested classes.
Clang currently croaks on the following:
  struct X1 {
    struct X2 {
      int L = ([] (int i) { return i; })(2);
    };
  };

asserting that the containing lexical context of the lambda is not Sema's cur context, when pushing the lambda's decl context on.

This occurs because (prior to this patch) getContainingDC always returns the non-nested class for functions at class scope (even for inline member functions of nested classes (to account for delayed parsing of their bodies)).  The patch addresses this by having getContainingDC always return the lexical DC for a lambda's call operator.

Link to the bug: http://llvm.org/bugs/show_bug.cgi?id=18052
Link to Richard Smith's feedback on phabricator: http://llvm-reviews.chandlerc.com/D2331

Thanks!

llvm-svn: 196423
2013-12-04 22:43:08 +00:00
Aaron Ballman b4c112338f The MSP430Interrupt attribute does have a sema handler (it's in TargetAttributesSema). Added a FIXME about the attribute being nameless when it really does have a valid name, and a comment explaining why we're using the name instead of the attribute kind.
llvm-svn: 196420
2013-12-04 22:23:43 +00:00
Aaron Ballman d9c5c5cb3f Getting rid of some hard-coded strings. No functional changes intended, though some test cases needed to be updated for attribute names becoming quoted.
llvm-svn: 196417
2013-12-04 22:02:33 +00:00
Aaron Ballman 3001339783 This attribute somehow remained nameless in the attribute tablegen, until now.
llvm-svn: 196415
2013-12-04 21:43:30 +00:00
Fariborz Jahanian 1a2519a7e9 ObjectiveC - Introducing objc_bridge_related attribute
which specifies couple of (optional) method selectors
for bridging a CFobject to or from an ObjectiveC 
object. This is wip. // rdsr://15499111

llvm-svn: 196408
2013-12-04 20:32:50 +00:00
Reid Kleckner 739756c0f9 [ms-cxxabi] Construct and destroy call arguments in the correct order
Summary:
MSVC destroys arguments in the callee from left to right.  Because C++
objects have to be destroyed in the reverse order of construction, Clang
has to construct arguments from right to left and destroy arguments from
left to right.

This patch fixes the ordering by reversing the order of evaluation of
all call arguments under the MS C++ ABI.

Fixes PR18035.

Reviewers: rsmith

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

llvm-svn: 196402
2013-12-04 19:23:12 +00:00
David Majnemer dbc0c8f941 Sema: Propagate the mangling number into instantiations
We would lose track of the mangling number assigned to the original
declaration which would cause us to create manglings that didn't match
the Itanium C++ specification.

e.g. Two static fields with the same name inside of a function template
would receive the same mangling with LLVM fixing up the second field so
they wouldn't collide.  This would create an incompatibility with other
compilers following the Itanium ABI.

I've confirmed that the new mangling is identical to the ones generated
by icc and gcc.

N.B. This was uncovered while working on Microsoft mangler.

llvm-svn: 196368
2013-12-04 09:01:55 +00:00
Richard Smith 8f65806b35 Fix crash if a dependent template-id was assumed to be a type but instantiates
to a variable template specialization.

llvm-svn: 196337
2013-12-04 00:56:29 +00:00
Richard Smith f95fe9b870 Fix crash if a variable template specialization is used in a nested-name-specifier.
llvm-svn: 196335
2013-12-04 00:47:45 +00:00
Richard Smith 72bfbd8615 Fix several crash-on-invalids when using template-ids that aren't
simple-template-ids (eg, 'operator+<int>') in weird places.

llvm-svn: 196333
2013-12-04 00:28:23 +00:00
Argyrios Kyrtzidis db5ce0f71e [objc] Add a warning when a class that provides a designated initializer, does not
override all of the designated initializers of its superclass.

llvm-svn: 196319
2013-12-03 21:11:54 +00:00
Argyrios Kyrtzidis b66d3cf5cf [objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.

A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.

llvm-svn: 196318
2013-12-03 21:11:49 +00:00
Argyrios Kyrtzidis fcded9b93a [objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.

llvm-svn: 196317
2013-12-03 21:11:43 +00:00
Argyrios Kyrtzidis 22bfa2c28b [objc] Emit a warning when the implementation of a designated initializer does not chain to
an init method that is a designated initializer for the superclass.

llvm-svn: 196316
2013-12-03 21:11:36 +00:00
Argyrios Kyrtzidis 9ed9e5f31c [objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get the
designated initializers of an interface.

If the interface declaration does not have methods marked as designated
initializers then the interface inherits the designated initializers of
its super class.

llvm-svn: 196315
2013-12-03 21:11:30 +00:00
Argyrios Kyrtzidis d1438b446e [objc] Introduce attribute 'objc_designated_initializer'.
It only applies to methods of init family in an interface declaration.

llvm-svn: 196314
2013-12-03 21:11:25 +00:00
Fariborz Jahanian a759848126 Issue diagnostic when constructor or destructor
return void expression. // rdar://15366494
pr17759.

llvm-svn: 196296
2013-12-03 17:10:08 +00:00
Aaron Ballman 1d0d2a48e7 Refactored the work group-related attributes to use a template, which reduces the amount of duplicate code in the handler. No functional change intended.
llvm-svn: 196165
2013-12-02 22:38:33 +00:00
Aaron Ballman a9e0540c78 Simplifying a test for duplicate vec_type_hint attributes. The assert and attribute kind test were superfluous. No functional change intended.
llvm-svn: 196162
2013-12-02 22:16:55 +00:00
Aaron Ballman f79ee2756d The CUDA device attribute doesn't need custom logic to check the number of attribute arguments (the common attribute handler already does this). Switching to use the simple attribute handler. No functional change intended.
llvm-svn: 196155
2013-12-02 21:09:08 +00:00
Aaron Ballman 3aff633590 Automate attribute language option checking by specifying the list of options to test in tablegen.
llvm-svn: 196138
2013-12-02 19:30:36 +00:00
Aaron Ballman fb76304f74 Factored attribute mutual exclusion code into a helper function; split the cf_audited_transfer and cf_unknown_transfer attributes into separate helper methods for simplicity. No functional changes intended.
llvm-svn: 196126
2013-12-02 18:05:46 +00:00
Aaron Ballman 604dfec8dc Re-enabled support for the Subjects for the weak attribute. This changes the diagnostic involved to be more accurate -- for C++ code, it will now report that weak applies to variables, functions or classes. Added additional test case for this.
llvm-svn: 196120
2013-12-02 17:07:07 +00:00