Commit Graph

7826 Commits

Author SHA1 Message Date
Fariborz Jahanian 17612b1dbf objc: don't crash if primary class is missing and continuation class
is declaring ivars. // rdar://10752081

llvm-svn: 149573
2012-02-02 00:49:12 +00:00
Eli Friedman e1ffd49165 Change the check for constant-conversion with width-1 bitfields so it doesn't suppress quite as many cases. Based off a testcase in the gcc testsuite.
llvm-svn: 149572
2012-02-02 00:40:20 +00:00
Rafael Espindola 6d65d7b63d Reject mismatched "#pragma GCC visibility push" and "#pragma GCC visibility pop".
llvm-svn: 149559
2012-02-01 23:24:59 +00:00
Fariborz Jahanian 30febeb224 Look for declaration of CFBridgingRetain/CFBridgingRetain before
changing the diagnostic. Also use correct spelling for both.

llvm-svn: 149554
2012-02-01 22:56:20 +00:00
Anna Zaks 314cd09b5c Add a new compiler warning, which flags anti-patterns used as the size
argument in strncat.

The warning is ignored by default since it needs more qualification. 

TODO: The warning message and the note are messy when
strncat is a builtin due to the macro expansion.

llvm-svn: 149524
2012-02-01 19:08:57 +00:00
Douglas Gregor 6b8ef34f84 Diagnose the restriction on default arguments in C++11 [expr.prim.lambda]p5.
llvm-svn: 149517
2012-02-01 17:18:19 +00:00
Douglas Gregor cdd11d4e7e Introduce the lambda scope before determining explicit captures, which
cleans up and improves a few things:
  - We get rid of the ugly dance of computing all of the captures in
  data structures that clone those of CapturingScopeInfo, centralizing
  the logic for accessing/updating these data structures
  - We re-use the existing capture logic for 'this', which actually
  works now.

Cleaned up some diagnostic wording in minor ways as well.

llvm-svn: 149516
2012-02-01 17:04:21 +00:00
Douglas Gregor d3cebdba41 When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type.

llvm-svn: 149471
2012-02-01 05:02:47 +00:00
Richard Smith 0287910521 constexpr: Unlike other incomplete types, 'void' cannot possibly be completed as
a literal type. Disallow it as the return type of a constexpr function
declaration.

llvm-svn: 149469
2012-02-01 04:40:02 +00:00
Douglas Gregor 53a9bdf17e Improve checking of explicit captures in a C++11 lambda expression:
- Actually building the var -> capture mapping properly (there was an off-by-one error)
  - Keeping track of the source location of each capture
  - Minor QoI improvements, e.g, highlighing the prior capture if
  there are multiple captures, pointing at the variable declaration we
  found if we reject it.

As part of this, add standard citations for the various semantic
checks we perform, and note where we're not performing those checks as
we should.

llvm-svn: 149462
2012-02-01 01:18:43 +00:00
Nico Weber f8bb3de488 Fix crash on invalid in microsoft anonymous struct extension.
Fixes PR11847. Patch from Jason Haslam!

llvm-svn: 149460
2012-02-01 00:41:00 +00:00
Douglas Gregor 0e8ff39dc7 Diagnose attempts to explicitly capture a __block variable in a lambda.
llvm-svn: 149458
2012-02-01 00:09:55 +00:00
Kaelyn Uhrain 4e8942c139 Make the callback object to Sema::CorrectTypo mandatory.
llvm-svn: 149451
2012-01-31 23:49:25 +00:00
Fariborz Jahanian bcdc282d85 objc-arc: In various diagnostics mention
CFBridgingRetain/CFBridgingRelease calls instead
of __bridge_retained/__bridge_transfer casts as preferred
way of moving cf objects to arc land. // rdar://10207950

