Commit Graph

7933 Commits

Author SHA1 Message Date
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
Anna Zaks 201d489cb8 Move identification of memory setting and copying functions (memset,
memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic
could be reused in the analyzer.

llvm-svn: 148142
2012-01-13 21:52:01 +00:00
Kaelyn Uhrain 3658e6a636 Convert SemaExprMember.cpp to pass a callback object to CorrectTypo,
improving the typo correction results in certain situations.

This is also the first typo correction callback conversion to affect
an existing unit test. :)

llvm-svn: 148140
2012-01-13 21:28:55 +00:00
Richard Smith d7d5790cb6 Refactor for clarity.
llvm-svn: 148135
2012-01-13 19:34:55 +00:00
Richard Smith 7971b69f74 PR11754: Reject non-static constexpr member functions in classes with virtual
base classes.

llvm-svn: 148094
2012-01-13 04:54:00 +00:00
Eli Friedman c8002429e5 constexpr is allowed on static member functions of non-literal classes. Per report on cfe-dev.
llvm-svn: 148090
2012-01-13 02:31:53 +00:00
Eli Friedman 9a766c4043 A few minor improvements to error recovery trying to access member of a function. In particular, this restores the cool error recovery for the example from http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html , which regressed a few months back.
llvm-svn: 148089
2012-01-13 02:20:01 +00:00
Richard Smith 90b748e0d1 Don't crash while trying to diagnose a function declared at block scope with an
incomplete return type.

llvm-svn: 148088
2012-01-13 02:14:39 +00:00
Kaelyn Uhrain e31b88833a Fix up the calls to CorrectTypo in Sema*ObjC.cpp to use callback
objects, and add a basic CorrectionCandidateCallback template class
to simplify the fixups.

llvm-svn: 148085
2012-01-13 01:32:50 +00:00
Richard Smith 8d06f42448 Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
   another declarator and ended with a comma, then that comma was probably a
   typo for a semicolon:

   int n = 0, m = 1, l = 2, // k = 5;
   myImportantFunctionCall(); // oops!

 - If removing the parentheses would correctly initialize the object, then
   produce a note suggesting that fix.

 - Otherwise, if there is a simple initializer we can suggest which performs
   value-initialization, then provide a note suggesting a correction to that
   initializer.

Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.

llvm-svn: 148072
2012-01-12 23:53:29 +00:00
Kaelyn Uhrain fb96ec76ff Convert SemaCXXScopeSpec.cpp to pass a callback object to CorrectTypo,
improvng the typo correction results in certain situations.

llvm-svn: 148052
2012-01-12 22:32:39 +00:00
Fariborz Jahanian e74d47ed03 objc: do not warn when converting to a const id qualfied by its
list of protools. // rdar://10669694

llvm-svn: 148051
2012-01-12 22:12:08 +00:00
Kaelyn Uhrain b02c5e9356 Convert SemaInit.cpp to pass a callback object to CorrectTypo.
And once again improve the typo correction results in certain
situations just by moving the existing checks on the correction.

llvm-svn: 148037
2012-01-12 19:27:05 +00:00
Douglas Gregor bf3a826f2c In Objective-C++, actually compute the base type of a member access
expression for an Objective-C object or pointer type, so that we don't
attempt to treat the member name as a template. Fixes
<rdar://problem/10672501>.

llvm-svn: 148028
2012-01-12 16:11:24 +00:00
Argyrios Kyrtzidis a80f1bf262 Add IsImplicit field in ObjCMessageExpr that is true when the message
was constructed, e.g. for a property access.

This allows the selector identifier locations machinery for ObjCMessageExpr
to function correctly, in that there are not real locations to handle/report for
such a message.

llvm-svn: 148013
2012-01-12 02:34:39 +00:00
Eli Friedman 42b199c699 Fix some edge cases with C++ casts and placeholder expressions.
llvm-svn: 147984
2012-01-12 00:44:34 +00:00
Fariborz Jahanian 4f8cb1e83a objective-c: fixes a regression in looking up names
in class extensions and categories by recent refactoring
of objc class ASTs. // rdar://1066654

llvm-svn: 147982
2012-01-12 00:18:35 +00:00
Douglas Gregor aab36986ab Improve the diagnostic when trying to redefine a typedef with a
variably-modified type.

llvm-svn: 147973
2012-01-11 22:33:48 +00:00
Kaelyn Uhrain 8811b3904c Fix the caching in CorrectTypo so that other non-keyword identifiers
are still added if the cached correction fails validation.

