Commit Graph

649 Commits

Author SHA1 Message Date
Anders Carlsson 53e1ba948d Revert enough of my patches to fix self-host again :(
llvm-svn: 102289
2010-04-25 00:52:09 +00:00
Anders Carlsson 36db0d9c47 Add an explicit UsuallyTinyPtrVector that takes a single element.
llvm-svn: 102283
2010-04-24 22:54:32 +00:00
Anders Carlsson 90235beb55 DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now).
llvm-svn: 102279
2010-04-24 22:25:18 +00:00
Anders Carlsson af13c7bea9 When building implicit base initializers, add a derived-to-base cast that points to the exact base specifier.
llvm-svn: 102277
2010-04-24 22:02:54 +00:00
Anders Carlsson a70cff624e Actually produce base paths for CastExprs of kind CK_DerivedToBase.
llvm-svn: 102259
2010-04-24 19:06:50 +00:00
Anders Carlsson 7afe4245e2 Pass the base specifiers through to CheckDerivedToBaseConversion. No functionality change yet.
llvm-svn: 102250
2010-04-24 17:11:09 +00:00
Douglas Gregor bbdf20acd0 Keep track of when DependentNameTypes have no associated keyword
(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
2010-04-24 15:35:55 +00:00
Anders Carlsson 7a0ffdbe53 Cleanup.
llvm-svn: 102179
2010-04-23 16:24:12 +00:00
Anders Carlsson 423f5d85fd Handle copy initialization in BuildImplicitMemberInitializer. Not used yet.
llvm-svn: 102178
2010-04-23 16:04:08 +00:00
Anders Carlsson 1b00e24d13 Add an ImplicitInitializerKind enum and pass it to BuildImplicitBaseInitializer and BuildImplicitMemberInitializer.
llvm-svn: 102166
2010-04-23 03:10:23 +00:00
Anders Carlsson dca6be04db Fix a think-o that broke self-host.
llvm-svn: 102165
2010-04-23 03:07:47 +00:00
Anders Carlsson 3c1db570b2 Factor code to initialize an implicit member out into a separate function.
llvm-svn: 102162
2010-04-23 02:15:47 +00:00
Anders Carlsson 6bd91c387b Remove calls to isDependentContext, since we handle that case earlier in the code. Make BuildImplicitBaseInitializer return a boolean instead.
llvm-svn: 102159
2010-04-23 02:00:02 +00:00
Anders Carlsson 05bf00938b Re-land the patch that merges two diagnostics into one now that it passes self-host :)
llvm-svn: 102050
2010-04-22 05:40:53 +00:00
Anders Carlsson 3eeb741e6c Remove an unused declaration.
llvm-svn: 102037
2010-04-21 23:55:31 +00:00
Anders Carlsson 43c64af5f0 Keep tack of whether a base in an InitializedEntity is an inherited virtual base or not. Use this in CheckConstructorAccess.
llvm-svn: 102020
2010-04-21 19:52:01 +00:00
Anders Carlsson cedc0a469f Factor some common code out into a separate function.
llvm-svn: 101952
2010-04-20 23:11:20 +00:00
Douglas Gregor c4df407604 Keep track of the actual storage specifier written on a variable or
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
2010-04-19 22:54:31 +00:00
Anders Carlsson 11e5140db9 Vtable -> VTable renames across the board.
llvm-svn: 101666
2010-04-17 20:15:18 +00:00
Douglas Gregor b33eed0ced Collapse the three separate initialization paths in
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
2010-04-16 22:09:46 +00:00
Benjamin Kramer 659d7fc003 Silence warning.
llvm-svn: 101495
2010-04-16 17:43:15 +00:00
Douglas Gregor b8eaf2944b Audit uses of Sema::LookupSingleName for those lookups that are
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
2010-04-15 23:40:53 +00:00
Douglas Gregor b2ccf010fb Feed proper source-location information into Sema::LookupSingleResult,
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
2010-04-15 22:33:43 +00:00
Douglas Gregor 454a5b65d4 Warn about non-aggregate classes with no user-declared constructors
that have reference or const scalar members, since those members can
never be initializer or modified. Fixes <rdar://problem/7804350>.

llvm-svn: 101316
2010-04-15 00:00:53 +00:00
Douglas Gregor 280e1ee0ae Teach typo correction about various language keywords. We can't
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
2010-04-14 20:04:41 +00:00
Douglas Gregor 38ae6ab6bc Refactor and simplify the computation of implicit conversion sequences
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
2010-04-13 16:31:36 +00:00
Douglas Gregor 538be4622c During referencing binding, only consider conversion functions for
direct reference binding when the source and target types are not
reference-related. Fixes PR6066.

llvm-svn: 101132
2010-04-13 15:07:45 +00:00
John McCall 43314ab3ae Allow classes to befriend implicitly-declared members. Fixes PR6207 for
members of non-templated classes.

llvm-svn: 101122
2010-04-13 07:45:41 +00:00
John McCall 212fa2efb7 Diagnose declarations of conversion functions with declarators other than '()'.
llvm-svn: 101098
2010-04-13 00:04:31 +00:00
Douglas Gregor b93b606759 When creating the implicitly-declared special member functions, be
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
2010-04-12 17:09:20 +00:00
Anders Carlsson 1c0f8bb4ce Have the CXXBaseOrMemberInitializer keep track of whether an initializer initializes a virtual base or not.
llvm-svn: 101004
2010-04-12 00:51:03 +00:00
John McCall 23eebd9c1e Diagnose more cases of initializing distinct members of an anonymous union
member.  Use a better diagnostic for this case.  Also fix a bug with nested
anonymous structs/unions for -Wreorder;  this last was PR6575.

