Commit Graph

7826 Commits

Author SHA1 Message Date
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
Richard Smith 764d2fe666 Unlike in C++03, a constant-expression is not an unevaluated operand in C++11.
Split out a new ExpressionEvaluationContext flag for this case, and don't treat
it as unevaluated in C++11. This fixes some crash-on-invalids where we would
allow references to class members in potentially-evaluated constant expressions
in static member functions, and also fixes half of PR10177.

The fix to PR10177 exposed a case where template instantiation failed to provide
a source location for a diagnostic, so TreeTransform has been tweaked to supply
source locations when transforming a type. The source location is still not very
good, but MarkDeclarationsReferencedInType would need to operate on a TypeLoc to
improve it further.

Also fix MarkDeclarationReferenced in C++98 mode to trigger instantiation for
static data members of class templates which are used in constant expressions.
This fixes a link-time problem, but we still incorrectly treat the member as
non-constant. The rest of the fix for that issue is blocked on PCH support for
early-instantiated static data members, which will be added in a subsequent
patch.

llvm-svn: 146955
2011-12-20 02:08:33 +00:00
Richard Smith d0b4dd656d constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'
variable is initialized by a non-constant expression, and pass in the variable
being declared so that earlier-initialized fields' values can be used.

Rearrange VarDecl init evaluation to make this possible, and in so doing fix a
long-standing issue in our C++ constant expression handling, where we would
mishandle cases like:

  extern const int a;
  const int n = a;
  const int a = 5;
  int arr[n];

Here, n is not initialized by a constant expression, so can't be used in an ICE,
even though the initialization expression would be an ICE if it appeared later
in the TU. This requires computing whether the initializer is an ICE eagerly,
and saving that information in PCH files.

llvm-svn: 146856
2011-12-19 06:19:21 +00:00
Benjamin Kramer 198e0836f2 Silence gcc warnings.
llvm-svn: 146847
2011-12-18 12:18:02 +00:00
Douglas Gregor 05f10357a9 Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.

The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed). 

As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.

This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.

llvm-svn: 146841
2011-12-17 23:38:30 +00:00
Eli Friedman e321795c60 Remove a non-gcc-compatible extension that would apply attributes on declarations without a declarator to structs. Add a warning for ignored attributes. Patch by Michael Han.
llvm-svn: 146796
2011-12-17 00:36:09 +00:00
Nicola Gigante 3533eb4f5c Fix an inconsistency in the syntactic form of InitListExpr in case of initialization that involves a ConstructorConversion
llvm-svn: 146766
2011-12-16 22:57:37 +00:00
Richard Smith 13f6718b42 PR11594: Don't blindly build a UnaryOperator UO_Minus on an expression which
might not be an rvalue when checking array accesses. Instead, pass through a
flag indicating the array index is negated.

llvm-svn: 146753
2011-12-16 19:31:14 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
David Blaikie 1d578782fa Support decltype in pseudo destructors and dependent destructor calls.
Reviewed by Eli Friedman.

llvm-svn: 146738
2011-12-16 16:03:09 +00:00
Fariborz Jahanian 21c2484454 objc: after issuing the warning on direct use of __attribute__((NSObject))
on properties, prevent consequential error  diagnostics. // rdar://10591336

llvm-svn: 146737
2011-12-16 15:54:29 +00:00
Douglas Gregor ab1ec82e04 Fix chaining of ObjCInterfaceDecl redeclarations
llvm-svn: 146722
2011-12-16 03:12:41 +00:00
Sean Callanan caa69f0570 Sema::RequireCompleteType currently attempts to
instantiate a class from its template pattern
before it consults the ExternalASTSource.  LLDB
in particular will sometimes provide patterns
that need to be completed first.

To make this possible, I have moved the
completion before the code that does the
instantiation, allowing the ExternalASTSource
to provide the required information.

