summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merging r156031:Bill Wendling2012-05-121-64/+0
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r156031 | rsmith | 2012-05-02 15:22:32 -0700 (Wed, 02 May 2012) | 4 lines Revert most of r154844, which was disabled in r155975. Keep around the refactorings in that revision, and some of the subsequent bugfixes, which seem to be relevant even without delayed exception specification parsing. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156684 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155293:Bill Wendling2012-05-121-2/+37
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155293 | rsmith | 2012-04-21 11:42:51 -0700 (Sat, 21 Apr 2012) | 4 lines Fix regression in r154844. If necessary, defer computing adjusted destructor exception specifications in C++11 until after we've parsed the exception specifications for nested classes. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156683 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155218:Bill Wendling2012-05-121-12/+15
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r155218 | rsmith | 2012-04-20 11:46:14 -0700 (Fri, 20 Apr 2012) | 5 lines Fix bug where a class's (deleted) copy constructor would be implicitly given a non-const reference parameter type if the class had any subobjects with deleted copy constructors. This causes a rejects-valid if the class's copy constructor is explicitly defaulted (as happens for some implementations of std::pair etc). ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156682 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155424:Bill Wendling2012-05-121-4/+8
| | | | | | | | | | | | | ------------------------------------------------------------------------ r155424 | rsmith | 2012-04-23 22:06:35 -0700 (Mon, 23 Apr 2012) | 3 lines PR12629: Cope with parenthesized function types when attaching a delayed exception specification to a function. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156679 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155728:Bill Wendling2012-04-271-2/+4
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155728 | rsmith | 2012-04-27 12:33:05 -0700 (Fri, 27 Apr 2012) | 4 lines PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode. We do not support IRGen for these, and get some parts of the semantic analysis wrong. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@155731 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155279:Bill Wendling2012-04-211-1/+1
| | | | | | | | | | | ------------------------------------------------------------------------ r155279 | chapuni | 2012-04-21 02:40:04 -0700 (Sat, 21 Apr 2012) | 1 line SemaDeclCXX.cpp: Fix utf8 in comment. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@155295 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.Richard Smith2012-04-171-35/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154886 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-161-5/+140
| | | | | | | | | | exception specifications on member functions until after the closing '}' for the containing class. This allows, for example, a member function to throw an instance of its own class. Fixes PR12564 and a fairly embarassing oversight in our C++98/03 support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154844 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154799 91177308-0d34-0410-b5e6-96231b3b80d8
* My original patch missed the virtual-base case for destroyingJohn McCall2012-04-091-2/+3
| | | | | | | | | | | | base-class subojects. Incidentally, thinking about virtual bases makes it clear to me that we're not appropriately computing the access to the virtual base's member because we're not computing the best possible access to the virtual base at all; in fact, we're basically assuming it's public. I'll file a separate PR about that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154346 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the access check performed as part of the determination of whetherJohn McCall2012-04-091-2/+23
| | | | | | | | to define a special member function as deleted so that it properly establishes an object context for the accesses to the base subobject members. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154343 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix several problems with protected access control:John McCall2012-04-071-1/+9
| | | | | | | | | | | | | | | | | | | | | - The [class.protected] restriction is non-trivial for any instance member, even if the access lacks an object (for example, if it's a pointer-to-member constant). In this case, it is equivalent to requiring the naming class to equal the context class. - The [class.protected] restriction applies to accesses to constructors and destructors. A protected constructor or destructor can only be used to create or destroy a base subobject, as a direct result. - Several places were dropping or misapplying object information. The standard could really be much clearer about what the object type is supposed to be in some of these accesses. Usually it's easy enough to find a reasonable answer, but still, the standard makes a very confident statement about accesses to instance members only being possible in either pointer-to-member literals or member access expressions, which just completely ignores concepts like constructor and destructor calls, using declarations, unevaluated field references, etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154248 91177308-0d34-0410-b5e6-96231b3b80d8
* Point the caret at the error for the 'expected namespace name' diagnostic inRichard Smith2012-04-051-1/+1
| | | | | | | a namespace alias declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154138 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove dead assignment to local variable.Ted Kremenek2012-04-041-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153985 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10217 diagnostic fix: don't say 'copy constructor' when we meanRichard Smith2012-04-021-1/+1
| | | | | | | 'copy assignment operator'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153897 91177308-0d34-0410-b5e6-96231b3b80d8
* Finish PR10217: Ensure we say that a special member was implicitly, notRichard Smith2012-04-021-10/+10
| | | | | | | explicitly, deleted in all relevant cases, and explain why. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153894 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement DR1402: if a field or base class is not movable, the derived class'sRichard Smith2012-04-021-41/+138
| | | | | | | | | | | | move constructor/move assignment operator are not declared, rather than being defined as deleted, so move operations on the derived class fall back to copying rather than moving. If a move operation on the derived class is explicitly defaulted, the unmovable subobject will be copied instead of being moved. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153883 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic semantic analysis support for inheriting constructor declarations inRichard Smith2012-04-021-12/+12
| | | | | | | dependent contexts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153858 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-301-81/+186
| | | | | | | member function is deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153773 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor special member function deletion. No functionality change.Richard Smith2012-03-291-63/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153673 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify and fix our checking of C++ [dcl.meaning]p1's requirementsDouglas Gregor2012-03-281-4/+2
| | | | | | | | | | concerning qualified declarator-ids. We now diagnose extraneous qualification at namespace scope (which we had previously missed) and diagnose these qualification errors for all kinds of declarations; it was rather uneven before. Fixes <rdar://problem/11135644>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153577 91177308-0d34-0410-b5e6-96231b3b80d8
* Skip through transparent contexts when deciding where to add a friend function.Nick Lewycky2012-03-161-1/+1
| | | | | | | This fixes g++.dg/parse/friend5.C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152938 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that default arguments are handled correctly in sub scopes. For example:James Molloy2012-03-131-4/+14
| | | | | | | | | | | | | | | void f () { int g (int a, int b=4); { int g(int a, int b=5); } } should compile. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152621 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR10447: lazily building name lookup tables for DeclContexts was broken.Richard Smith2012-03-131-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | The deferred lookup table building step couldn't accurately tell which Decls should be included in the lookup table, and consequently built different tables in some cases. Fix this by removing lazy building of DeclContext name lookup tables. In practice, the laziness was frequently not worthwhile in C++, because we performed lookup into most DeclContexts. In C, it had a bit more value, since there is no qualified lookup. In the place of lazy lookup table building, we simply don't build lookup tables for function DeclContexts at all. Such name lookup tables are not useful, since they don't capture the scoping information required to correctly perform name lookup in a function scope. The resulting performance delta is within the noise on my testing, but appears to be a very slight win for C++ and a very slight loss for C. The C performance can probably be recovered (if it is a measurable problem) by avoiding building the lookup table for the translation unit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152608 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-35/+35
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12225: The requirement that literal operators be namespace-scope functionsRichard Smith2012-03-101-4/+1
| | | | | | | does not imply that such functions can't be declared at block scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152509 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-2/+2
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152491 91177308-0d34-0410-b5e6-96231b3b80d8
* Only make a call to a copy constructor elidable if in fact we areDouglas Gregor2012-03-101-1/+20
| | | | | | | doing a copy. Fixes PR12139. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152485 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST/Sema/libclang] Replace getSourceRange().getBegin() with getLocStart().Daniel Dunbar2012-03-091-15/+15
| | | | | | | | | - getSourceRange().getBegin() is about as awesome a pattern as .copy().size(). I already killed the hot paths so this doesn't seem to impact performance on my tests-of-the-day, but it is a much more sensible (and shorter) pattern. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152419 91177308-0d34-0410-b5e6-96231b3b80d8
* Literal operators can't have default arguments.Richard Smith2012-03-091-0/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152394 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for raw and template forms of numeric user-defined literals,Richard Smith2012-03-091-1/+7
| | | | | | | and lots of tidying up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++11 [lex.ext]p10 for string and character literals: a ud-suffix notRichard Smith2012-03-081-21/+6
| | | | | | | | | | | | | | | | | | | starting with an underscore is ill-formed. Since this rule rejects programs that were using <inttypes.h>'s macros, recover from this error by treating the ud-suffix as a separate preprocessing-token, with a DefaultError ExtWarn. The approach of treating such cases as two tokens is under discussion for standardization, but is in any case a conforming extension and allows existing codebases to keep building while the committee makes up its mind. Reword the warning on the definition of literal operators not starting with underscores (which are, strangely, legal) to more explicitly state that such operators can't be called by literals. Remove the special-case diagnostic for hexfloats, since it was both triggering in the wrong cases and incorrect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152287 91177308-0d34-0410-b5e6-96231b3b80d8
* static_assert: Allow any string-literal as the message, not just a characterRichard Smith2012-03-051-2/+6
| | | | | | | | string literal, and adjust the diagnostic code to match. This also causes us to escape any control characters in the message. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152069 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid double lookup.Benjamin Kramer2012-03-051-3/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152033 91177308-0d34-0410-b5e6-96231b3b80d8
* Add tests for [over.literal]. Fix a few bugs which were exposed by the tests.Richard Smith2012-03-041-5/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151997 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement "optimization" for lambda-to-block conversion which inlines the ↵Eli Friedman2012-03-011-74/+15
| | | | | | | | | | generated block literal for lambdas which are immediately converted to block pointer type. This simplifies the AST, avoids an unnecessary copy of the lambda and makes it much easier to avoid copying the result onto the heap. Note that this transformation has a substantial semantic effect outside of ARC: it gives the converted lambda lifetime semantics similar to a block literal. With ARC, the effect is much less obvious because the lifetime of blocks is already managed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151797 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that we delete default constructors in the right cases. Don't delete theRichard Smith2012-02-271-11/+9
| | | | | | | | default constructor of a union if it has a const member with no user-provided default constructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151516 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that we delete destructors in the right cases. Specifically:Richard Smith2012-02-261-101/+86
| | | | | | | | | | | | | | | - variant members with nontrivial destructors make the containing class's destructor deleted - check for a virtual destructor after checking for overridden methods in the base class(es) - check for an inaccessible operator delete for a class with a virtual destructor. Do not try to call an anonymous union field's destructor from the destructor of the containing class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151483 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure we don't try to produce a definition of an implicitly-deleted functionRichard Smith2012-02-261-5/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151478 91177308-0d34-0410-b5e6-96231b3b80d8
* Special members which are defaulted or deleted on their first declaration areRichard Smith2012-02-261-0/+53
| | | | | | | | | | | | | | trivial if the implicit declaration would be. Don't forget to set the Trivial flag on the special member as well as on the class. It doesn't seem ideal that we have two separate mechanisms for storing this information, but this patch does not attempt to address that. This leaves us in an interesting position where the has_trivial_X trait for a class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'. This seems to be what the standard requires. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151465 91177308-0d34-0410-b5e6-96231b3b80d8
* Work-in-progress for lambda conversion-to-block operator. Still need to ↵Eli Friedman2012-02-251-5/+11
| | | | | | implement the retain+autorelease outside of ARC, and there's a bug that causes the generated code to crash in ARC (which I think is unrelated to my code, although I'm not completely sure). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151428 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++11 [over.match.copy]p1b2, which allows the use ofDouglas Gregor2012-02-241-2/+3
| | | | | | | | | | | | explicit conversion functions to initialize the argument to a copy/move constructor that itself is the subject of direct initialization. Since we don't have that much context in overload resolution, we end up threading more flags :(. Fixes <rdar://problem/10903741> / PR10456. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151409 91177308-0d34-0410-b5e6-96231b3b80d8
* C++11 [class.ctor]p5 says thatDouglas Gregor2012-02-241-2/+6
| | | | | | | | | | | | | | | | | | | A defaulted default constructor for a class X is defined as deleted if [...] - X is a union and all of its variant members are of const-qualified type. A pedantic reading therefore says that union X { }; has a deleted default constructor, which is both silly and almost certainly unintended. Pretend as if this this read - X is a union with one or more variant members, and all of its variant members are of const-qualified type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151394 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace some DenseSets with SmallPtrSets. Apart from the "small" ↵Benjamin Kramer2012-02-231-2/+1
| | | | | | optimization, the current implementation is also a denser. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151257 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-4/+9
| | | | | | direct member initializers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151155 91177308-0d34-0410-b5e6-96231b3b80d8
* Generate an AST for the conversion from a lambda closure type to aDouglas Gregor2012-02-221-10/+79
| | | | | | | | | | | | | | | | | block pointer that returns a block literal which captures (by copy) the lambda closure itself. Some aspects of the block literal are left unspecified, namely the capture variable (which doesn't actually exist) and the body (which will be filled in by IRgen because it can't be written as an AST). Because we're switching to this model, this patch also eliminates tracking the copy-initialization expression for the block capture of the conversion function, since that information is now embedded in the synthesized block literal. -1 side tables FTW. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151131 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-0/+17
| | | | | | | initializers of data members (both static and non-static). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151017 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a constexpr FIXME: When implicitly instantiating the primary template for anRichard Smith2012-02-201-6/+2
| | | | | | | | explicit specialization of a function template, mark the instantiation as constexpr if the specialization is, rather than requiring them to match. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151001 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit a warning when list-initializing a std::initializer_list member.Sebastian Redl2012-02-191-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150933 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a bunch of missing calls to DiagnoseSentinelCalls. ↵Eli Friedman2012-02-181-0/+5
| | | | | | | | | | <rdar://problem/10885993>. This should probably be refactored... but it isn't completely obvious what refactoring is best. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150869 91177308-0d34-0410-b5e6-96231b3b80d8