summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-3/+3
| | | | llvm-svn: 103517
* Speculatively revert r103497, "Do not mark the virtual members of anDaniel Dunbar2010-05-111-51/+8
| | | | | | implicitly-instantiated class as ...", which seems to have broken bootstrap. llvm-svn: 103515
* Do not mark the virtual members of an implicitly-instantiated class asDouglas Gregor2010-05-111-8/+51
| | | | | | | | referenced unless we see one of them defined (or the key function defined, if it as one) or if we need the vtable for something. Fixes PR7114. llvm-svn: 103497
* It turns out that we should be allowing redeclarations within functionDouglas Gregor2010-05-061-2/+3
| | | | | | scope. Thanks to Steven Watanabe for correcting me. llvm-svn: 103210
* Partial and full specializations of a class template may have aDouglas Gregor2010-05-061-1/+0
| | | | | | | | | different tag kind ("struct" vs. "class") than the primary template, which has an affect on access control. Should fix the last remaining Boost.Accumulors failure. llvm-svn: 103144
* When implicit definition of the copy-assignment operator fails,Douglas Gregor2010-05-051-6/+12
| | | | | | | | | provide a note that shows where the copy-assignment operator was needed. We used to have this, but I broke it during refactoring. Finishes PR6999. llvm-svn: 103127
* Reimplement code generation for copying fields in theDouglas Gregor2010-05-051-49/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implicitly-generated copy constructor. Previously, Sema would perform some checking and instantiation to determine which copy constructors, etc., would be called, then CodeGen would attempt to figure out which copy constructor to call... but would get it wrong, or poke at an uninstantiated default argument, or fail in other ways. The new scheme is similar to what we now do for the implicit copy-assignment operator, where Sema performs all of the semantic analysis and builds specific ASTs that look similar to the ASTs we'd get from explicitly writing the copy constructor, so that CodeGen need only do a direct translation. However, it's not quite that simple because one cannot explicit write elementwise copy-construction of an array. So, I've extended CXXBaseOrMemberInitializer to contain a list of indexing variables used to copy-construct the elements. For example, if we have: struct A { A(const A&); }; struct B { A array[2][3]; }; then we generate an implicit copy assignment operator for B that looks something like this: B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { } CodeGen will loop over the invented variables i0 and i1 to visit all elements in the array, so that each element in the destination array will be copy-constructed from the corresponding element in the source array. Of course, if we're dealing with arrays of scalars or class types with trivial copy-assignment operators, we just generate a memcpy rather than a loop. Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes all of its regression tests. Conspicuously missing from this patch is handling for the exceptional case, where we need to destruct those objects that we have constructed. I'll address that case separately. llvm-svn: 103079
* When creating a call to a base subobject's operator= in anDouglas Gregor2010-05-041-4/+29
| | | | | | | | | implicitly-defined copy assignment operator, suppress the protected access check. This eliminates the remaining failure in the Boost.SmartPtr library (that was a product of the copy-assignment generation rewrite) and, presumably, the Boost.TR1 library as well. llvm-svn: 103010
* When inheriting a default argument expression, inherit the full expression,John McCall2010-05-041-2/+4
| | | | | | | | | not just the inner expression. This is important if the expression has any temporaries. Fixes PR 7028. Basically a symptom of really tragic method names. llvm-svn: 102998
* Diagnose unused exception parameters under a different warning groupDouglas Gregor2010-05-031-1/+2
| | | | | | | | (-Wunused-exception-parameter) than normal variables, since it's more common to name and then ignore an exception parameter. This warning is neither enabled by default nor by -Wall. Fixes <rdar://problem/7931045>. llvm-svn: 102931
* When creating the declaration reference for implicit copy-constructionDouglas Gregor2010-05-031-1/+1
| | | | | | of a base class, give it real source-location information. Fixes PR7017. llvm-svn: 102916
* When declaring a namespace alias, ignore previous declarations thatDouglas Gregor2010-05-031-3/+7
| | | | | | aren't in scope. Fixes PR7014. llvm-svn: 102915
* Replace a char*/size pair with stringref.Benjamin Kramer2010-05-031-4/+3
| | | | llvm-svn: 102902
* Add an enum to CXXConstructExpr so we can determine if the construction ↵Anders Carlsson2010-05-021-4/+4
| | | | | | expression constructs a non-virtual or virtual base. llvm-svn: 102879
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-82/+404
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* When defining implicit copy constructors, use SetBaseOrMemberInitializers to ↵Anders Carlsson2010-05-011-20/+18
| | | | | | initialize the bases. llvm-svn: 102842
* Added an RAII object that helps set up/tear down the Sema contextDouglas Gregor2010-05-011-19/+31
| | | | | | | | | | | information required to implicitly define a C++ special member function. Use it rather than explicitly setting CurContext on entry and exit, which is fragile. Use this RAII object for the implicitly-defined default constructor, copy constructor, copy assignment operator, and destructor. llvm-svn: 102840
* It turns out that basically every caller to RequireCompleteDeclContextJohn McCall2010-05-011-2/+2
| | | | | | | already knows what context it's looking in. Just pass that context in instead of (questionably) recalculating it. llvm-svn: 102818
* More of Sema to implement initialization ofFariborz Jahanian2010-04-281-0/+41
| | | | | | ivar of c++ object types. llvm-svn: 102500
* Improve the diagnostic you get when making a qualified member accessJohn McCall2010-04-271-1/+1
| | | | | | with a qualifier referencing a different type. llvm-svn: 102409
* Revert enough of my patches to fix self-host again :(Anders Carlsson2010-04-251-14/+18
| | | | llvm-svn: 102289
* Add an explicit UsuallyTinyPtrVector that takes a single element.Anders Carlsson2010-04-241-3/+2
| | | | llvm-svn: 102283
* DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create ↵Anders Carlsson2010-04-241-18/+14
| | | | | | implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now). llvm-svn: 102279
* When building implicit base initializers, add a derived-to-base cast that ↵Anders Carlsson2010-04-241-0/+7
| | | | | | points to the exact base specifier. llvm-svn: 102277
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-15/+38
| | | | llvm-svn: 102259
* Pass the base specifiers through to CheckDerivedToBaseConversion. No ↵Anders Carlsson2010-04-241-10/+19
| | | | | | functionality change yet. llvm-svn: 102250
* Keep track of when DependentNameTypes have no associated keywordDouglas Gregor2010-04-241-1/+2
| | | | | | | (e.g., no typename, enum, class, etc.), e.g., because the context is one that is known to refer to a type. Patch from Enea Zaffanella! llvm-svn: 102243
* Cleanup.Anders Carlsson2010-04-231-2/+1
| | | | llvm-svn: 102179
* Handle copy initialization in BuildImplicitMemberInitializer. Not used yet.Anders Carlsson2010-04-231-6/+35
| | | | llvm-svn: 102178
* Add an ImplicitInitializerKind enum and pass it to ↵Anders Carlsson2010-04-231-11/+62
| | | | | | BuildImplicitBaseInitializer and BuildImplicitMemberInitializer. llvm-svn: 102166
* Fix a think-o that broke self-host.Anders Carlsson2010-04-231-20/+20
| | | | llvm-svn: 102165
* Factor code to initialize an implicit member out into a separate function.Anders Carlsson2010-04-231-39/+62
| | | | llvm-svn: 102162
* Remove calls to isDependentContext, since we handle that case earlier in the ↵Anders Carlsson2010-04-231-23/+15
| | | | | | code. Make BuildImplicitBaseInitializer return a boolean instead. llvm-svn: 102159
* Re-land the patch that merges two diagnostics into one now that it passes ↵Anders Carlsson2010-04-221-1/+1
| | | | | | self-host :) llvm-svn: 102050
* Remove an unused declaration.Anders Carlsson2010-04-211-1/+0
| | | | llvm-svn: 102037
* Keep tack of whether a base in an InitializedEntity is an inherited virtual ↵Anders Carlsson2010-04-211-6/+19
| | | | | | base or not. Use this in CheckConstructorAccess. llvm-svn: 102020
* Factor some common code out into a separate function.Anders Carlsson2010-04-201-37/+40
| | | | llvm-svn: 101952
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-2/+7
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Vtable -> VTable renames across the board.Anders Carlsson2010-04-171-2/+2
| | | | llvm-svn: 101666
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-107/+0
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Silence warning.Benjamin Kramer2010-04-161-1/+1
| | | | llvm-svn: 101495
* Audit uses of Sema::LookupSingleName for those lookups that areDouglas Gregor2010-04-151-1/+2
| | | | | | | | | | | intended for redeclarations, fixing those that need it. Fixes PR6831. This uncovered an issue where the C++ type-specifier-seq parsing logic would try to perform name lookup on an identifier after it already had a type-specifier, which could also lead to spurious ambiguity errors (as in PR6831, but with a different test case). llvm-svn: 101419
* Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor2010-04-151-3/+5
| | | | | | | | in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
* Warn about non-aggregate classes with no user-declared constructorsDouglas Gregor2010-04-151-0/+24
| | | | | | | that have reference or const scalar members, since those members can never be initializer or modified. Fixes <rdar://problem/7804350>. llvm-svn: 101316
* Teach typo correction about various language keywords. We can'tDouglas Gregor2010-04-141-1/+2
| | | | | | | | | | | | | generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. llvm-svn: 101274
* Refactor and simplify the computation of implicit conversion sequencesDouglas Gregor2010-04-131-468/+0
| | | | | | | | | | | | | for reference binding. The code attempted to handle both the computation of the ICS and the actual conversion, but the latter is an anachronism: we now use InitializationSequence for that. Sema::CheckReferenceInit is now a static function TryReferenceInit that's only use within overload resolution, and has been simplified slightly. It still needs to be updated per C++ [over.ics.ref], by eliminating more of the lvalue/rvalue checks. llvm-svn: 101136
* During referencing binding, only consider conversion functions forDouglas Gregor2010-04-131-7/+9
| | | | | | | direct reference binding when the source and target types are not reference-related. Fixes PR6066. llvm-svn: 101132
* Allow classes to befriend implicitly-declared members. Fixes PR6207 forJohn McCall2010-04-131-2/+6
| | | | | | members of non-templated classes. llvm-svn: 101122
* Diagnose declarations of conversion functions with declarators other than '()'.John McCall2010-04-131-13/+25
| | | | llvm-svn: 101098
* When creating the implicitly-declared special member functions, beDouglas Gregor2010-04-121-8/+23
| | | | | | | | sure to introduce them into the current Scope (when we have one) in addition to the DeclContext for the class, so that they can be found by name lookup for inline members of the class. Fixes PR6570. llvm-svn: 101047
OpenPOWER on IntegriCloud