Commit Graph

7826 Commits

Author SHA1 Message Date
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