Commit Graph

7933 Commits

Author SHA1 Message Date
Eli Friedman 3bda6b1f8e Add some code to accurately perform odr-used marking for variables per the C++11 rules.
llvm-svn: 149641
2012-02-02 23:15:15 +00:00
Fariborz Jahanian 57539cf8c8 Further enhance comment for property in continuation class.
llvm-svn: 149639
2012-02-02 22:37:48 +00:00
Benjamin Kramer b6d6508b16 Initialize the user defined conversion function to null if this is an aggregate initialization from an initializer list.
Found by valgrind.

llvm-svn: 149627
2012-02-02 19:35:29 +00:00
Fariborz Jahanian 24c2ccc254 objc: comment the code which allows narroing of property object
type in continuation class.

llvm-svn: 149625
2012-02-02 19:34:05 +00:00
Fariborz Jahanian 6a73384b53 objective-c: When redeclaraing in continuation class a 'readonly'
property to 'readwrite', also allow redeclaration of
property type to a narrowring object type.
// rdar://10790488

llvm-svn: 149614
2012-02-02 18:54:58 +00:00
Matt Beaumont-Gay 248bc72737 Pacify gcc's -Wreturn-type
llvm-svn: 149610
2012-02-02 18:35:35 +00:00
Eli Friedman fa0df83eba Split Sema::MarkDeclarationReferenced into multiple functions; the additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch.
llvm-svn: 149586
2012-02-02 03:46:19 +00:00
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
Jean-Daniel Dupas 3b8dfa069b Add "multiple format attributes" support on block.
llvm-svn: 148890
2012-01-25 00:55:11 +00:00
Douglas Gregor e171601ff6 Rework the external Sema source's ReadMethodPool() so that it doesn't
return pre-built lists. Instead, it feeds the methods it deserializes
to Sema so that Sema can unique them, which keeps the chains shorter.

llvm-svn: 148889
2012-01-25 00:49:42 +00:00
Douglas Gregor c454afedff Factor out the addition of a method into the global method pool, and
teach it to always add the new method at the *end* of the list rather
than as the second element in the list.

llvm-svn: 148886
2012-01-25 00:19:56 +00:00
Eli Friedman 946b7b5bc8 Switch PerformImplicitConversion over to use DefaultLvalueConversion for lvalue-to-rvalue conversion.
llvm-svn: 148874
2012-01-24 22:51:26 +00:00
Jean-Daniel Dupas 78536ae5b5 Replace a hack to handle NSLog/NSLogv in sema by declaring them as Library Builtins.
llvm-svn: 148873
2012-01-24 22:32:46 +00:00
Argyrios Kyrtzidis 3698cef19f [libclang] In clang::getCursorKindForDecl() don't return "UnexposedDecl"
for forward references of classes and protocols, this breaks libclang API usage.

rdar://10747438.

llvm-svn: 148861
2012-01-24 21:39:26 +00:00
Nick Lewycky 411fc65b45 Add a new warning, -Wover-aligned, which detects attempts to use the default
allocator to construct an object which declares more alignment than the default
allocator actually provides. Fixes PR9527!

llvm-svn: 148857
2012-01-24 21:15:41 +00:00
Kaelyn Uhrain 9ce58bd757 Small code cleanup/simplification in Sema::ClassifyName.
llvm-svn: 148850
2012-01-24 19:45:35 +00:00
Fariborz Jahanian e2a7776eff objc: Issue a generic diagnostic assigning to
an objc object in any abi mode.

llvm-svn: 148847
2012-01-24 19:40:13 +00:00
Kostya Serebryany 588d6abf7d The following patch adds __attribute__((no_address_safety_analysis)) which will allow to disable
address safety analysis (such as e.g. AddressSanitizer or SAFECode) for a specific function.

When building with AddressSanitizer, add AddressSafety function attribute to every generated function
except for those that have __attribute__((no_address_safety_analysis)).