llvm-svn: 149449
2012-01-31 23:42:37 +00:00
Eli Friedman 9ccdb1d01b Make sure we call MaybeCreateExprWithCleanups for the sub-expression of an indirect goto.
llvm-svn: 149441
2012-01-31 22:47:07 +00:00
Eli Friedman 87d3280985 A couple minor fixes to template instantiation for for-range loops.
llvm-svn: 149440
2012-01-31 22:45:40 +00:00
Ted Kremenek 3814359657 Revert r149359. This was a hack to a problem with an easy workaround, and it doesn't feel like general solution.
llvm-svn: 149404
2012-01-31 19:19:25 +00:00
Jean-Daniel Dupas cb197b0e42 FormatCheckers should emit all diagnostics using EmitFormatDiagnostic().
llvm-svn: 149394
2012-01-31 18:12:08 +00:00
Ted Kremenek fdc870d6b2 Don't warn about -Wshorten-64-to-32 in unreachable code. Fixes <rdar://problem/10759934>. Apparently this is a common idiom in Linux (among other places).
llvm-svn: 149359
2012-01-31 05:37:48 +00:00
Ted Kremenek 8a92c8bb4f Make a bunch of local functions 'static'.
llvm-svn: 149358
2012-01-31 05:37:37 +00:00
Nico Weber 496cdc2cb7 Let %S, %ls, %C match 16bit types in NSStrings.
As discussed at http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120130/052200.html

llvm-svn: 149325
2012-01-31 01:43:25 +00:00
Richard Smith 911e142f03 constexpr: disallow signed integer overflow in integral conversions in constant
expressions in C++11.

llvm-svn: 149286
2012-01-30 22:27:01 +00:00
Jean-Daniel Dupas 537aa1ac68 Disable "non literal format string" for NSString that result from a macro expansion.
This is to prevent diagnostic when using NSLocalizedString or CFCopyLocalizedString
macros which are usually used in place of NS and CF strings literals.

llvm-svn: 149268
2012-01-30 19:46:17 +00:00
Benjamin Kramer e0513cb3b3 SmallBitVectorize the deduced parameter set.
llvm-svn: 149253
2012-01-30 16:17:39 +00:00
Jean-Daniel Dupas 028573e794 Update on format attribute handling.
- Remove the printf0 special handling as we treat it as printf anyway.
- Perform basic checks (non-literal, empty) for all formats and not only printf/scanf.

llvm-svn: 149236
2012-01-30 08:46:47 +00:00
Douglas Gregor 07f4357b44 Implement code completion support for module import declarations, e.g.,
@import <complete with module names here>

or

  @import std.<complete with submodule names here>

Addresses <rdar://problem/10710117>.

llvm-svn: 149199
2012-01-29 18:15:03 +00:00
John McCall eed64c77d2 Complain about attempts to use 'protected' visibility on targets
like Darwin that don't support it.  We should also complain about
invalid -fvisibility=protected, but that information doesn't seem
to exist at the most appropriate time, so I've left a FIXME behind.

llvm-svn: 149186
2012-01-29 01:20:30 +00:00
Abramo Bagnara 7945c981b9 Added source location for the template keyword in AST template-id expressions.
llvm-svn: 149127
2012-01-27 09:46:47 +00:00
Jean-Daniel Dupas fc0da1a8e0 Remove redundant checks.
llvm-svn: 149125
2012-01-27 09:14:17 +00:00
Abramo Bagnara 4244b43b60 Avoid redundant NNS qualification in constructor/destructor names.
llvm-svn: 149124
2012-01-27 08:46:19 +00:00
Richard Smith 253c2a390a constexpr: Implement the [dcl.constexpr]p5 check for whether a constexpr
function definition can produce a constant expression. This also provides the
last few checks for [dcl.constexpr]p3 and [dcl.constexpr]p4.

llvm-svn: 149108
2012-01-27 01:14:48 +00:00
Eli Friedman 66b6395dd5 Turn off implicit truncation warning for compound assignment to bitfields; it might be reasonable in some cases, but it clearly doesn't make sense in some cases, like the included testcase.
<rdar://problem/10238797>, part 2.

llvm-svn: 149095
2012-01-26 23:34:06 +00:00
Eli Friedman c267a32b05 Make the bitfield implicit truncation warning slightly more aggressive, and make the printed warning a bit more accurate. The new behavior matches gcc's -Wconversion. <rdar://problem/10238797>.
llvm-svn: 149089
2012-01-26 23:11:39 +00:00
John McCall 18a962bab5 Don't suppress access-control or invalid-type diagnostics from a
declarator just because we were able to build an invalid decl
for it.  The invalid-type diagnostics, in particular, are still useful
to know, and may indicate something about why the decl is invalid.

Also, recover from an illegal pointer/reference-to-unqualified-retainable
type using __strong instead of __autoreleasing;  in general, a random
object is much more likely to be __strong, so this avoids unnecessary
cascading errors in the most common case.