llvm-svn: 146715
2011-12-16 00:20:31 +00:00
Douglas Gregor 16408325af Move ObjCInterfaceDecl's "EndLoc" into DefinitionData, since it only
applies to an actual definition. Plus, clarify the purpose of this
field and give the accessor a different name, since getLocEnd() is
supposed to be the same as getSourceRange().getEnd().

llvm-svn: 146694
2011-12-15 22:34:59 +00:00
Douglas Gregor 95ab186240 When name lookup finds a module-private Objective-C class declaration,
check whether any previous declarations of the class were visible.

llvm-svn: 146680
2011-12-15 20:36:27 +00:00
Douglas Gregor dc9166c8e1 Keep track of all declarations of an Objective-C class (both forward
declarations and definitions) as ObjCInterfaceDecls within the same
redeclaration chain. This new representation matches what we do for
C/C++ variables/functions/classes/templates/etc., and makes it
possible to answer the query "where are all of the declarations of
this class?"

llvm-svn: 146679
2011-12-15 20:29:51 +00:00
Richard Smith 0cc85787f7 Refactor and simplify AddInitializerToDecl.
llvm-svn: 146673
2011-12-15 19:20:59 +00:00
Douglas Gregor 2039ca061f Two null Decl*'s don't refer to the same declaration, because they
don't refer to anything. Amusingly, we were relying on this in one
place. Thanks to Chandler for noticing the weirdness in
declaresSameEntity.

llvm-svn: 146659
2011-12-15 17:15:07 +00:00
Hans Wennborg 23926bd2d7 Support the 'a' length modifier in scanf format strings as a C90
extension.

This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess
errors).

llvm-svn: 146649
2011-12-15 10:25:47 +00:00
Douglas Gregor c0ac7d688e Move the definition-specific data of ObjCInterfaceDecl into a
separately-allocated DefinitionData structure, which we manage the
same way as CXXRecordDecl::DefinitionData. This prepares the way for
making ObjCInterfaceDecls redeclarable, to more accurately model
forward declarations of Objective-C classes and eliminate the mutation
of ObjCInterfaceDecl that causes us serious trouble in the AST reader.

Note that ObjCInterfaceDecl's accessors are fairly robust against
being applied to forward declarations, because Clang (and Sema in
particular) doesn't perform RequireCompleteType/hasDefinition() checks
everywhere it has to. Each of these overly-robust cases is marked with
a FIXME, which we can tackle over time.

llvm-svn: 146644
2011-12-15 05:27:12 +00:00
Eli Friedman 8349dc1fd6 Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning in the case of a shifted bitfield. PR11572.
llvm-svn: 146634
2011-12-15 02:41:52 +00:00
Fariborz Jahanian 9e49b6a6ff objc: do not auto synthesize properties declared in
protocols; with a warning. // rdar://10567333

llvm-svn: 146626
2011-12-15 01:03:18 +00:00
Douglas Gregor 95715f9ecf In debugger support mode, if we have a top-level message send
expression with an unknown result type, assume that the result type is
'id'. Fixes <rdar://problem/10400663>.

llvm-svn: 146622
2011-12-15 00:53:32 +00:00
Douglas Gregor 0b144e160a Replace all comparisons between ObjCInterfaceDecl pointers with calls
to declaresSameEntity(), as a baby step toward tracking forward
declarations of Objective-C classes precisely. Part of
<rdar://problem/10583531>.

llvm-svn: 146618
2011-12-15 00:29:59 +00:00
Richard Smith 902ca2138f Produce more detailed diagnostics when static_assert condition is not an ICE.
llvm-svn: 146607
2011-12-14 23:32:26 +00:00
Douglas Gregor 7234103225 Don't consider an overloaded operator& when the expression is actually
going to be a pointer-to-member constant. Fixes <rdar://problem/10544564>.