With this patch we will be able to
1. disable AddressSanitizer for a particular function
2. disable AddressSanitizer-hostile optimizations (such as some cases of load widening) when AddressSanitizer is on.

llvm-svn: 148842
2012-01-24 19:25:38 +00:00
Douglas Gregor 3ecbc3d655 Promote the extension warning for attempts to catch a reference or
pointer to incomplete type from an ExtWarn to an error. We put the
ExtWarn in place as part of a workaround for Boost (PR6527), but it
(1) doesn't actually match a GCC extension and (2) has been fixed for
two years in Boost, and (3) causes us to emit code that fails badly at
run time, so it's a bad idea to keep it. Fixes PR11803.

llvm-svn: 148838
2012-01-24 19:01:26 +00:00
Fariborz Jahanian 3c4225a858 objc: issue error if assigning objects in fragile-abi too.
// rdar://10731065

llvm-svn: 148823
2012-01-24 18:05:45 +00:00
Douglas Gregor 247afcc6a9 Only mark an IdentifierInfo as having changed since deserialization
when it actually has changed (and not, e.g., when we've simply attached a
deserialized macro definition). Good for ~1.5% reduction in module
file size, mostly in the identifier table.

llvm-svn: 148808
2012-01-24 15:24:38 +00:00
David Blaikie 186a8899a4 Support decltype in member initializers.
This is the last piece of N3031 (decltype in weird places) - supporting
the use of decltype in a class ctor's member-initializer-list to
specify the base classes to initialize.

Reviewed by Richard Smith.

llvm-svn: 148789
2012-01-24 06:03:59 +00:00
David Blaikie 0f2ae78980 Revert various template unreachability code I committed accidentally.
r148774, r148775, r148776, r148777

llvm-svn: 148780
2012-01-24 04:51:48 +00:00
David Blaikie 7e625b67e5 Simple hack to do unreachable code analysis on template patterns.
llvm-svn: 148774
2012-01-24 04:29:18 +00:00
Argyrios Kyrtzidis 50cfa12752 Rename Sema::isNullExpr() -> Sema::isSentinelNullExpr() which is more descriptive.
llvm-svn: 148772
2012-01-24 03:13:57 +00:00
Fariborz Jahanian 04c4455dd4 objective-c: Ignore with warning forward class declaration whose name
matches a typedef declaring an object type. // rdar://10733000

llvm-svn: 148760
2012-01-24 00:40:15 +00:00
Sebastian Redl 09edce0400 Minor fixups for auto deduction of initializer lists.
Fix some review comments.
Add a test for deduction when std::initializer_list isn't available yet.
Fix redundant error messages. This fixes and outstanding FIXME too.

llvm-svn: 148735
2012-01-23 22:09:39 +00:00
Argyrios Kyrtzidis ba52365ae3 Introduce Sema::isNullExpr() that contains the checks that
Sema::DiagnoseSentinelCalls() does.

llvm-svn: 148722
2012-01-23 20:38:53 +00:00
Kaelyn Uhrain cb7a0406c3 In CorrectTypo, use the cached correction as a starting point instead.
Previously, for unqualified lookups, a positive cache hit is used as the
only non-keyword correction and a negative cache hit immediately returns
an empty TypoCorrection. With the new callback objects, this behavior
causes false negatives by not accounting for the fact that callback
objects alter the set of potential/allowed corrections. The new behavior
is to seed the set of corrections with the cached correction (for
positive hits) to estabilishing a baseline edit distance. Negative cache
hits are only stored or used when either no callback object is provided
or when it returns true for a call to ValidateCandidate with an empty
TypoCorrection (i.e. when ValidateCandidate does not seem to be doing
any checking of the TypoCorrection, such as when an instance of the base
callback class is used solely to specify the set of keywords to be accepted).

llvm-svn: 148720
2012-01-23 20:18:59 +00:00
Douglas Gregor 1cc88a977c Handle pseudo-object expressions (and any other placeholder
expression) when code-completing member access expressions. Fixes
<rdar://problem/10717172>.