Also fix a copy-and-paste error in a comment from my previous commit.
Finally, add an example of the benefit the typo correction callback adds
to TryNamespaceTypoCorrection--which happens to also tickle the above
caching problem, as the only way a non-namespace Decl would be added to
the possible corrections is if it was cached as the correction for a
previous instance of the same typo where the typo was corrected to a
non-namespace via a different code path.

llvm-svn: 147968
2012-01-11 21:17:51 +00:00
Fariborz Jahanian a230dea394 minor refactoring to improve compile-time performance.
llvm-svn: 147963
2012-01-11 19:48:08 +00:00
Kaelyn Uhrain 2d317edcfd Add initial callback object support to Sema::CorrectTypo.
Also includes two examples of the callback: a wrapper/replacement for
the CorrectTypoContext enum, and a conversion of the two calls to
CorrectTypo in SemaDeclCXX.cpp (one of which provides verifiable
improvement to the typo correction, as demonstrated in the added test).

llvm-svn: 147962
2012-01-11 19:37:46 +00:00
Fariborz Jahanian 39ba639f9d objc-arc: evaluate 'readonly' property with no known
life-time to that of its backing 'ivar's lifetime.
// rdar://10558871

llvm-svn: 147956
2012-01-11 18:26:06 +00:00
Douglas Gregor 7363fb05fd C11 allows typedefs to be redefined. Implement this in C11 mode, and
downgrade the default-error warning to an ExtWarn in
C90/99. <rdar://problem/10668057>

llvm-svn: 147925
2012-01-11 04:25:01 +00:00
Eli Friedman 20139d3809 Start refactoring code for capturing variables and 'this' so that it is shared between lambda expressions and block literals.
llvm-svn: 147917
2012-01-11 02:36:31 +00:00
John McCall 9b80c2186f Do placeholder conversions on array bounds in both declarators and
new-expressions.

llvm-svn: 147900
2012-01-11 00:14:46 +00:00
Douglas Gregor 21b3b298c4 When something goes wrong in type-checking a namespace definition, make the namespace declaration invalid
llvm-svn: 147882
2012-01-10 22:14:10 +00:00
Fariborz Jahanian edbc345170 objc-arc: fixes a crash when trying to find out retaining cycle
ownership of property sent to 'super'. // rdar://10640891

llvm-svn: 147868
2012-01-10 19:28:26 +00:00
Chandler Carruth bfe8ecd347 Remove a set, but unused variable. Found with GCC's warning.
llvm-svn: 147864
2012-01-10 18:26:14 +00:00
Eli Friedman c4b251dc2b Implement the missing pieces of Evaluate for _Complex types. With that complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.)
llvm-svn: 147840
2012-01-10 04:58:17 +00:00
Eli Friedman 9163e360d6 Per John's comment, it makes sense to ask isLambda on any CXXRecordDecl; make sure that's safe. Get rid of a check which is now unnecessary in Sema::getFunctionLevelDeclContext().
llvm-svn: 147837
2012-01-10 03:38:46 +00:00
Richard Smith 0f8ee22655 Update C++11 scoped enumeration support to match the final proposal:
- reject definitions of enums within friend declarations
 - require 'enum', not 'enum class', for non-declaring references to scoped
   enumerations

llvm-svn: 147824
2012-01-10 01:33:14 +00:00
Fariborz Jahanian a08a74705b objc++: patch for IRgen for atomic properties of
c++ objects with non-trivial assignment/copy functions.
Also, one additional sema check. // rdar://6137845

llvm-svn: 147817
2012-01-10 00:37:01 +00:00
Eli Friedman 7f21bd74b8 Don't crash with -Wlarge-by-value-copy and a dependent type. PR11726.
llvm-svn: 147812
2012-01-09 23:46:59 +00:00
Nico Weber a8f80b31f9 Fix "note" of a duplicate explicit instantiation definition following a specialization.
llvm-svn: 147798
2012-01-09 19:52:25 +00:00
Douglas Gregor dbd93bfc2d Always allow redefinition of typedefs when modules are enabled. This
is important because it's fairly common for headers (especially system
headers) to want to provide only those typedefs needed for that
particular header, based on some guard macro, e.g.,

#ifndef _SIZE_T
#define _SIZE_T
typedef long size_t;
#endif