llvm-svn: 100923
2010-04-10 09:28:51 +00:00
John McCall bb7b658ab5 Diagnose misordered initializers in constructor templates immediately instead of
when they're instantiated.  Merge the note into the -Wreorder warning;  it
doesn't really contribute much, and it was splitting a thought across diagnostics
anyway.  Don't crash in the parser when a constructor's initializers end in a
comma and there's no body;  the recovery here is still terrible, but anything's
better than a crash.

llvm-svn: 100922
2010-04-10 07:37:23 +00:00
John McCall da6841bade Suppress access control diagnostics when looking up a base or member name
fails to find a type.  There are no cases where it's valid for this to produce
an error.

llvm-svn: 100878
2010-04-09 19:01:14 +00:00
Jeffrey Yasskin c76498d409 Make CXXScopeSpec invalid when incomplete, and propagate that into any
Declarator that depends on it.  This fixes several redundant errors and bad
recoveries.

llvm-svn: 100779
2010-04-08 16:38:48 +00:00
John McCall b9c7848ba7 Implement dependent friend function template specializations.
llvm-svn: 100753
2010-04-08 09:05:18 +00:00
Alexis Hunt 7dd2617e9c Implement checking for template literal operator functions. This
code won't actually get used yet because we don't handle non-type
parameter packs, but when we do, this code should jump in and work.

llvm-svn: 100716
2010-04-07 23:11:06 +00:00
Alexis Hunt 079a6f7fe5 Updated comment to reflect changes made in the most recent draft.
llvm-svn: 100707
2010-04-07 22:57:35 +00:00
Douglas Gregor 3b4abb6792 Improve handling of friend types in several ways:
- When instantiating a friend type template, perform semantic
  analysis on the resulting type.
  - Downgrade the errors concerning friend type declarations that do
  not refer to classes to ExtWarns in C++98/03. C++0x allows
  practically any type to be befriended, and ignores the friend
  declaration if the type is not a class.

llvm-svn: 100635
2010-04-07 17:57:12 +00:00
Douglas Gregor afb9bc10fa Split Sema::ActOnFriendTypeDecl into Sema::CheckFriendTypeDecl (for
semantic analysis) and Sema::ActOnFriendTypeDecl (the action
callback). This is a prerequisite for improving template instantiation
of friend type declarations.

llvm-svn: 100633
2010-04-07 16:53:43 +00:00
Douglas Gregor 45cf7e3d2a Rework our handling of copy construction of temporaries, which was a
poor (and wrong) approximation of the actual rules governing when to
build a copy and when it can be elided.

The correct implementation is actually simpler than the
approximation. When we only enumerate constructors as part of
initialization (e.g., for direct initialization or when we're copying
from a class type or one of its derived classes), we don't create a
copy. When we enumerate all conversion functions, we do create a
copy. Before, we created some extra copies and missed some
others. The new test copy-initialization.cpp shows a case where we
missed creating a (required, non-elidable) copy as part of a
user-defined conversion, which resulted in a miscompile. This commit
also fixes PR6757, where the missing copy made us reject well-formed
code in the ternary operator.

This commit also cleans up our handling of copy elision in the case
where we create an extra copy of a temporary object, which became
necessary now that we produce the right copies. The code that seeks to
find the temporary object being copied has moved into
Expr::getTemporaryObject(); it used to have two different
not-quite-the-same implementations, one in Sema and one in CodeGen.

Note that we still do not attempt to perform the named return value
optimization, so we miss copy elisions for return values and throw
expressions.

llvm-svn: 100196
2010-04-02 18:24:57 +00:00
Anders Carlsson db0a965eca If a constructor is a dependent context, just set the base and member initializers as they are written. Fixes a bug where we wouldn't show initialization order warnings when instantiating.
llvm-svn: 100180
2010-04-02 06:26:44 +00:00
Anders Carlsson 7b3f2788a1 Diagnose multiple base and member initializers in class templates.
llvm-svn: 100179
2010-04-02 05:42:15 +00:00
Anders Carlsson 4c8cb01b5a More cleanup.
llvm-svn: 100175
2010-04-02 03:43:34 +00:00
Anders Carlsson 96b8fc664a Constify.
llvm-svn: 100174
2010-04-02 03:38:04 +00:00
Anders Carlsson e857b29e0c Minor cleanup.
llvm-svn: 100173
2010-04-02 03:37:03 +00:00
Douglas Gregor e677dafce1 Change the representation of dependent elaborated-type-specifiers
(such as "class T::foo") from an ElaboratedType of a TypenameType to a
DependentNameType, which more accurately models the underlying
concept.

Improve template instantiation for DependentNameType nodes that
represent nested-name-specifiers, by performing tag name lookup and
checking the resulting tag appropriately. Fixes PR5681.

There is still much testing and cleanup to do in this area.

llvm-svn: 100054
2010-03-31 22:19:08 +00:00
Douglas Gregor a771f46c82 Reinstate my CodeModificationHint -> FixItHint renaming patch, without
the C-only "optimization".

llvm-svn: 100022
2010-03-31 17:46:05 +00:00
Douglas Gregor 30e631862f Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
llvm-svn: 100018
2010-03-31 17:25:35 +00:00
Douglas Gregor 3baad0d4f7 Rename CodeModificationHint to FixItHint, since we've been using the
term "fix-it" everywhere and even *I* get tired of long names
sometimes. No functionality change.

llvm-svn: 100008
2010-03-31 15:31:50 +00:00