summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert most of r154844, which was disabled in r155975. Keep around theRichard Smith2012-05-021-64/+0
| | | | | | | refactorings in that revision, and some of the subsequent bugfixes, which seem to be relevant even without delayed exception specification parsing. llvm-svn: 156031
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-28/+28
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* [class.copy]p23: Fix an assertion caused by incorrect argument numbering in aRichard Smith2012-04-291-2/+2
| | | | | | | diagnostic, add a test for this paragraph, and tighten up the diagnostic wording a little. llvm-svn: 155784
* PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode.Richard Smith2012-04-271-2/+4
| | | | | | | We do not support IRGen for these, and get some parts of the semantic analysis wrong. llvm-svn: 155728
* PR12625: Cope with classes which have incomplete base or member types:Richard Smith2012-04-251-1/+1
| | | | | | | Don't try to query whether an incomplete type has a trivial copy constructor when determining whether a move constructor should be declared. llvm-svn: 155575
* PR12629: Cope with parenthesized function types when attaching a delayedRichard Smith2012-04-241-4/+8
| | | | | | exception specification to a function. llvm-svn: 155424
* Fix regression in r154844. If necessary, defer computing adjusted destructorRichard Smith2012-04-211-2/+37
| | | | | | | exception specifications in C++11 until after we've parsed the exception specifications for nested classes. llvm-svn: 155293
* SemaDeclCXX.cpp: Fix utf8 in comment.NAKAMURA Takumi2012-04-211-1/+1
| | | | llvm-svn: 155279
* Fix bug where a class's (deleted) copy constructor would be implicitly given aRichard Smith2012-04-201-12/+15
| | | | | | | | 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). llvm-svn: 155218
* 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. llvm-svn: 154886
* 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. llvm-svn: 154844
* 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. llvm-svn: 154799
* 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. llvm-svn: 154346
* 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. llvm-svn: 154343
* 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. llvm-svn: 154248
* Point the caret at the error for the 'expected namespace name' diagnostic inRichard Smith2012-04-051-1/+1
| | | | | | a namespace alias declaration. llvm-svn: 154138
* Remove dead assignment to local variable.Ted Kremenek2012-04-041-1/+0
| | | | llvm-svn: 153985
* PR10217 diagnostic fix: don't say 'copy constructor' when we meanRichard Smith2012-04-021-1/+1
| | | | | | 'copy assignment operator'. llvm-svn: 153897
* 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. llvm-svn: 153894
* 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. llvm-svn: 153883
* Basic semantic analysis support for inheriting constructor declarations inRichard Smith2012-04-021-12/+12
| | | | | | dependent contexts. llvm-svn: 153858
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-301-81/+186
| | | | | | member function is deleted. llvm-svn: 153773
* Refactor special member function deletion. No functionality change.Richard Smith2012-03-291-63/+9
| | | | llvm-svn: 153673
* 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>. llvm-svn: 153577
* 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. llvm-svn: 152938
* 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. llvm-svn: 152621
* 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. llvm-svn: 152608
* 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 llvm-svn: 152536
* 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. llvm-svn: 152509
* 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. llvm-svn: 152491
* Only make a call to a copy constructor elidable if in fact we areDouglas Gregor2012-03-101-1/+20
| | | | | | doing a copy. Fixes PR12139. llvm-svn: 152485
* [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. llvm-svn: 152419
* Literal operators can't have default arguments.Richard Smith2012-03-091-0/+13
| | | | llvm-svn: 152394
* Support for raw and template forms of numeric user-defined literals,Richard Smith2012-03-091-1/+7
| | | | | | and lots of tidying up. llvm-svn: 152392
* 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. llvm-svn: 152287
* 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. llvm-svn: 152069
* Avoid double lookup.Benjamin Kramer2012-03-051-3/+5
| | | | llvm-svn: 152033
* Add tests for [over.literal]. Fix a few bugs which were exposed by the tests.Richard Smith2012-03-041-5/+10
| | | | llvm-svn: 151997
* 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. llvm-svn: 151797
* 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. llvm-svn: 151516
* 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. llvm-svn: 151483
* Make sure we don't try to produce a definition of an implicitly-deleted functionRichard Smith2012-02-261-5/+10
| | | | llvm-svn: 151478
* 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. llvm-svn: 151465
* 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). llvm-svn: 151428
* 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. llvm-svn: 151409
* 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. llvm-svn: 151394
* Replace some DenseSets with SmallPtrSets. Apart from the "small" ↵Benjamin Kramer2012-02-231-2/+1
| | | | | | optimization, the current implementation is also a denser. llvm-svn: 151257
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-4/+9
| | | | | | direct member initializers. llvm-svn: 151155
* 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. llvm-svn: 151131
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-0/+17
| | | | | | initializers of data members (both static and non-static). llvm-svn: 151017
OpenPOWER on IntegriCloud