summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR13479: If we see the definition of an out-of-line destructor in C++11, beRichard Smith2012-07-301-8/+26
| | | | | | | | sure to update the exception specification on the declaration as well as the definition. If we're building in -fno-exceptions mode, nothing else will trigger it to be updated. llvm-svn: 161008
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-228/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* When we have an Objective-C object with non-trivial lifetime in aDouglas Gregor2012-07-231-1/+1
| | | | | | | | structor class under ARC, that struct/class does not have a trivial move constructor or move assignment operator. Fixes the rest of <rdar://problem/11738725>. llvm-svn: 160615
* PR13381, part 2: when determining if a defaulted special member function shouldRichard Smith2012-07-181-9/+18
| | | | | | | | be defined as deleted, take cv-qualifiers on class members into account when looking up the copy or move constructor or assignment operator which will be used for them. llvm-svn: 160418
* PR13381: consider cv-qualifiers on a class member's type when determining whichRichard Smith2012-07-181-12/+19
| | | | | | | constructor will be used for moving that object, in the computation of its exception specification. llvm-svn: 160417
* Ignore visibility attributes after definitions. This matches newer (4.7) gcc'sRafael Espindola2012-07-121-0/+8
| | | | | | behavior and is the first step in fixing pr13338. llvm-svn: 160104
* Stop instantiating a class if we hit a static_assert failure. Also, if theRichard Smith2012-07-111-11/+23
| | | | | | | static_assert fails when parsing the template, don't diagnose it again on every instantiation. llvm-svn: 160088
* Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko2012-07-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostics implemented -- see testcases. I created a new TableGen file for comment diagnostics, DiagnosticCommentKinds.td, because comment diagnostics don't logically fit into AST diagnostics file. But I don't feel strongly about it. This also implements support for self-closing HTML tags in comment lexer and parser (for example, <br />). In order to issue precise diagnostics CommentSema needs to know the declaration the comment is attached to. There is no easy way to find a decl by comment, so we match comments and decls in lockstep: after parsing one declgroup we check if we have any new, not yet attached comments. If we do -- then we do the usual comment-finding process. It is interesting that this automatically handles trailing comments. We pick up not only comments that precede the declaration, but also comments that *follow* the declaration -- thanks to the lookahead in the lexer: after parsing the declgroup we've consumed the semicolon and looked ahead through comments. Added -Wdocumentation-html flag for semantic HTML errors to allow the user to disable only HTML warnings (but not HTML parse errors, which we emit as warnings in -Wdocumentation). llvm-svn: 160078
* When marking virtual functions as used for a class' vtable, mark all functionsRichard Smith2012-07-071-8/+17
| | | | | | | | | | which will appear in the vtable as used, not just those ones which were declared within the class itself. Fixes an issue reported as comment#3 in PR12763 -- we sometimes assert in codegen if we try to emit a reference to a function declaration which we've not marked as referenced. This also matches gcc's observed behavior. llvm-svn: 159895
* Split out the "empty" case for compound statement into a separate ctor.Benjamin Kramer2012-07-041-4/+3
| | | | | | Move the ASTContext-dependent version out of line. llvm-svn: 159717
* Be more eager about setting the 'Invalid' bit on an invalid classDouglas Gregor2012-07-021-0/+2
| | | | | | | | | template instantiation. I wasn't able to reproduce this down to anything small enough to put in our test suite, but it's "obviously" okay to set the invalid bit earlier and precludes a known-broken-but-not-marked-broken class from being used elsewhere. llvm-svn: 159584
* Avoid redundant error when redefining a function as deleted.David Blaikie2012-06-291-2/+2
| | | | | | Reviewed by Doug Gregor. llvm-svn: 159442
* PR12937: Explicitly deleting an explicit template specialization.David Blaikie2012-06-251-2/+7
| | | | | | | | | | | | | | | This works around a quirk in the way that explicit template specializations are handled in Clang. We generate an implicit declaration from the original template which the explicit specialization is considered to redeclare. This trips up the explicit delete logic. This change only works around that strange representation. At some point it'd be nice to remove those extra declarations to make the AST more accurately reflect the C++ semantics. Review by Doug Gregor. llvm-svn: 159167
* Unrevert r158887, reverted in r158949, along with a fix for the bug whichRichard Smith2012-06-251-9/+3
| | | | | | | | | | | | | | | | | | | | resulted in it being reverted. A test for that bug was added in r158950. Original comment: If an object (such as a std::string) with an appropriate c_str() member function is passed to a variadic function in a position where a format string indicates that c_str()'s return type is desired, provide a note suggesting that the user may have intended to call the c_str() member. Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and move it to SemaChecking in order to facilitate this. Factor the call checking out of function call checking and block call checking, and extend it to cover constructor calls too. Patch by Sam Panzer! llvm-svn: 159159
* Revert r158887. This fixes pr13168.Rafael Espindola2012-06-211-3/+9
| | | | | | | | Revert "If an object (such as a std::string) with an appropriate c_str() member function" This reverts commit 7d96f6106bfbd85b1af06f34fdbf2834aad0e47e. llvm-svn: 158949
* If an object (such as a std::string) with an appropriate c_str() member functionRichard Smith2012-06-211-9/+3
| | | | | | | | | | | | | | | is passed to a variadic function in a position where a format string indicates that c_str()'s return type is desired, provide a note suggesting that the user may have intended to call the c_str() member. Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and move it to SemaChecking in order to facilitate this. Factor the call checking out of function call checking and block call checking, and extend it to cover constructor calls too. Patch by Sam Panzer! llvm-svn: 158887
* Restructure how the driver communicates information about theJohn McCall2012-06-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | target Objective-C runtime down to the frontend: break this down into a single target runtime kind and version, and compute all the relevant information from that. This makes it relatively painless to add support for new runtimes to the compiler. Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z, available at the driver level as a better and more general alternative to -fgnu-runtime and -fnext-runtime. This new concept of an Objective-C runtime also encompasses what we were previously separating out as the "Objective-C ABI", so fragile vs. non-fragile runtimes are now really modelled as different kinds of runtime, paving the way for better overall differentiation. As a sort of special case, continue to accept the -cc1 flag -fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak. I won't go so far as to say "no functionality change", even ignoring the new driver flag, but subtle changes in driver semantics are almost certainly not intended. llvm-svn: 158793
* Documentation cleanup:James Dennett2012-06-151-1/+1
| | | | | | | | | * Escaped "::" and "<" as needed in Doxygen comments; * Marked up code examples with \code...\endcode; * Documented a \param that is current, instead of a few that aren't; * Fixed up some \file and \brief comments. llvm-svn: 158562
* Fix T* p to T *pRichard Trieu2012-06-141-2/+2
| | | | llvm-svn: 158478
* Use a proper visitor to recursively check for uninitialized use in constructors.Richard Trieu2012-06-141-67/+88
| | | | llvm-svn: 158477
* Allow __attribute__((unused)) for fields and make it silenceDaniel Jasper2012-06-131-0/+1
| | | | | | -Wunused-private-field. llvm-svn: 158411
* Remove CXXRecordDecl flags which are unused after r158289.Richard Smith2012-06-101-24/+16
| | | | | | | | | | | | | | | | | | | | | We need an efficient mechanism to determine whether a defaulted default constructor is constexpr, in order to determine whether a class is a literal type, so keep the incrementally-built form on CXXRecordDecl. Remove the on-demand computation of same, so that we only have one method for determining whether a default constructor is constexpr. This doesn't affect correctness, since default constructor lookup is much simpler than selecting a constructor for copying or moving. We don't need a corresponding mechanism for defaulted copy or move constructors, since they can't affect whether a type is a literal type. Conversely, checking whether such functions are constexpr can require non-trivial effort, so we defer such checks until the copy or move constructor is required. Thus we now only compute whether a copy or move constructor is constexpr on demand, and only compute whether a default constructor is constexpr in advance. This is unfortunate, but seems like the best solution. llvm-svn: 158290
* Fix PR13052 properly, by performing special member lookup to determine whetherRichard Smith2012-06-101-15/+128
| | | | | | | | | | an explicitly-defaulted default constructor would be constexpr. This is necessary in weird (but well-formed) cases where a class has more than one copy or move constructor. Cleanup of now-unused parts of CXXRecordDecl to follow. llvm-svn: 158289
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-9/+11
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-13/+13
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Introduce -Wunused-private-field. If enabled, this warning detectsDaniel Jasper2012-06-061-2/+54
| | | | | | | unused private fields of classes that are fully defined in the current translation unit. llvm-svn: 158054
* Make delegating initializers use a similar codepath to base initializers in ↵Eli Friedman2012-05-191-0/+10
| | | | | | dependent contexts. PR12890. llvm-svn: 157136
* Apparently empty names are allowed here.Benjamin Kramer2012-05-191-2/+3
| | | | llvm-svn: 157117
* Simplify some users of DeclarationName::getNameKind. Fold ↵Benjamin Kramer2012-05-191-4/+3
| | | | | | getFETokenInfoAsVoid into its only caller. llvm-svn: 157116
* Fold the six functions checking explicitly-defaulted special member functionsRichard Smith2012-05-151-501/+155
| | | | | | | | | | | | into one. These were all performing almost identical checks, with different bugs in each of them. This fixes PR12806 (we weren't setting the exception specification for an explicitly-defaulted, non-user-provided default constructor) and enforces 8.4.2/2's rule that an in-class defaulted member must exactly match the implicit parameter type. llvm-svn: 156802
* Move Sema::VerifyIntegerConstantExpression() andDouglas Gregor2012-05-041-2/+2
| | | | | | | | Sema::ConvertToIntegralOrEnumerationType() from PartialDiagnostics to abstract "diagnoser" classes. Not much of a win here, but we're -several PartialDiagnostics. llvm-svn: 156217
* Move Sema::RequireNonAbstractType() off of PartialDiagnostic.Douglas Gregor2012-05-041-8/+21
| | | | llvm-svn: 156180
* Switch RequireLiteralType() off of PartialDiagnostic.Douglas Gregor2012-05-041-5/+5
| | | | llvm-svn: 156178
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-4/+3
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* 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
OpenPOWER on IntegriCloud