llvm-svn: 148703
2012-01-23 15:59:30 +00:00
Douglas Gregor 84585ab48e Downgrade C++11 narrowing conversion errors to warnings default-mapped
to an error, so that users can turn them off if necessary. Note that
this does *not* change the behavior of in a SFINAE context, where we
still flag an error even if the warning is disabled. This matches
GCC's behavior.

llvm-svn: 148701
2012-01-23 15:29:33 +00:00
Nico Weber 4bc649943f Add a source range to the ms path. Spotted by David Blaikie.
llvm-svn: 148683
2012-01-23 06:08:16 +00:00
Nico Weber 5882927d7a In microsoft mode, downgrade pseudo-destructors on void from error to warning.
This matches cl.exe's behavior and fixes PR11791.

llvm-svn: 148682
2012-01-23 05:50:57 +00:00
David Blaikie 60ac6382e0 Implement -Wswitch-enum correctly.
Clang previously implemented -Wswitch-enum the same as -Wswitch. This patch
corrects the behavior to match GCC's. The critical/only difference being that
-Wswitch-enum is not silenced by the presence of a default case in the switch.

llvm-svn: 148679
2012-01-23 04:46:12 +00:00
Nico Weber 323076f439 Eli says this should check MicrosoftMode instead.
Also change a || that I accidentally changed to && back to ||.

llvm-svn: 148677
2012-01-23 04:01:33 +00:00
Nico Weber 94e746d5e5 In ms mode, a move assignment operator shouldn't mark a copy ctor as deleted.
MSVC2010's pair class has a move assignment operator but no explicit copy
constructor, which makes it unusable without this change.

For symmetry, let move copy constructors not mark the default assignment
operator as deleted either. Both changes match cl.exe's behavior.  Fixes
pr11826.

Also update the standard excerpt to point to the right paragraph.

llvm-svn: 148675
2012-01-23 03:19:29 +00:00
Eli Friedman 844f945963 Make sure the AST correctly represents lvalue-to-rvalue conversions where appropriate.
llvm-svn: 148673
2012-01-23 02:35:22 +00:00
David Blaikie e476f979ca Fix -Wswitch to warn about out of bounds enum cases even when there's a default
For consistency with GCC & reasonable sanity. The FIXME suggests that the
original author was perhaps using the default check for some other purpose,
not realizing the more obvious limitation/false-negatives it creates, but this
doesn't seem to produce any regressions & fixes the included test.

llvm-svn: 148649
2012-01-22 02:31:55 +00:00
Francois Pichet 2056a69cb2 In Microsoft Mode, disable the C++11 strict integral conversion rules for enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode.
llvm-svn: 148642
2012-01-21 23:26:50 +00:00
David Blaikie 645ae0ce10 Add -Wswitch-enum-redundant-default.
This warning acts as the complement to the main -Wswitch-enum warning (which
warns whenever a switch over enum without a default doesn't cover all values of
 the enum) & has been an an-doc coding convention in LLVM and Clang in my
experience. The purpose is to ensure there's never a "dead" default in a
switch-over-enum because this would hide future -Wswitch-enum errors.

The name warning has a separate flag name so it can be disabled but it's grouped
under -Wswitch-enum & is on-by-default because of this.

The existing violations of this rule in test cases have had the warning disabled
& I've added a specific test for the new behavior (many negative cases already
exist in the same test file - and none regressed - so I didn't add more).

Reviewed by Ted Kremenek ( http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120116/051690.html )