which is repeated in a number of headers. The guard macro protects
against duplicate definitions. However, this means that only the first
occurrence of this pattern actually defines size_t, so the submodule
corresponding to this header has the only visible definition. If a
user then imports a different submodule from the same module, size_t
will be known but not visible, and therefore cannot be used.

By allowing redefinition of typedefs, each header that wants to define
size_t can do so independently, so it will be available in the
corresponding submodules.

llvm-svn: 147775
2012-01-09 15:36:04 +00:00
Abramo Bagnara 3732fa5417 Made unknown builtin diagnostic remappable.
llvm-svn: 147774
2012-01-09 10:05:48 +00:00
Abramo Bagnara 1cd8368eb2 Fixed TypeofExpr AST and code generation.
llvm-svn: 147730
2012-01-07 10:52:36 +00:00
Douglas Gregor e57e752b71 Switch NamespaceDecl from its own hand-rolled redeclaration chain over
to Redeclarable<NamespaceDecl>, so that we benefit from the improveed
redeclaration deserialization and merging logic provided by
Redeclarable<T>. Otherwise, no functionality change.

As a drive-by fix, collapse the "inline" bit into the low bit of the
original namespace/anonymous namespace, saving 8 bytes per
NamespaceDecl on x86_64.

llvm-svn: 147729
2012-01-07 09:11:48 +00:00
Eli Friedman 73a040906d More lambda work: semantic analysis of capturing 'this'. It's a bit complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.)
llvm-svn: 147723
2012-01-07 04:59:52 +00:00
Eli Friedman 44803326d4 Lambdas: semantic analysis of explicit captures.
This patch (and some of my other commits related to lambdas) is heavily based off of John Freeman's work-in-progress patches.

llvm-svn: 147706
2012-01-07 01:08:17 +00:00
Matt Beaumont-Gay 7a57adab83 Suppress -Wunused-value within macros from system headers.
Along the way, move a helper function from SemaChecking.cpp to a more
accessible home in SourceManager.

llvm-svn: 147692
2012-01-06 22:43:58 +00:00
Douglas Gregor 5407920f82 During name lookup, use redecl_iterator to walk over the redeclaration
chain to determine whether any declaration of the given entity is
visible, eliminating the redundant (and less efficient)
getPreviousDeclaration() implementation.

This tweak uncovered an omission in the handling of
RedeclarableTemplateDecl, where we weren't making sure to search for
additional redeclarations of a template in other module files. Things
would be cleaner if RedeclarableTemplateDecl actually used Redeclarable.

llvm-svn: 147687
2012-01-06 22:05:37 +00:00
Rafael Espindola 7c23b0891b Improvements to the uninitialized variable warning: Check if the constructor
call is elidable or if the constructor is trivial instead of checking if it
is user declared.

llvm-svn: 147652
2012-01-06 04:54:01 +00:00
Eli Friedman 4817cf72f6 More lambda work. Fixes a minor bug Richard pointed out, makes lookup for lambda parameters work correctly, recording more information into the AST.
llvm-svn: 147650
2012-01-06 03:05:34 +00:00
Richard Smith b3851f5ca1 David Blaikie and Chandler would like us to diagnose
int f();

in function scopes under -Wvexing-parse, so now we do.

llvm-svn: 147649
2012-01-06 02:30:50 +00:00
Richard Smith d069d2f6ac Tweak to r147599 for PR10828: Move the check from the parser into sema, and use
the Semantic Powers to only warn on class types (or dependent types), where the
constructor or destructor could do something interesting.

llvm-svn: 147642
2012-01-06 01:31:20 +00:00
Eli Friedman 5c5e3b7e84 Minor refactoring of sentinel warning on blocks. Add a test for this warning.
llvm-svn: 147641
2012-01-06 01:23:10 +00:00
Ted Kremenek 0c2c90b1ad After further discussion, rename attribute 'objc_disable_automatic_synthesis' to 'objc_requires_property_definitions'.
llvm-svn: 147622
2012-01-05 22:47:47 +00:00
Eli Friedman de30e523b4 Tweak the fix to PR8977: an empty expression-list represents value initialization, not default initialization. Fixes PR11712.
llvm-svn: 147620
2012-01-05 22:34:08 +00:00
Eli Friedman 71c8055f8e More lambda work. Tweak the Sema interface slightly. Start adding the pieces to build the lambda class and its call operator. Create an actual scope for the lambda body.
llvm-svn: 147595
2012-01-05 03:35:19 +00:00
Douglas Gregor 5c193c7ed6 When we're performing name lookup for a tag, we still allow ourselves
to see hidden declarations because every tag lookup is effectively a
redeclaration lookup. For example, image that

  struct foo;