llvm-svn: 146587
2011-12-14 21:23:13 +00:00
David Blaikie 96b4874b50 Move & comment the 'decltype in declarator-id' as suggested by Doug Gregor.
llvm-svn: 146576
2011-12-14 18:59:02 +00:00
Douglas Gregor 4a814568b2 When name lookup comes across a declaration that is in a module that
is not visible, look for any previous declarations of that entity that
might be visible.

llvm-svn: 146563
2011-12-14 16:03:29 +00:00
Matt Beaumont-Gay 5533a55172 r146430 lost some compile-time performance on MultiSource/Benchmarks/MiBench/security-rijndael; this gets most of it back.
llvm-svn: 146562
2011-12-14 16:02:15 +00:00
Richard Trieu 96ed5b6b47 Make the diagnostic message more consistant. Update the type comparison to
handle non-pointer types.  This is for the extra info printed when function
types are compared.

llvm-svn: 146525
2011-12-13 23:19:45 +00:00
Fariborz Jahanian c17c86b56c objc: diagnose duplicate declaration of methods
in classes. // rdar://10535349

llvm-svn: 146504
2011-12-13 19:40:34 +00:00
David Blaikie 42b99e08e6 Disallow decltype in qualified declarator-ids.
llvm-svn: 146480
2011-12-13 08:03:36 +00:00
Fariborz Jahanian b989e6e50a objc-arc: better diagnostic when block is declared
inside a struct/union.

llvm-svn: 146444
2011-12-12 23:17:04 +00:00
Matt Beaumont-Gay 9d570c438c Suppress -Warray-bounds in certain cases involving macros from system headers.
The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large.

llvm-svn: 146430
2011-12-12 22:35:02 +00:00
Richard Smith 92b1ce0a80 Prepare constant expression infrastructure for the generation of richer
diagnostics. No functionality change.

llvm-svn: 146365
2011-12-12 09:28:41 +00:00
David Blaikie 08608f6744 Fix/test decltype dtor calls with invalid base expression.
llvm-svn: 146354
2011-12-12 04:13:55 +00:00
Hans Wennborg b1a5e09f6f Check that arguments to a scanf call match the format specifier,
and offer fixits when there is a mismatch.

llvm-svn: 146326
2011-12-10 13:20:11 +00:00
Douglas Gregor 8ca0c6408e Make sure that we infer __strong, etc. when we instantiate variables
under ARC. Fixes <rdar://problem/10530209>.

llvm-svn: 146307
2011-12-10 01:22:52 +00:00
Fariborz Jahanian 88d510da9d Add ability to supply additional message to availability macros,
// rdar://10095131

llvm-svn: 146304
2011-12-10 00:28:41 +00:00
Douglas Gregor c7f46f20d1 When we manage to re-use an expression during tree transformation (=
template instantiation), and that expression might produce a
temporary, invoke MaybeBindToTemporary. Otherwise, we forget to
destroy objects, release objects, etc. Fixes <rdar://problem/10531073>.

llvm-svn: 146301
2011-12-10 00:23:21 +00:00
Richard Smith f57d8cb131 C++11 constant expressions: Don't use CheckICE in C++11; instead, determine
whether an expression is a (core) constant expression as a side-effect of
evaluation. This takes us from accepting far too few expressions as ICEs to
accepting slightly too many -- fixes for the remaining cases are coming next.

The diagnostics produced when an expression is found to be non-constant are
currently quite poor (with generic wording but reasonable source locations),
and will be improved in subsequent commits.