llvm-svn: 148640
2012-01-21 18:12:07 +00:00
Rafael Espindola de15baf1f4 Remove redundant argument.
llvm-svn: 148628
2012-01-21 05:43:40 +00:00
Eli Friedman 02b5851823 Fix some comments relating to ExpressionEvaluationContexts. Get rid of a couple of uses of ConstantEvaluated which don't make sense.
llvm-svn: 148624
2012-01-21 04:44:06 +00:00
Eli Friedman d78a5d36d5 Add obvious missing call to MarkDeclarationReferenced.
llvm-svn: 148611
2012-01-21 01:07:00 +00:00
Eli Friedman e0afc98742 Make clang's AST model sizeof and typeof with potentially-evaluated operands correctly, similar to what we already do with typeid.
llvm-svn: 148610
2012-01-21 01:01:51 +00:00
Douglas Gregor 3aa55267c4 Fix the code completion string for variadic macros with more than one
argument, which was broken and very ugly (and even had a test case to
make *sure* it was broken and ugly). Fixes <rdar://problem/10609117>.

llvm-svn: 148606
2012-01-21 00:43:38 +00:00
DeLesley Hutchins 30398dd410 Delayed template instantiation of late-parsed attributes.
llvm-svn: 148595
2012-01-20 22:50:54 +00:00
DeLesley Hutchins ceec3063e2 Instantiate dependent attributes when instantiating templates.
llvm-svn: 148592
2012-01-20 22:37:06 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
Benjamin Kramer 4d08ccb2d5 Replace a dubious use of SmallVectorImpl with a proper copy.
llvm-svn: 148549
2012-01-20 16:39:18 +00:00
Benjamin Kramer 469214426a Localize variable, remove unused assignment.
Found by the clang static analyzer.

llvm-svn: 148544
2012-01-20 14:57:34 +00:00
Benjamin Kramer 1dd48bc76f Remove unused variables.
Found by clang's own static analyzer.

llvm-svn: 148542
2012-01-20 14:42:32 +00:00
Eli Friedman 456f01833b Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately.
llvm-svn: 148522
2012-01-20 01:26:23 +00:00
Richard Smith 45bb45523f An instantiation of a constexpr static data member in a class template is
constexpr.

llvm-svn: 148505
2012-01-19 22:46:17 +00:00
Tanya Lattner 3dd33b296a A few style changes.
Change CheckVectorLogicalOperands to pass params by ref.
Add another test case.

llvm-svn: 148452
2012-01-19 01:16:16 +00:00
Kaelyn Uhrain edb4acf16b Remove the now-unused CorrectTypoContext enum.
llvm-svn: 148441
2012-01-19 00:33:34 +00:00
Richard Smith f8379a0fc3 constexpr: converted constant expression handling for enumerator values, case
values and non-type template arguments of integral and enumeration types.

This change causes some legal C++98 code to no longer compile in C++11 mode, by
enforcing the C++11 rule that narrowing integral conversions are not permitted
in the final implicit conversion sequence for the above cases.

llvm-svn: 148439
2012-01-18 23:55:52 +00:00
Kaelyn Uhrain b1378408e4 Convert SemaDecl.cpp to pass callback objects to CorrectTypo.
Includes tests highlighting the cases where accuracy has improved
(there is one call that does no filtering beyond selecting the set
of allowed keywords, and one call that only triggers for ObjC code
for which a test by someone who knows ObjC would be welcome). Also
fixes a small typo in one of the suggestion messages, and drops a
malformed "expected-note" for a suggestion that did not occur even
when the malformed note was committed as r145930.

llvm-svn: 148420
2012-01-18 21:41:41 +00:00
Fariborz Jahanian 28324b0066 objc: deprecate direct usage of 'isa' of objc objects
in favor of usage of api's intended for.
// rdar://8290002

llvm-svn: 148404
2012-01-18 19:08:56 +00:00
Seth Cantrell 02f8605974 Fix char literal types in C
L'x' is actually wchar_t

support C11 u and U char literals

llvm-svn: 148390
2012-01-18 12:27:06 +00:00
Kaelyn Uhrain 79d01c1760 Convert DiagnoseEmptyLookup to use correction callbacks.
No new unit tests yet as there is no behavioral change
(except for slightly more specific filtering in
Sema::ActOnStartOfLambdaDefinition). Tests will be added
as the code paths are traced in greater depth to determine
how to improve the results--there are at least one or two
known bugs that require those improvements. This commit
lays the groundwork for those changes.