is declared in a submodule that is known but hasn't been imported. If
someone later writes

  struct foo *foo_p;

then "struct foo" is either a reference or a redeclaration. To keep
the redeclaration chains sound, we treat it like a redeclaration for
name-lookup purposes.

llvm-svn: 147588
2012-01-05 01:11:47 +00:00
Eli Friedman de958784d6 Minor cleanup; no functional change.
llvm-svn: 147582
2012-01-05 00:49:17 +00:00
John McCall a59dc2f8f0 The value of a const weak variable is not an integer constant.
llvm-svn: 147575
2012-01-05 00:13:19 +00:00
Ted Kremenek dec9d12fc4 Rename attribute 'objc_suppress_autosynthesis' to 'objc_disable_automatic_synthesis'.
llvm-svn: 147567
2012-01-04 23:51:09 +00:00
Douglas Gregor eb90e83085 Store the submodules of a module in source order, as they are stored
in the module map. This provides a bit more predictability for the
user, as well as eliminating the need to sort the submodules when
serializing them.

llvm-svn: 147564
2012-01-04 23:32:19 +00:00
Fariborz Jahanian 783ffde6d3 objc: When issuing warning for missing synthesis for
properties in classes declared with objc_suppress_autosynthesis
attribute, pinpoint location of the said class in a note.

llvm-svn: 147562
2012-01-04 23:16:13 +00:00
Eli Friedman fd5e54da2d Add an APValue representation for the difference between two address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer.
With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary.

Fixes PR11705.

llvm-svn: 147561
2012-01-04 23:13:47 +00:00
Douglas Gregor 9b7b39116e Implement declaration merging for typedefs loaded from disjoint
modules, so long as the typedefs refer to the same underlying
type. This ensures that the typedefs end up in the same redeclaration
chain.

To test this, fix name lookup for C/Objective-C to properly deal with
multiple declarations with the same name in the same scope.

llvm-svn: 147533
2012-01-04 16:44:10 +00:00
Rafael Espindola 2aa7acfadb Process attributes in explicit function template instantiations. Fixes part of
PR11690.

llvm-svn: 147523
2012-01-04 05:40:59 +00:00
Eli Friedman 36d129435e Add an explicit LambdaExprContext to Declarator, to parallel BlockLiteralContext. Use it to ensure semantic analysis of types isn't confused by the lack of a type specifier.
llvm-svn: 147522
2012-01-04 04:41:38 +00:00
Eli Friedman c7c97144af Stub out the Sema interface for lambda expressions, and change the parser to use it. Unconditionally error on lambda expressions because they don't work in any meaningful way yet.
llvm-svn: 147515
2012-01-04 02:40:39 +00:00
Fariborz Jahanian 1fc1c6c307 In non-gc, non-arc mode, property of 'Class' type
variety is treated as a 'void *'. No need to issue
warning reserved for objc object properties.
// rdar://10565506

llvm-svn: 147504
2012-01-04 00:31:53 +00:00
Douglas Gregor 6aeecf1791 Minor tweak to name lookup for C/Objective-C: after the first name, still consider whether this is a redeclaration lookup when determining whether to look for the visible declaration
llvm-svn: 147499
2012-01-03 23:34:23 +00:00
Douglas Gregor b59643baf6 Test "merging" of typedef types across distinct modules. At present,
the AST reader doesn't actually perform a merge, because name lookup
knows how to merge identical typedefs together.

As part of this, teach C/Objective-C name lookup to return multiple
results in all cases, rather than first digging through the attributes
to see if the value is overloadable. This way, we'll catch ambiguous
lookups in C/Objective-C.

llvm-svn: 147498
2012-01-03 23:26:26 +00:00
Fariborz Jahanian 7249e36704 objc: diagnose misplacement of objc_suppress_autosynthesis
attribute.

llvm-svn: 147490
2012-01-03 22:52:32 +00:00
Fariborz Jahanian 3c9707bd90 objc: use objc_suppress_autosynthesis attribute on classes
which should not be default synthesized.

llvm-svn: 147468
2012-01-03 19:46:00 +00:00
Fariborz Jahanian 9d4d20af55 objc: introduce objc_suppress_autosynthesis class
attributes for later use.

