Commit Graph

23 Commits

Author SHA1 Message Date
Douglas Gregor db56b919e5 Provide a real fix for PR6199, reverting the old workaround. Here, we
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.

llvm-svn: 95192
2010-02-03 03:01:57 +00:00
Anders Carlsson 75b1f959da Check in a test case and a nasty workaround for PR6199.
llvm-svn: 95076
2010-02-02 07:10:35 +00:00
Eli Friedman a682427e42 Switch expressions like T() and T(1,2) over to new-style initialization. I'm
not quite sure what we want to do about the AST representation; comments
welcome.

llvm-svn: 94967
2010-01-31 20:58:15 +00:00
Douglas Gregor 7ae2d7758f Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:

  - CXXBaseOrMemberInitializer now contains only a single initializer
    rather than a set of initialiation arguments + a constructor. The
    single initializer covers all aspects of initialization, including
    constructor calls as necessary but also cleanup of temporaries
    created by the initializer (which we never handled
    before!).

  - Rework + simplify code generation for CXXBaseOrMemberInitializers,
    since we can now just emit the initializer as an initializer.

  - Switched base and member initialization over to the new
    initialization code (InitializationSequence), so that it

  - Improved diagnostics for the new initialization code when
    initializing bases and members, to match the diagnostics produced
    by the previous (special-purpose) code.

  - Simplify the representation of type-checked constructor initializers in
    templates; instead of keeping the fully-type-checked AST, which is
    rather hard to undo at template instantiation time, throw away the
    type-checked AST and store the raw expressions in the AST. This
    simplifies instantiation, but loses a little but of information in
    the AST.

  - When type-checking implicit base or member initializers within a
    dependent context, don't add the generated initializers into the
    AST, because they'll look like they were explicit.

  - Record in CXXConstructExpr when the constructor call is to
  initialize a base class, so that CodeGen does not have to infer it
  from context. This ensures that we call the right kind of
  constructor.

There are also a few "opportunity" fixes here that were needed to not
regress, for example:

  - Diagnose default-initialization of a const-qualified class that
    does not have a user-declared default constructor. We had this
    diagnostic specifically for bases and members, but missed it for
    variables. That's fixed now.

  - When defining the implicit constructors, destructor, and
    copy-assignment operator, set the CurContext to that constructor
    when we're defining the body.

llvm-svn: 94952
2010-01-31 09:12:51 +00:00
Ken Dyck 7df3cbeb01 Convert one last size variable to CharUnits (follow-on to 94577).
llvm-svn: 94579
2010-01-26 19:59:28 +00:00
Ken Dyck 3eb55cfe8a Use CharUnits for sizes, offsets, alignments, and padding amounts for values
that are in character units.

llvm-svn: 94577
2010-01-26 19:44:24 +00:00
Anders Carlsson e36a6b3e44 Correctly pass VTT parameters to constructors and destructors. The VTTs aren't yet used in the ctors/dtors, but that will follow.
llvm-svn: 92409
2010-01-02 01:01:18 +00:00
Anders Carlsson 27da15ba8e Move a few more functions away from CGCXX and to CGClass and CGExprCXX.
llvm-svn: 92399
2010-01-01 20:29:01 +00:00
Benjamin Kramer d20ef75b91 Remove some dead variables clang-analyzer found.
llvm-svn: 92162
2009-12-25 15:43:36 +00:00
Anders Carlsson bfb3671b25 Pass the return value slot to all call exprs.
llvm-svn: 92145
2009-12-24 21:13:40 +00:00
Anders Carlsson 61a401caec Pass ReturnValueSlot to EmitCall. No functionality change yet.
llvm-svn: 92138
2009-12-24 19:25:24 +00:00
Douglas Gregor 247894b361 There is no such thing as typeinfo for a cv-qualified type. Assert
that this is true when mangling, then fix up the various places in
Sema and/or CodeGen that need to remove qualifiers. Addresses a
linking issue when building LLVM with Clang.

llvm-svn: 92064
2009-12-23 22:04:40 +00:00
Anders Carlsson 0087bc851c Fix regression I introduced when dynamic_cast-ing to a reference type.
llvm-svn: 91687
2009-12-18 14:55:04 +00:00
Anders Carlsson 3f4336cb1f Rename GetAddrOfRTTI to GetAddrOfRTTIDescriptor. Remove the overload that takes a CXXRecordDecl since we were just creating a QualType from it anyway.
llvm-svn: 91590
2009-12-17 07:09:17 +00:00
Anders Carlsson 07863b8b6e Use GetAddrOfRTTI everywhere and remove GenerateRTTI and GenerateRTTIRef. With this change, we can now compile and link TableGen.
llvm-svn: 91520
2009-12-16 07:05:41 +00:00
Anders Carlsson 399f499f0c Don't use a cookie if the global placement new function is used.
llvm-svn: 91251
2009-12-13 20:34:34 +00:00
Anders Carlsson adbe4249d6 Fix regression in my last commit - if a struct has a trivial destructor but no usual deallocation function we don't need a cookie.
llvm-svn: 91249
2009-12-13 20:10:12 +00:00
Anders Carlsson 21122cf657 More array cookie improvements.
llvm-svn: 91247
2009-12-13 20:04:38 +00:00
Anders Carlsson f5af8dead7 If the usual array deallocation function of a class takes two arguments, we need to pass the number of bytes allocated to the deallocation function, just not the number of bytes in a single element.
llvm-svn: 91246
2009-12-13 18:48:07 +00:00
Anders Carlsson fd7dfeb779 Improve linkage of RTTI data structures. Introduce CodeGenModule::GetAddrOfRTTI which figures out the right linkage of the RTTI information for the given type and whether it should be defined or not. I will migrate clients over to GetAddrOfRTTI in subsequent commits (with tests).
llvm-svn: 91098
2009-12-11 02:46:30 +00:00
Mike Stump c01c2b87e8 Change rtti/Rtti to RTTI, as it is an acronym.
llvm-svn: 90334
2009-12-02 18:57:08 +00:00
Anders Carlsson 3a202f601e Handle cases where we're constructing an array of objects and the constructor has default arguments.
llvm-svn: 89783
2009-11-24 18:43:52 +00:00
Anders Carlsson 59486a2ddb Get rid of the ugly CGCXX names and replace them with CGClass, CGExprCXX and CGTemporaries.
llvm-svn: 89742
2009-11-24 05:51:11 +00:00