llvm-svn: 148382
2012-01-18 05:58:54 +00:00
Richard Smith 66e05fe630 Move narrowing conversion detection code from SemaInit to SemaOverload, ready
for it to be used in converted constant expression checking, and fix a couple
of issues:
 - Conversion operators implicitly invoked prior to the narrowing conversion
   were not being correctly handled when determining whether a constant value
   was narrowed.
 - For conversions from floating-point to integral types, the diagnostic text
   incorrectly always claimed that the source expression was not a constant
   expression.

llvm-svn: 148381
2012-01-18 05:21:49 +00:00
Eli Friedman 7bda7f7533 Make PotentiallyPotentiallyEvaluated contexts work correctly when referencing a class field from outside an instance method.
llvm-svn: 148376
2012-01-18 03:53:45 +00:00
Eli Friedman 1f4f9ddee8 The value of a case statement is a potentially evaluated context. Found by inspection.
llvm-svn: 148373
2012-01-18 02:54:10 +00:00
Eli Friedman fbc0dff6f8 Fix a couple issues where we didn't correctly delay diagnostics in PotentiallyPotentiallyEvaluated contexts. In preparation for making sizeof() PotentiallyPotentiallyEvaluated.
llvm-svn: 148367
2012-01-18 01:05:54 +00:00
Fariborz Jahanian c72a807039 objc-arc: when 'assign' attribute is unspecified,
rely on property's type for its life-time to avoid
bogus warning with -Warc-unsafe-retained-assign.
// rdar://10694932

llvm-svn: 148355
2012-01-17 22:58:16 +00:00
Sebastian Redl be24ec22fd Add Sema::isInitListConstructor. This will be needed for upcoming work.
llvm-svn: 148354
2012-01-17 22:50:14 +00:00
Sebastian Redl 42acd4a05b Auto deduction support for std::initializer_list, including for-range support. This means you can now write:
for (int i : {1, 4, 512, 23, 251}) {}

llvm-svn: 148353
2012-01-17 22:50:08 +00:00
Sebastian Redl 43144e72b5 Template argument deduction for std::initializer_list arguments from initializer lists.
llvm-svn: 148352
2012-01-17 22:49:58 +00:00
Sebastian Redl fb0b1f1f1f Rename the first of 11 DeduceTemplateArguments overloads.
There are 5 functions of this name in Sema, and 6 more static helpers in
SemaTemplateDeduction.cpp. The Sema functions have jobs like "deduce for
function call", "deduce for taking the address", etc. The static helpers
have jobs like "deduce by comparing two types", "deduce by comparing two
lists of types", "deduce by comparing two template arguments", etc.
The fact that they all are called the same and only differ in two of their
6 or more arguments makes the code using them very hard to read.

Here I rename the one function that concerns me most at the moment, but
as a matter of cleanup, the others will eventually be renamed as well.

llvm-svn: 148351
2012-01-17 22:49:52 +00:00
Sebastian Redl 10f0fc04a8 Basic overloading support for std::initializer_list.
llvm-svn: 148350
2012-01-17 22:49:48 +00:00
Sebastian Redl c1839b1b09 Sema support for initialization of std::initializer_list from initializer lists.
This does not yet support CodeGen.

llvm-svn: 148349
2012-01-17 22:49:42 +00:00
Sebastian Redl 2bfa104b40 Add Sema::isStdInitializerList, which will be necessary for the upcoming operations.
llvm-svn: 148348
2012-01-17 22:49:33 +00:00
Eli Friedman 419b1ff677 Correctly resolve an overload set passed to an overloaded operator=. PR11784.
llvm-svn: 148335
2012-01-17 21:27:43 +00:00
Jean-Daniel Dupas 0ae6e671cc Fix a couples of issues in format strings checking.
PR 10274: format function attribute with the NSString archetype yields no compiler warnings
PR 10275: format function attribute isn't checked in Objective-C methods