llvm-svn: 147457
2012-01-03 18:45:41 +00:00
Douglas Gregor 22d0974b40 Introduce a non-uglified syntax for module imports in Objective-C:
@import identifier [. identifier]* ;

llvm-svn: 147452
2012-01-03 18:04:46 +00:00
Rafael Espindola 0b0620776a Process attributes in explicit template instatiation definitions. Fixes PR11690.
llvm-svn: 147441
2012-01-03 06:04:21 +00:00
Douglas Gregor 5dbf4eb66b Diagnose cases where the definition of a particular type is required,
is known (to Clang), but is not visible because the module has not yet
been imported.

llvm-svn: 147436
2012-01-02 17:18:37 +00:00
Douglas Gregor fe620daefa Eliminate ObjCProtocolDecl's end-of-definition location. It is not
used anywhere.

llvm-svn: 147422
2012-01-02 02:22:52 +00:00
Douglas Gregor 1bd9617671 Move ObjCProtocolDecl::EndLoc into its DefinitionData, and give
ObjCProtocolDecl proper source-range information.

llvm-svn: 147420
2012-01-02 01:18:16 +00:00
Douglas Gregor 05a1f4d60b Eliminate the ForwardDecl/InitiallyForwardDecl bits from ObjCProtocolDecl. They are no longer needed
llvm-svn: 147419
2012-01-01 22:06:18 +00:00
Douglas Gregor f610267581 Eliminate ObjCForwardProtocolDecl, which is redundant now that
ObjCProtocolDecl modules forward declarations properly.

llvm-svn: 147415
2012-01-01 21:23:57 +00:00
Douglas Gregor 42ff1bb922 Eliminate ASTMutationListener::UpdatedAttributeList, which is no
longer needed now that we aren't back-patching ObjCProtocolDecls.

llvm-svn: 147413
2012-01-01 20:33:24 +00:00
Douglas Gregor 32c1757730 Wire up redeclaration chains for Objective-C protocols, so that both
forward declarations and definitions of an Objective-C protocol are
represented within a single chain of ObjCProtocolDecls.

llvm-svn: 147412
2012-01-01 20:30:41 +00:00
Douglas Gregor a715bfff98 Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, including:
  - Using the first declaration as the canonical declaration
  - Using the definition as the primary DeclContext
  - Making sure that all declarations have a pointer to the definition
  data, and that we know which declaration is the definition
  - Serialization support for redeclaration chains and for adding
  definitions to already-serialized declarations.

However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCProtocolDecls.

llvm-svn: 147410
2012-01-01 19:51:50 +00:00
Douglas Gregor e6e48b1490 Move the data that corresponds to the definition of a protocol into a
separately-allocated DefinitionData structure. Introduce various
functions that will help with the separation of declarations from
definitions (isThisDeclarationADefinition(), hasDefinition(),
getDefinition()).

llvm-svn: 147408
2012-01-01 19:29:29 +00:00
Rafael Espindola 01fb1135d6 Use hasSameType.
llvm-svn: 147407
2012-01-01 18:36:59 +00:00
Richard Smith e434590bd9 Change the diagnostics which said 'accepted as an extension' to instead say
'is an extension'. The former is inappropriate and confusing when building with
-Werror/-pedantic-errors.

llvm-svn: 147357
2011-12-29 21:57:33 +00:00
Richard Smith 5fab0c9e1a Small refactoring and simplification of constant evaluation and some of its
clients. No functionality change.

llvm-svn: 147318
2011-12-28 19:48:30 +00:00
Douglas Gregor deafd0b2a4 Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDecl
covers both declarations (@class) and definitions (@interface) of an
Objective-C class.

llvm-svn: 147299
2011-12-27 22:43:10 +00:00
Rafael Espindola cde2c8f7d2 Delay checking of typedefs of dependent types. Fixes PR11630.
llvm-svn: 147281
2011-12-26 22:42:47 +00:00
Richard Smith f0215fe898 Fix constexpr handling to allow 'extern constexpr' variable declarations. We no
longer have access to the source locations we need to produce the
'replace constexpr with const' fixits, so they're gone for now.

llvm-svn: 147273
2011-12-25 21:17:58 +00:00
Rafael Espindola 65e025cad5 Remove unused variables.
llvm-svn: 147260
2011-12-25 01:18:52 +00:00
Richard Smith 966c1fb0c8 Always implicitly declare move assignment operations for dynamic classes, in
case they override virtual functions from a base class. Also fix -print-stats
counting of move assignment/construction.