llvm-svn: 146289
2011-12-09 22:58:01 +00:00
David Blaikie 10eb4b67d8 Add notes for suppressing and (if it's a zero-arg function returning bool) fixing the function-to-bool conversion warning.
llvm-svn: 146280
2011-12-09 21:42:37 +00:00
Fariborz Jahanian e283346d0b objc-arc: diagnose synthesis of a 'weak unavailable' property.
// rdar://10535245

llvm-svn: 146272
2011-12-09 19:55:11 +00:00
David Blaikie 72b61203f4 Provide a separate warning for weak vtables in explicit template instantiations. There's no (current) way to fix such templates to emit strong symbols/vtables, but perhaps users want to know about the cost being incurred anyway.
llvm-svn: 146265
2011-12-09 18:32:50 +00:00
Hans Wennborg a5b1aa99c7 Make printf warnings refer to wint_t and wchar_t by name
in addition to underlying type.

llvm-svn: 146254
2011-12-09 12:22:12 +00:00
Argyrios Kyrtzidis 4996f5fba2 Save category name loc in ObjCCategoryImplDecl, patch by Jason Haslam!
llvm-svn: 146213
2011-12-09 00:31:40 +00:00
DeLesley Hutchins f7faa6a69b This patch extends thread safety analysis with support for the scoped_lockable attribute.
llvm-svn: 146174
2011-12-08 20:23:06 +00:00
David Blaikie ecd8a94acf Decltype in non-pseudo (& non-dependent) dtor calls.
llvm-svn: 146155
2011-12-08 16:13:53 +00:00
Hans Wennborg 70a1324428 Only do typo correction for implicit function decls when
they are treated as errors.

Doing typo correction when these are just warnings slows down the
compilation of source which deliberately uses implicit function
declarations.

llvm-svn: 146153
2011-12-08 15:56:07 +00:00
Hans Wennborg 772e9270f6 Make printf warnings refer to intmax_t et al. by name
in addition to underlying type.

For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"

(This is a second attempt after r145697, which got reverted.)

llvm-svn: 146032
2011-12-07 10:33:11 +00:00
Richard Smith 42d3af9d95 When folding the size of a global scope VLA to a constant, require the array
bound to not have side effects(!). Add constant-folding support for expressions
of void type, to ensure that we can still fold ((void)0, 1) as an array bound.

llvm-svn: 146000
2011-12-07 00:43:50 +00:00
Fariborz Jahanian 6bdeb14d5d objc: issue deprecated/unavailable diagnostic when
methods with these attributes are sent to receivers
of 'id' type too. // rdar://10459930

llvm-svn: 145999
2011-12-07 00:30:00 +00:00
Hans Wennborg 2fb8b91f6f Suggest typo corrections for implicit function declarations.
A mistyped function call becomes an inmplicit function declaration in C.
Suggest typo correction when one can be found.

llvm-svn: 145930
2011-12-06 09:46:12 +00:00
Erik Verbruggen c6c8d9356d Extend warnings for missing '@end'.
Fixes PR2709.

llvm-svn: 145928
2011-12-06 09:25:23 +00:00
Richard Trieu 5f623229ec Switch a cast to a dyn_cast and check the pointer before using. Fixes a crash
in the following code:

void test4(bool (&x)(void)) {
  while (x);
}

llvm-svn: 145918
2011-12-06 04:48:01 +00:00
Eli Friedman 7c6515a653 Make sure we perform lvalue-to-rvalue conversions for enum initializers. PR11484.
llvm-svn: 145874
2011-12-06 00:10:34 +00:00
Fariborz Jahanian 56f326e7f2 objc: put out more coherent warning when method definition
attributes don't match its declaration. // rdar://10529259.

llvm-svn: 145872
2011-12-06 00:02:41 +00:00
Lang Hames df5c121f8e Add a warning for implicit conversion from function literals (and static
methods) to bool. E.g.

void foo() {}
if (f) { ... // <- Warns here.
}

Only applies to non-weak functions, and does not apply if the function address
is taken explicitly with the addr-of operator.

llvm-svn: 145849
2011-12-05 20:49:50 +00:00
David Blaikie 15a430a368 Support decltype in nested-name-specifiers.
llvm-svn: 145785
2011-12-04 05:04:18 +00:00
Fariborz Jahanian 5c12ca8a25 Move block return type inference diagnostic to a common place where
Function or array lvalue conversions happens.

llvm-svn: 145782
2011-12-03 23:53:56 +00:00
Douglas Gregor dca70af22f Implement support for the __is_final type trait, to determine whether
a class is marked 'final', from Alberto Ganesh Barbati! Fixes
PR11462.

llvm-svn: 145775
2011-12-03 18:14:24 +00:00
Fariborz Jahanian dd5eb9df0c If block literal return type is not specified, return type of the block is
inferred from return types. All the return statements have to agree about the type.
// rdar://10466373

llvm-svn: 145774
2011-12-03 17:47:53 +00:00
Francois Pichet 9c39113fdb In Microsoft mode, don't perform typo correction in a template member function dependent context because it interferes with the "lookup into dependent bases of class templates" feature.
Basically typo correction will try to offer a correction instead of looking into type dependent base classes.

I found this problem while parsing Microsoft ATL code with clang.

llvm-svn: 145772
2011-12-03 15:55:29 +00:00
Sebastian Redl df88864273 Implement overload resolution for reference-typed parameters supplied with initializer lists.
llvm-svn: 145769
2011-12-03 14:54:30 +00:00
Douglas Gregor bcfc7d0229 When we treat an #include or #import as a module import, create an
implicit ImportDecl in the translation unit to record the presence of
the import.

llvm-svn: 145727
2011-12-02 23:42:12 +00:00
Douglas Gregor ba34552e79 Introduce a module import declaration, so that we properly represent, e.g.,
__import_module__ std.vector;

in the AST.

llvm-svn: 145725
2011-12-02 23:23:56 +00:00
Nick Lewycky 45ccba64ab Revert r145697 and dependent patch r145702. It added a dependency from
lib/Analysis to lib/Sema which is cyclical.

llvm-svn: 145724
2011-12-02 23:21:43 +00:00
Douglas Gregor 2a5d14898a Make sure that name lookup in C checks whether a name is hidden.
llvm-svn: 145700
2011-12-02 20:08:44 +00:00
Hans Wennborg 70f7213d2c Make conversion specifier warning refer to typedef if possible.
For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"

llvm-svn: 145697
2011-12-02 19:22:15 +00:00
Douglas Gregor 2b82c2a59e Implementing parsing and resolution of module export declarations
within module maps, which will (eventually) be used to re-export a
module from another module. There are still some pieces missing,
however.

llvm-svn: 145665
2011-12-02 01:47:07 +00:00
Douglas Gregor ff2be53f8f Introduce the notion of name visibility into modules. For a given
(sub)module, all of the names may be hidden, just the macro names may
be exposed (for example, after the preprocessor has seen the import of
the module but the parser has not), or all of the names may be
exposed. Importing a module makes its names, and the names in any of
its non-explicit submodules, visible to name lookup (transitively).

This commit only introduces the notion of name visible and marks
modules and submodules as visible when they are imported. The actual
name-hiding logic in the AST reader will follow (along with test cases).

llvm-svn: 145586
2011-12-01 17:11:21 +00:00
Douglas Gregor 11bb308457 When typo-correction an Objective-C superclass name, don't
typo-correct to ourselves.

llvm-svn: 145583
2011-12-01 15:37:53 +00:00
Douglas Gregor d8fb1e30eb When sending a message to a receiver that has "unknown any" type,
force the unknown any type to "id" so that the message send can be
completed without requiring a case. Fixes <rdar://problem/10506646>.

llvm-svn: 145552
2011-12-01 01:37:36 +00:00
Ted Kremenek 764d63ad94 Specially whitelist the selector 'addOperationWithBlock:' for the retain-cycle checking in -Warc-retain-cycles. This commonly
is hit by users using NSOperationQueue.  Fixes <rdar://problem/10465721>.

llvm-svn: 145548
2011-12-01 00:59:21 +00:00
Ted Kremenek 85825aebc9 Further tweak -Wurneachable-code and templates by allowing the warning to run on
explicit template specializations (which represent actual functions somebody wrote).

Along the way, refactor some other code which similarly cares about whether or
not they are looking at a template instantiation.

llvm-svn: 145547
2011-12-01 00:59:17 +00:00
Douglas Gregor de3ef502a9 Promote ModuleMap::Module to a namespace-scope class in the Basic
library, since modules cut across all of the libraries. Rename
serialization::Module to serialization::ModuleFile to side-step the
annoying naming conflict. Prune a bunch of ModuleMap.h includes that
are no longer needed (most files only needed the Module type).

llvm-svn: 145538
2011-11-30 23:21:26 +00:00
Ted Kremenek 7f770032c7 Don't run -Wunreachable-code on template instantiations. Different instantiations may produce different unreachable code results, and it is very difficult for us to prove that ALL instantiations of a template have specific unreachable code. If we come up with a better solution, then we can revisit this, but this approach will at least greatly reduce the noise of this warning for code that makes use of templates.
llvm-svn: 145520
2011-11-30 21:22:09 +00:00
John McCall e929082806 Fix the instantiation of pseudo-object expressions. This is a
really bad way to go about this, but I'm not sure there's a better
choice without substantial changes to TreeTransform --- most
notably, preserving implicit semantic nodes instead of discarding
and rebuilding them.

llvm-svn: 145480
2011-11-30 04:42:31 +00:00
Douglas Gregor 71944203de Switch the module-loading interfaces and parser from a simple
top-level module name to a module path (e.g., std.vector). We're still
missing a number of pieces for this actually to do something.

llvm-svn: 145462
2011-11-30 00:36:36 +00:00
Richard Smith 507840dbff Revert r145244. It causes us to create broken ASTs with missing type information
for some cast expressions.

Original commit message:

Removed useless ImplicitCast nodes in explicit cstyle and static casts

llvm-svn: 145447
2011-11-29 22:48:16 +00:00
Matt Beaumont-Gay c93b489138 Suppress -Warray-bounds for classes (not just structs) where the last field is
a 1-length character array.

llvm-svn: 145445
2011-11-29 22:43:53 +00:00
Lang Hames c8c3b403c5 Test isa<FunctionDecl> to exclude objective-C methods. This ensures the following cast will never fail.
llvm-svn: 145441
2011-11-29 22:37:13 +00:00
Matt Beaumont-Gay b2339826e6 Merge branch 'yo-dawg-i-herd-u-like-arrays'
llvm-svn: 145421
2011-11-29 19:27:11 +00:00
Fariborz Jahanian a45495a9f2 objc: warn if NSObject attribute appears other than in a typedef.
// rdar://10453342

llvm-svn: 145358
2011-11-29 01:48:40 +00:00
Douglas Gregor 7db3e95b0d When synthesizing an implicitly-defined copy or move constructor, or
when computing the exception specification of a copy or move constructor,
ignore non-static data member initializers. Fixes PR11418 /
<rdar://problem/10478642>.

llvm-svn: 145269
2011-11-28 20:03:15 +00:00
Fariborz Jahanian 80b831c1a9 Remove code made redundant by my previous patch.
llvm-svn: 145266
2011-11-28 19:56:36 +00:00
Fariborz Jahanian 25d09c2209 pinpoint name/location of deprecated/unavailable enumerator
whose enum has been made deprecated/unavailable in the warning.
// rdar://10201690

llvm-svn: 145264
2011-11-28 19:45:58 +00:00
Fariborz Jahanian 22b405c7aa objc: turn warning for property type mismatch in
primary and its continuation class into error.
// rdar://10142679

llvm-svn: 145255
2011-11-28 18:38:27 +00:00
Douglas Gregor 7372248a98 When checking a call to a builtin atomic operation, be sure to
consider the _<width> variants as well, which we'll see if we're
performing the type checking in a template instantiation where the
call expression itself was originally not type-dependent. Fixes
PR11411.

llvm-svn: 145248
2011-11-28 16:30:08 +00:00
Nicola Gigante 13b6a2ae04 Removed useless ImplicitCast nodes in explicit cstyle and static casts
llvm-svn: 145244
2011-11-28 12:21:57 +00:00
Peter Collingbourne fbef4c8657 In Sema::MaybeBindToTemporary, create a CXXBindTemporaryExpr for an
array of objects with non-trivial destructors.  PR11365.

llvm-svn: 145203
2011-11-27 22:09:28 +00:00
Sebastian Redl 29526f09ce Reference initialization with initializer lists.
This supports single-element initializer lists for references according to DR1288, as well as creating temporaries and binding to them for other initializer lists.

llvm-svn: 145186
2011-11-27 16:50:07 +00:00
Nicola Gigante c8edb0f657 Test commit
llvm-svn: 145147
2011-11-26 16:20:01 +00:00
Abramo Bagnara edf99fff49 Fixed lexical declaration context when instantiating a friend / out-of-line class template member.
llvm-svn: 145146
2011-11-26 13:33:46 +00:00
Francois Pichet de232cb166 In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside a friend function definition at class scope.
Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext.

This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang.

llvm-svn: 145127
2011-11-25 01:10:54 +00:00
Richard Trieu caff247882 Add feature to diagnostics that will provide more information on function
pointer mismatch.  Cases covered are: initialization, assignment, and function
arguments.  Additional text will give the extra information about the nature
of the mismatch: different classes for member functions, wrong number of
parameters, different parameter type, different return type, and function
qualifier mismatch.

llvm-svn: 145114
2011-11-23 22:32:32 +00:00
Argyrios Kyrtzidis 8ad3bab505 [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

llvm-svn: 145109
2011-11-23 20:27:36 +00:00
Argyrios Kyrtzidis 41fc05cad8 [libclang] Indexing API: Fix issues, mostly C++ related.
llvm-svn: 145107
2011-11-23 20:27:26 +00:00
Abramo Bagnara 5001caa1b6 Fixed HadMultipleCandidates loading.
llvm-svn: 144995
2011-11-19 11:44:21 +00:00
Abramo Bagnara 12dcbf3eaa Fixed implicit instantiations source range.
llvm-svn: 144977
2011-11-18 08:08:52 +00:00
David Blaikie 0f65d59e52 Include named unions in union member init checking
llvm-svn: 144883
2011-11-17 06:01:57 +00:00
Francois Pichet 857f9d6e5e In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside default argument instantiation.
This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated.

This fixes 2 errors when parsing MFC code with clang.

llvm-svn: 144881
2011-11-17 03:44:24 +00:00
Abramo Bagnara b0cf297654 Added missing ImplicitCastExpr around conversion operator call.
llvm-svn: 144850
2011-11-16 22:46:05 +00:00
Bob Wilson 89d14247ff Fix Neon builtin pointer argument checking for "sret" builtins.
The code for checking Neon builtin pointer argument types was assuming that
there would only be one pointer argument.  But, for vld2-4 builtins, the first
argument is a special sret pointer where the result will be stored.  So,
instead of scanning all the arguments to find a pointer, have TableGen figure
out the index of the pointer argument that needs checking.  That's better than
scanning all the arguments regardless.  <rdar://problem/10448804>

llvm-svn: 144834
2011-11-16 21:32:23 +00:00
Abramo Bagnara d4756b9ece Fixed missing cast and wrong cast kind in delete expression.
llvm-svn: 144796
2011-11-16 15:42:13 +00:00
Francois Pichet 78286b24fd In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside static functions.
llvm-svn: 144729
2011-11-15 23:33:34 +00:00
Eli Friedman 4134073c4b Compute whether a class is trivial correctly for template classes with an explicitly deleted or defaulted special member. PR11387.
llvm-svn: 144715
2011-11-15 22:39:08 +00:00
Abramo Bagnara dc1646dc2b Fixed plausible overloads location.
llvm-svn: 144700
2011-11-15 21:43:28 +00:00