llvm-svn: 148324
2012-01-17 20:03:31 +00:00
Fariborz Jahanian 9d7cf2baaf objc: fixes a bug where struct used inside an
objc class was not being exported to parent decl
context resulting in bogus mismatch warning later on.
// rdar://10655530

llvm-svn: 148320
2012-01-17 18:52:07 +00:00
Douglas Gregor d53ae83516 Delay the creation of the built-in Objective-C class 'Protocol' by
moving it from a "special type" to a predefined declaration, as we do
for id, Class, and SEL.

llvm-svn: 148313
2012-01-17 18:09:05 +00:00
David Blaikie 60deeee783 Re-add an over-zealously removed break.
llvm-svn: 148296
2012-01-17 08:24:58 +00:00
David Blaikie d72e5c0dac Remove dead comments as per Chandler's feedback to r148292
llvm-svn: 148294
2012-01-17 07:28:46 +00:00
David Blaikie 8a40f700e6 Remove unreachable code in Clang. (replace with llvm_unreachable where appropriate or when GCC requires it)
llvm-svn: 148292
2012-01-17 06:56:22 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Argyrios Kyrtzidis 8d05ca7dd2 Introduce a CodeCompletionResult::CreateCodeCompletionString() that
does not depend on Sema, it accepts an ASTContext and a Preprocessor.

Step towards making clang_getCursorCompletionString not depend on Sema.

llvm-svn: 148278
2012-01-17 02:15:51 +00:00
Argyrios Kyrtzidis f34950d26a Introduce a static Sema::MarkDeducedTemplateParameters() that only depends
on an ASTContext.

This is a step towards making clang_getCursorCompletionString not depend on Sema.

llvm-svn: 148277
2012-01-17 02:15:41 +00:00
Eli Friedman 05e280156f Revert r148271; this requires more thought.
llvm-svn: 148276
2012-01-17 02:13:45 +00:00
Eli Friedman 4f97786e16 Change the behavior of the lvalue-to-rvalue conversion for varargs in PotentiallyPotentiallyEvaluated contexts so that we model it in a sane way in most cases, and give up for the edge case which hopefully doesn't matter too much.
In preparation for correctly treating sizeof() as a PotentiallyPotentiallyEvaluated context.

llvm-svn: 148271
2012-01-17 01:17:46 +00:00
Anna Zaks 2212270e71 Use Builtin ID as the return value
for FunctionDecl::getMemoryFunctionKind().

This is a follow up on the Chris's review for r148142: We don't want to
pollute FunctionDecl with an extra enum. (To make this work, added
memcmp and family to the library builtins.)

llvm-svn: 148267
2012-01-17 00:37:07 +00:00
Tanya Lattner 20248226a9 Add support for OpenCL 1.1 logical operations.
llvm-svn: 148254
2012-01-16 21:02:28 +00:00
Eli Friedman 2dfa79325c Add some calls to MarkDeclarationReferenced, towards a point where every declaration which is used is marked as used.
llvm-svn: 148253
2012-01-16 21:00:51 +00:00
David Chisnall fa35df628a Some improvements to the handling of C11 atomic types:
- Add atomic-to/from-nonatomic cast types
- Emit atomic operations for arithmetic on atomic types
- Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load
- Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type.  This is needed for the corresponding C11 stdatomic.h function.
- Enables the relevant __has_feature() checks.  The feature isn't 100% complete yet, but it's done enough that we want people testing it.

Still to do:

- Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg.
- Add a signal fence builtin
- Properly set the fenv state in atomic operations on floating point values
- Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context)
- Fix the many remaining corner cases