llvm-svn: 149074
2012-01-26 20:04:03 +00:00
Peter Collingbourne c331a1eb19 Improve efficiency of Sema::MaybeBindToTemporary by working with the
canonical type directly and adding a fast path for the common case
that the type is directly a RecordType.

llvm-svn: 149039
2012-01-26 03:33:51 +00:00
Eli Friedman 34b49061aa Refactor to share code for handling return statements between lambda expressions and block literals. As it turns out, almost all the logic can be shared.
llvm-svn: 149031
2012-01-26 03:00:14 +00:00
Eli Friedman 1da70394f6 Slight refactoring; catch yet another case where we were missing an lvalue-to-rvalue conversion.
llvm-svn: 149003
2012-01-26 00:26:18 +00:00
Eli Friedman 9562f39e2f Don't stack-allocate an IntegerLiteral which can be referred to after the current method returns. PR11744, part 2.
llvm-svn: 148995
2012-01-25 23:20:27 +00:00
Eli Friedman f7f102f81a Fix a crash involving a multi-dimensional dependent VLA. PR11744.
llvm-svn: 148989
2012-01-25 22:19:07 +00:00
Kaelyn Uhrain 9afaf793b3 Allow typo correction to be disabled in BuildOverloadedCallExpr variant.
This suppresses typo correction for auto-generated call expressions such
as to 'begin' or 'end' within a C++0x for-range statement.

llvm-svn: 148979
2012-01-25 21:11:35 +00:00
Kaelyn Uhrain 77e21fca3c Avoid correcting unknown identifiers to types where types aren't allowed.
Pass a typo correction callback object from ParseCastExpr to
Sema::ActOnIdExpression to be a bit more selective about what kinds of
corrections will be allowed for unknown identifiers.

llvm-svn: 148973
2012-01-25 20:49:08 +00:00
Kaelyn Uhrain 8edb17d753 Add custom callback object for typo correction in BuildRecoveryCallExpr.
The new callback, in addition to limiting which keywords to include in
the pool of typo correction candidates, also filters out non-keyword
candidates that don't refer to (template) functions that accept the
number of arguments that are present for the call being recovered.

llvm-svn: 148962
2012-01-25 18:37:44 +00:00
Douglas Gregor 0dd22bc4d6 When we're substituting into a function parameter pack and expect to
get a function parameter pack (but don't due to weird substitutions),
complain. Fixes the last bit of PR11848.

llvm-svn: 148960
2012-01-25 16:15:54 +00:00
Jean-Daniel Dupas d5f7ef48e2 Add support for const pointer to literal-objc string as format attribute.
llvm-svn: 148948
2012-01-25 10:35:33 +00:00
Eli Friedman 0ce4de4183 Fix r148920 to what I actually meant to commit.
llvm-svn: 148921
2012-01-25 04:35:06 +00:00
Eli Friedman 6601b550c0 Add missing check for placeholders.
llvm-svn: 148920
2012-01-25 04:29:24 +00:00
Argyrios Kyrtzidis 34172b83d6 In TreeTransform<Derived>::TransformBlockExpr, call ActOnBlockError for errors,
patch by Dmitri Gribenko.

llvm-svn: 148915
2012-01-25 03:53:04 +00:00
Richard Smith 928be491e0 Fix PR11848: decree that an alias template contains an unexpanded parameter pack
iff its substitution contains an unexpanded parameter pack. This has the effect
that we now reject declarations such as this (which we used to crash when
expanding):

  template<typename T> using Int = int;
  template<typename ...Ts> void f(Int<Ts> ...ints);

The standard is inconsistent on how this case should be treated.

llvm-svn: 148905
2012-01-25 02:14:59 +00:00
Eli Friedman a59b1907cc Make sure we correctly treat __is_convertible_to as an unevaluated context. PR11833.
llvm-svn: 148893
2012-01-25 01:05:57 +00:00
Douglas Gregor 70f449bf41 Whenever Sema attempts to look in the global method pool, try to load
additional data from the external Sema source. This properly copes
with modules that are imported after we have already searched in the
global method pool for a given selector. For PCH, it's a slight
pessimization to be fixed soon.

llvm-svn: 148891
2012-01-25 00:59:09 +00:00