llvm-svn: 147258
2011-12-24 21:56:24 +00:00
Nico Weber d3bdadf616 Fix several issues related to specializations and explicit instantiations.
Explicit instantiations following specializations are no-ops and hence have
no PointOfInstantiation. That was done correctly in most cases, but for a
specialization -> instantiation decl -> instantiation definition chain, the
definition didn't realize that it was a no-op. Fix that.

Also, when printing diagnostics for these no-ops, get the diag location from
the decl name location.

Add many test cases, one of them not yet passing (but it failed the same way
before this change). Fixes http://llvm.org/pr11558 and more.

llvm-svn: 147225
2011-12-23 20:58:04 +00:00
Benjamin Kramer e56f393249 Mass rename C1x references to C11. The name hasn't proliferated like "C++0x" so this patch is surprisingly small.
Also drop -Wc1x-extensions in favor of -Wc11-extensions. I don't think we need to keep this around for compatibility.

llvm-svn: 147221
2011-12-23 17:00:35 +00:00
Nick Lewycky 097f47ce02 Fix build under -Wswitch by adding support for FK_ListConstructorOverloadFailed
to initialization sequence dumping.

llvm-svn: 147171
2011-12-22 20:21:32 +00:00
Sebastian Redl 6901c0de67 Overloading for initializer list construction.
llvm-svn: 147156
2011-12-22 18:58:38 +00:00
Sebastian Redl ed2e53222f List-initialization via constructor part 1. Still needs: pretty-printing, overloading, initializer_list.
llvm-svn: 147145
2011-12-22 14:44:04 +00:00
Richard Smith cc36f698af PR11614: Mark defaulted special constructors as constexpr if their implicit
definition would satisfy the constexpr requirements.

llvm-svn: 147128
2011-12-22 02:22:31 +00:00
Richard Smith 242ad89a15 C++11 half of r147023: In C++11, additionally eagerly instantiate:
- constexpr function template instantiations
 - variables of reference type
 - constexpr variables

llvm-svn: 147031
2011-12-21 02:55:12 +00:00
Richard Smith ed2974f3cf C++ constant expression handling: eagerly instantiate static const integral data
members of class templates so that their values can be used in ICEs. This
required reverting r105465, to get such instantiated members to be included in
serialized ASTs.

llvm-svn: 147023
2011-12-21 00:25:33 +00:00
Fariborz Jahanian 13d08955ea objc QOI: Don't't warn about mismatch between attributes
on method declaration and definition if former is in
a system header. // rdar://10580333

llvm-svn: 147020
2011-12-21 00:09:11 +00:00
Fariborz Jahanian 028b9e1d0a objc/c++: Issue diagnostic when free-standing ivar is accessed
in class method instead of crash. // rdar://10593227

llvm-svn: 146998
2011-12-20 22:21:08 +00:00
Nico Weber 3ffc4c93fd Fix a crash on invalid, http://llvm.org/pr11599
llvm-svn: 146988
2011-12-20 20:32:49 +00:00
Douglas Gregor 21823bfe31 When performing name lookup for a redeclaration, ignore module
visibility restrictions. This ensures that all declarations of the
same entity end up in the same redeclaration chain, even if some of
those declarations aren't visible. While this may seem unfortunate to
some---why can't two C modules have different functions named
'f'?---it's an acknowedgment that a module does not introduce a new
"namespace" of names.

As part of this, stop merging the 'module-private' bit from previous
declarations to later declarations, because we want each declaration
in a module to stand on its own because this can effect, for example,
submodule visibility.

Note that this notion of names that are invisible to normal name
lookup but are available for redeclaration lookups is how we should
implement friend declarations and extern declarations within local
function scopes. I'm not tackling that problem now.

llvm-svn: 146980
2011-12-20 18:11:52 +00:00
Chandler Carruth 1c032e0dc0 Update the CMake build for r146959's new files.
llvm-svn: 146967
2011-12-20 08:42:15 +00:00
Richard Smith 0f8ede1654 Revert r146766, and add a testcase for which it introduced a wrong-code bug.
llvm-svn: 146961
2011-12-20 04:00:21 +00:00
David Blaikie 68e081d606 Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
llvm-svn: 146959
2011-12-20 02:48:34 +00:00