llvm-svn: 148242
2012-01-16 17:27:18 +00:00
David Blaikie ca043229c7 Refactor variables unused under non-assert builds.
llvm-svn: 148229
2012-01-16 05:16:03 +00:00
Richard Smith 2ec4061e39 Pedantic diagnostic correction: in C++, we have integral constant expressions,
not integer constant expressions. In passing, fix the 'folding is an extension'
diagnostic to not claim we're accepting the code, since that's not true in
-pedantic-errors mode, and add this diagnostic to -Wgnu.

llvm-svn: 148209
2012-01-15 03:51:30 +00:00
Benjamin Kramer 490afa6b9d Use a smaller vector than SmallVector.
Shrinks OverloadCandidate from 208 to 168 bytes.

llvm-svn: 148204
2012-01-14 21:05:10 +00:00
Benjamin Kramer 02b0843684 Clear ImplicitConversionSequence the obvious way which turns out to be less fragile.
llvm-svn: 148200
2012-01-14 20:16:52 +00:00
Benjamin Kramer 0b9c509c4e Give OverloadCandidateSet the responsibility for destroying the implicit conversion sequences so we don't get double frees when the vector reallocates.
llvm-svn: 148198
2012-01-14 19:31:39 +00:00
Fariborz Jahanian 52d02f68e5 objc: disallow __block attribute on method params.
llvm-svn: 148197
2012-01-14 18:44:35 +00:00
Douglas Gregor ec9fd13c77 De-virtualize getPreviousDecl() and getMostRecentDecl() when we know
we have a redeclarable type, and only use the new virtual versions
(getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have
that type information. This keeps us from penalizing users with strict
type information (and is the moral equivalent of a "final" method).

Plus, settle on the names getPreviousDecl() and getMostRecentDecl()
throughout.

llvm-svn: 148187
2012-01-14 16:38:05 +00:00
Benjamin Kramer b009517ad4 Pool allocate ImplicitConversionSequences.
To avoid malloc thrashing give OverloadCandidateSet an inline capacity for conversion sequences.
We use the fact that OverloadCandidates never outlive the OverloadCandidateSet and have a fixed
amount of conversion sequences.

This eliminates the oversized SmallVector from OverloadCandidate shrinking it from 752 to 208 bytes.

On the test case from the "Why is CLANG++ so freaking slow" thread on llvmdev this avoids one gig
of vector reallocation (including memcpy) which translates into 5-10% speedup on Lion/x86_64.

Overload candidate computation is still the biggest malloc contributor when compiling templated
c++ code.

llvm-svn: 148186
2012-01-14 16:32:05 +00:00
Benjamin Kramer fb761ff544 OverloadCandidateSet: Stop exposing SmallVector internals
Replace push_back with addCandidate which will let us make use of the fixed size of
the conversion sequence vector soon.

llvm-svn: 148185
2012-01-14 16:31:55 +00:00
Douglas Gregor 0bc8a21dba Introduce Decl::getPreviousDecl() and Decl::getMostRecentDecl(),
virtual functions that provide previous/most recent redeclaration
information for any declaration. Use this to eliminate the redundant,
less efficient getPreviousDecl() functions.

llvm-svn: 148184
2012-01-14 15:55:47 +00:00
Eli Friedman c09e0557a5 Progress towards making isUsed() reflect whether a declaration is odr-used; don't set isUsed for local variables which are referenced in unevaluated contexts. Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate.
I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check.  Someone who actually understands the semantics here should fix that.

llvm-svn: 148158
2012-01-13 23:41:25 +00:00
Kaelyn Uhrain 637b5b3235 Convert SemaTemplate*.cpp to pass a callback object to CorrectTypo.
The change to SemaTemplateVariadic.cpp improves the typo correction
results in certain situations, while the change to SemaTemplate.cpp
does not change existing behavior.

llvm-svn: 148155
2012-01-13 23:10:36 +00:00
Douglas Gregor 81bd038623 Make sure to consider non-DeclContext scopes properly when finding
multiple name lookup results in C/Objective-C. Fixes a regression a
caused in r147533, found by Enea Zaffanella!

llvm-svn: 148154
2012-01-13 23:06:53 +00:00