Commit Graph

406 Commits

Author SHA1 Message Date
Fariborz Jahanian 31e7f225fa In ms_struct structs, Establish a new alignment for a
non-bitfield following a bitfield if size of their types differ.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131032 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:42:22 +00:00
Fariborz Jahanian 52bbe7a113 Establish a new alignment for an ms_struct bitfield following
a non-bitfield if size of their types differ.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 21:56:12 +00:00
Fariborz Jahanian 9b3acaa325 More ms_struct bitfield stuff:
Adjacent bit fields are packed into the same 1-, 2-, or
4-byte allocation unit if the integral types are the same
size. // rdar://8823265.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 18:51:37 +00:00
Fariborz Jahanian cc0f9f1a3b Only the first zero-length bitfield decides alignment of
the followup data member in an ms_struct struct.
// rdar:// 8823265



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-03 22:07:14 +00:00
Fariborz Jahanian 855a8e79f4 Finish off rules for z-length bitfields in ms_struct
structs. // rdar://8823265


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130783 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-03 20:21:04 +00:00
Fariborz Jahanian 340fa24213 More rule enforcement of zero bitfields for ms_struct.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130696 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 17:20:56 +00:00
Fariborz Jahanian 14d56ef43f Some refactoring of my ms_struct patch.
// rdar://8823265 related.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130311 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 17:14:21 +00:00
Fariborz Jahanian 62055b0618 With ms_struct attribut, Zero-length bitfields following
non-bitfield members are ignore. // rdar://8823265 wip


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-26 23:52:16 +00:00
Ted Kremenek 43d8bcfc36 Simplify crash recovery cleanup registration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128057 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 01:15:19 +00:00
Ted Kremenek 4d96d9f0e7 Recover memory from RecordLayoutBuilders during crashes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-19 01:00:36 +00:00
Ken Dyck d5e3ed0850 Instead of round up sizes to '8', round them up to the alignment of the char
type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127391 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10 02:00:35 +00:00
Ken Dyck 90ce2dba29 Round up the non-virtual size to the next char instead of rounding down.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127390 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10 01:53:59 +00:00
Ken Dyck 3b3e1a1e8b Use CharUnits for TypeAlign variable in LayoutWideBitField(). No change in
functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126730 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 01:36:00 +00:00
Ken Dyck 5dc989c4f6 Change the return type of GetVirtualPointersSize() to CharUnits. No change
in functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 01:22:45 +00:00
Ken Dyck f079b735d8 Retry r126357. Use CharUnits for the Size and DataSize calculations when
they are known to be exact multiples of the width of the char type. Add a
test case to CodeGen/union.c that would have caught the problem with the
previous attempt. No change in functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126628 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-28 02:01:38 +00:00
Daniel Dunbar 6b46cd9c85 Revert "Use CharUnits values for Size and DataSize outside of the bitfield
layout", it broke some GCC tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126386 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 16:40:53 +00:00
Ken Dyck 8102fae66d Use CharUnits values for Size and DataSize outside of the bitfield layout
methods, when they are known to be exact multiples of the width of the char
type. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 02:12:14 +00:00
Ken Dyck 9911344114 Use Context.getCharWidth() in place of literal '8's in assertions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126356 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 01:33:05 +00:00
Ken Dyck a0c21c4ec0 Make the Size and DataSize members more CharUnits-friendly by wrapping them
with getter and setter methods in both bit units and CharUnits. This will help
simplify some of the unit mismatch in the parts of the code where sizes are
known to be exact multiples of the width of the char type.

Assertions in the getters help guard against accidentally converting to
CharUnits when sizes are not exact multiples of the char width.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126354 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 01:13:28 +00:00
Ken Dyck 9ed9a25018 Expand use of CharUnits in LayoutField(). No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126066 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-20 02:06:09 +00:00
Ken Dyck 3263e09c8e Expand use of CharUnits for alignments further. No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126034 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-19 18:58:07 +00:00
Ken Dyck 834945c19c Convert MaxFieldAlignment to CharUnits from bits. No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125704 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 01:49:42 +00:00
Ken Dyck 6feb4bb3de Convert the UnpackedAlignment field to CharUnits from bits. No change in
functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125643 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 02:11:31 +00:00
Ken Dyck ea7f6c2c53 Convert Alignment member to CharUnits from bits. No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125641 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 02:05:21 +00:00
Ken Dyck a1fdb0bc09 Convert NonVirtualSize to CharUnits from bits. No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125639 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 01:52:01 +00:00
Ken Dyck df205382da Convert NonVirtualAlignment to CharUnits. No change in functionality
intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125638 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 01:43:15 +00:00
Ken Dyck dac54c124e Convert RecordLayout::Alignment to CharUnits from bit units. No change in
functionality intended. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125549 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 02:32:40 +00:00
Ken Dyck ec29903513 Convert RecordLayout::DataSize to CharUnits from bits, eliminating two
unnecessary calls to RoundUpToAlignment. No changes to functionality
intended.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125356 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 02:20:09 +00:00
Ken Dyck dd76a9ab9e Add a helper function, ASTContext::toBits(), that converts sizes in
CharUnits to sizes in bits, and use it to tidy up the places where the
conversion was done explicitly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125332 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 01:54:29 +00:00
Ken Dyck 5f022d8269 Convert RecordLayout::Size to CharUnits from bits. No changes to
functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125156 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-09 01:59:34 +00:00
Ken Dyck 68cf1a5a01 Convert RecordLayout::NonVirtualAlign to CharUnits. No change in
functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125069 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 02:02:47 +00:00
Fariborz Jahanian adf082e829 For gcc compatibility, size of a class which is zero
but has non-empty data fields, such as array of zero length,
remains zero.
// rdar://8945175


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 19:36:18 +00:00
Douglas Gregor 6f75550e40 Basic support for -mms-bitfields, from Carl Norum!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124661 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 15:15:22 +00:00
Ken Dyck 5c3633fa57 Convert RecordLayout::NonVirtualSize from bit units to CharUnits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124646 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 01:52:10 +00:00
Ken Dyck ff3a5174d1 Remove private toCharUnits() helper method, replacing with calls to
ASTContext::toCharUnitsFromBits().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124092 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 01:28:50 +00:00
Ken Dyck fb1e3bc29b Replace calls to CharUnits::fromQuantity() with ones
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123715 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 01:56:16 +00:00
Jay Foad 4ba2a17694 PR3558: mark "logically const" accessor methods in ASTContext as const,
and mark the fields they use as mutable. This allows us to remove a few
const_casts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 09:06:06 +00:00
Rafael Espindola 272324bc88 Fix PR8796.
The problem was that we were asserting the we never added an empty class
to the same offset twice. This is not true for unions, where two members, empty
or not, can have the some offset.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122633 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-29 23:02:58 +00:00
Argyrios Kyrtzidis 5a82119820 Fix another unnecessary-struct-padding issue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121352 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 02:47:58 +00:00
Argyrios Kyrtzidis 43ddd9f202 Before determining the effect the alignment of base struct will have in the aligment of the sub-struct,
take into account if the sub-struct is packed and its maximum field alignment.

Fixes rdar://8745206

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121335 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 00:35:20 +00:00
Anders Carlsson dae0cb52e4 Move isNearlyEmpty out into the ASTContext so it can be called from CodeGen as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120137 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-25 01:51:53 +00:00
Anders Carlsson c9e814ba19 Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-24 23:12:57 +00:00
Anders Carlsson 245656ec65 Use the newly added function in ASTRecordLayoutBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120131 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-24 22:55:48 +00:00
Argyrios Kyrtzidis 33e4e70c8c Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
   SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-18 20:06:41 +00:00
Anders Carlsson fa84fbad48 Don't update empty field subobjects for bitfields. Fixes PR8519.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-01 15:14:51 +00:00
Anders Carlsson 6a35674423 Get rid of more calls to getBaseClassOffsetInBits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117883 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-01 00:21:58 +00:00
Anders Carlsson 3069a0d286 Port over a couple of getVBaseClassOffsetInBits call sites to use getVBaseClassOffset instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117882 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 23:45:59 +00:00
Anders Carlsson a14f597957 Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 23:22:37 +00:00
Anders Carlsson a231151352 Start converting over the RecordLayoutBuilder next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117878 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 22:20:42 +00:00
Anders Carlsson a3d4380d66 EmptyObjectMap now uses CharUnits wherever possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117877 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 22:13:23 +00:00
Anders Carlsson 8c6acc6be0 More CharUnits conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117875 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 21:54:55 +00:00
Anders Carlsson fe5ef73149 More CharUnits conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117874 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 21:39:24 +00:00
Anders Carlsson d8da76365f Use CharUnits in the EmptyClassOffsets map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117873 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 21:22:43 +00:00
Anders Carlsson 376bda924a Baby steps towards using only CharUnits for base class offsets in ASTRecordLayout. Start by storing the offsets in CharUnits in the ASTRecordLayout object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-31 21:01:46 +00:00
Benjamin Kramer cb9c07418b Move classes into anonymous namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 16:33:16 +00:00
Argyrios Kyrtzidis 36d2fd44bf Store in PCH the key function of C++ class to avoid deserializing the complete declaration context in order to compute it.
Progress for rdar://7260160.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116508 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-14 20:14:38 +00:00
Argyrios Kyrtzidis 3bd5b6c3c2 Embrace C++ ABI 5.2.6 and consider that template instantiations don't have key functions (same as GCC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116391 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-13 02:39:41 +00:00
Argyrios Kyrtzidis 78a916ec5f Implement -Wpadded and -Wpacked.
-Wpadded warns when undesired padding is introduced in a struct. (rdar://7469556)
-Wpacked warns if a struct is given the packed attribute, but the packed attribute has no effect
  on the layout or the size of the struct. Such structs may be mis-aligned for little benefit.

The warnings are emitted at the point where layout is calculated, that is at RecordLayoutBuilder.
To avoid calculating the layouts of all structs regardless of whether they are needed or not,
I let the layouts be lazily constructed when needed. This has the disadvantage that the above warnings
will be emitted only when they are used for IR gen, and not e.g with -fsyntax-only:

$ cat t.c
struct S {
  char c;
  int i;
};
void f(struct S* s) {}

$ clang -fsyntax-only -Wpadded t.c
$ clang -c -Wpadded t.c -o t.o
t.c:3:7: warning: padding struct 'struct S' with 3 bytes to align 'i' [-Wpadded]
  int i;
      ^
1 warning generated.

This is a good tradeoff between providing the warnings and not calculating layouts for all
structs in case the user has enabled a couple of rarely used warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114544 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-22 14:32:24 +00:00
Argyrios Kyrtzidis cfe17e5c82 Use a smart pointer instead of delete.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112005 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 00:32:14 +00:00
Chandler Carruth 6d09a194bb Add a virtual destructor to the base of another class hierarchy with virtual
methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 08:37:21 +00:00
Charles Davis 20cf717034 Add some enum goodness as requested by Chris. Now instead of storing the
active C++ ABI as a raw string, we store it as an enum. This should improve
performance somewhat.

And yes, this time, I started from a clean build directory, and
all the tests passed. :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111507 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 02:18:14 +00:00
John McCall b61b7d24f3 Restore the build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 01:21:57 +00:00
Charles Davis c9f8aece7e Add a special RecordLayoutBuilder for the Microsoft C++ ABI.
All it does right now is add space for two vtable pointers instead of one
when a class has both virtual methods and virtual bases. This is a requirement
of the Microsoft ABI, since it has separate vtables for methods and bases. Other
stuff will come up over time, but we'll cross those bridges when we get to
them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111493 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 00:55:19 +00:00
Sean Hunt cf807c4dfd Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111455 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:23:40 +00:00
Daniel Dunbar 4087f27e54 StringRef'ication of lots stuff, patch by Peter Davies!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111314 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 22:39:59 +00:00
Argyrios Kyrtzidis c83d2d7d89 Remove ATTRIBUTE_UNUSED from the common pattern of disallowing copying.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111101 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-15 10:17:39 +00:00
Argyrios Kyrtzidis ed635e4bff Add ATTRIBUTE_UNUSED to methods not supposed to be used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111087 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-15 01:15:27 +00:00
Daniel Dunbar 84b0316f72 Sema: Fix a subtle i64 -> i32 truncation which broke layout of large structures
with bit-fields.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107185 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 18:34:35 +00:00
Jeffrey Yasskin fe8ec01bba Delete assert in ComputeKeyFunction. The function runs fine without it, since
there's an explicit guard on isPolymorphic, and virtual bases don't affect the
key function calculation.  This allows people to call
ASTContext::getKeyFunction on arbitrary classes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 15:27:35 +00:00
Anders Carlsson e3362bc104 Do the same short-circuit optimization when laying out bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-13 18:00:18 +00:00
Anders Carlsson 5ccfdd8d21 Implement part of the EmptySubobjectMap optimization described in PR6998. We still need to do this for bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105919 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-13 17:49:16 +00:00
Anders Carlsson 45f5b54d67 Correctly handle fields with virtual bases containing empty subobjects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08 19:09:24 +00:00
Anders Carlsson 2177ab7be5 When checking whether we can place a base subobject at an offset, we don't need to go past the highest offset that's known to contain an empty base subobject.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105611 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08 16:20:35 +00:00
Anders Carlsson c8cb462e57 Minor cleanups to the empty subobject map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105608 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08 15:56:03 +00:00
Anders Carlsson c15503d77b And now for the best part: Removing the old code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105162 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30 06:56:46 +00:00
Anders Carlsson 83a45e7dab Turn on the new empty base subobject tracking code. It's a bit faster than the previous code. However, it still has quadratic performance, something which I intend to fix shortly in a subsequent patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30 06:52:33 +00:00
Anders Carlsson 4137d51770 Cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105114 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 21:10:24 +00:00
Anders Carlsson 5b1319c780 Make EmptySubobjectMap::CanPlaceBaseAtOffset take a BaseSubobjectInfo as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105113 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 20:49:49 +00:00
Anders Carlsson b1d880b15f Change RecordLayoutBuilder::LayoutBase to take a BaseSubobjectInfo. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105112 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 20:47:33 +00:00
Anders Carlsson 3cd09ccbb1 Rework the way virtual primary bases are added when laying out classes. Instead of doing it as a separate step, we now use the BaseSubobjectInfo and use it when laying out the bases. This fixes a bug where we would either not add a primary virtual base at all, or add it at the wrong offset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105110 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 19:44:50 +00:00
Anders Carlsson 276b491b44 Change LayoutVirtualBase to also take a BaseSubobjectInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 17:48:36 +00:00
Anders Carlsson 07cebc5712 Change RecordLayoutBuilder::LayoutNonVirtualBase to take a BaseSubobjectInfo. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105103 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 17:42:25 +00:00
Anders Carlsson 6e26454ecc Move computing the base subobject info for a class into the RecordLayoutBuilder because we're going to need it to be able to correctly add offsets for primary virtual bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-29 17:35:14 +00:00
Anders Carlsson ea2f41c584 Rename BaseInfo to BaseSubobjectInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 21:24:37 +00:00
Anders Carlsson 4a25799760 Move BaseInfo outside of the EmptySubobject class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 21:13:31 +00:00
Anders Carlsson 812a3456b6 More work on the empty subobject map. This code is not yet used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104861 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 18:20:57 +00:00
Daniel Dunbar c6082fe347 Sema: Add initial support for '#pragma options align=mac68k'.
- Docs are fairly sketchy, if someone wants to pore through gcc to look for
   holes I'd appreciate any failing test cases!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104809 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 05:45:51 +00:00
Anders Carlsson 58b16b6e46 More work on the new empty subobject map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104808 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 05:41:06 +00:00
Daniel Dunbar 0aa7edbc1f Strip trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 02:25:46 +00:00
Daniel Dunbar 8a2c92cab2 AST: Rename PragmaPackAttr to MaxFieldAlignmentAttr, which is more accurate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 01:12:46 +00:00
Anders Carlsson 261febd091 More work on the empty subobjects map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104787 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 00:07:01 +00:00
Anders Carlsson 0c54fc9132 Move ComputeEmptySubobjectSizes to EmptySubobjectMap.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104702 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:54:25 +00:00
Anders Carlsson 6a91c0328c Stub out the EmptySubobjectsMap class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104701 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:32:58 +00:00
Anders Carlsson 0efac254e3 Inline the RecordLayoutBuilder constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104700 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:20:08 +00:00
Anders Carlsson c6cab68ae1 Add a Layout overload that takes a CXXRecordDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104695 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:10:00 +00:00
Benjamin Kramer 7e22028641 Move RecordLayoutBuilder into an anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 09:58:31 +00:00
Anders Carlsson 7d0918acd1 Rename ASTRecordLayoutBuilder to RecordLayoutBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104688 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:58:59 +00:00
Anders Carlsson 9392fa63e4 Move the ASTRecordLayoutBuilder class declaration into the .cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:41:04 +00:00
Anders Carlsson aa230b7bd2 Fix thinko and remove another unused function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:31:23 +00:00
Anders Carlsson 4831710518 Fix build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104682 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:25:15 +00:00
Anders Carlsson 28fdd0a8b4 No need to use the PrimaryBaseInfo struct in the builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104681 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:20:58 +00:00
Anders Carlsson 400b06dde5 Remove FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104674 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:11:02 +00:00
Anders Carlsson 2f64e377d1 Fold the other Layout overload into its sole call site.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104673 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:10:47 +00:00
Anders Carlsson 36cdc61b98 Fold the ASTRecordLayoutBuilder::ComputeLayout overload that takes an ObjCInterfaceDecl pointer into its only callsite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104672 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 05:04:25 +00:00
Anders Carlsson 1e641ce1c1 Move the relevant ASTContext member functions that deal with ASTRecordLayoutBuilder into RecordLayoutBuilder.cpp. This matches the way we interact with other builder classes (CGRecordLayoutBuilder, VTableBuilder and VTTBuilder) and it also allows for making ASTRecordLayoutBuilder a private class without a header file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104671 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 04:56:53 +00:00
Anders Carlsson bfcdc40cbc When recording empty subobjects we should always look at the primary virtual base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104464 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-23 18:14:24 +00:00
Anders Carlsson ecafebe28f Add an UpdateVBases parameter to UpdateEmptyClassOffsets. Not used just yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-10 15:28:59 +00:00
Anders Carlsson 3159ffeb23 More work on handling empty classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103402 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-10 15:26:14 +00:00
Anders Carlsson ddae877b5d Cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103370 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-09 05:03:38 +00:00
Anders Carlsson 836fc14e6c Actually compute the empty subobject sizes. No functionality change yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103363 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 23:06:26 +00:00
Anders Carlsson c3fddeb438 Add a SizeOfLargestEmptySubobject member to ASTRecordLayout. For C++ classes this will hold the largest empty subobject or 0 if the class doesn't have any empty subobjects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103359 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 22:35:05 +00:00
Daniel Dunbar 8d8ab749f6 AST: Dump ASTRecordLayout objects when they are created with -fdump-record-layouts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101815 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 20:44:53 +00:00
Dan Gohman cb421fa690 Fix -Wcast-qual warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 16:39:44 +00:00
Anders Carlsson de9f153b23 If a wide bit-field is inside a union its offset should always be 0.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101668 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17 20:21:41 +00:00
Benjamin Kramer 900fc6388e Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.
The next step is to print the name directly into the stream, avoiding a temporary std::string copy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17 09:33:03 +00:00
Anders Carlsson 4b16e97ff7 Remove printfs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101470 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 15:59:41 +00:00
Anders Carlsson 4cf6f5fdc5 More work on wide bit-fields, WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101467 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 15:57:11 +00:00
Anders Carlsson 0f0e9b0ace Rename the ASTContext member 'Context'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101462 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 15:07:51 +00:00
Anders Carlsson 97913576db Split adding the primary virtual base offsets out into a separate pass. This fixes a bug where we would lay out virtual bases in the wrong order.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101373 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 16:12:58 +00:00
Daniel Dunbar b6830d616a Tweak spelling (Bitfield -> BitField)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101369 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 15:06:18 +00:00
Daniel Dunbar b6a169395c Add TargetInfo::useBitfieldTypeAlignment().
- Used to determine whether the alignment of the type in a bit-field is
   respected when laying out structures. The default is true, targets can
   override this as needed.

 - This is designed to correspond to the PCC_BITFIELD_TYPE_MATTERS macro in
   gcc. The AST/Sema implementation only affects one line, unless I have
   forgotten something. I'd appreciate further review.

 - IRgen still needs to be updated to fully support this (which is effectively
   PR5591).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101356 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 06:18:39 +00:00
Daniel Dunbar 4895a8ca41 Remove unnecessary cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 20:52:05 +00:00
Anders Carlsson 573021fc10 Fix another vbase layout bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100952 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 21:35:33 +00:00
Anders Carlsson a1e87162d3 Add a simple debug-only verification pass to the record layout builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100951 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 21:24:48 +00:00
Anders Carlsson bdda6c1788 Simplify the virtual base layout code and fix a bug where we wouldn't store the offset for a virtual base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100940 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 18:42:27 +00:00
Daniel Dunbar bf9e48cbaa AST: Move C++ record layout dumping to ASTContext::DumpRecordLayout.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100746 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 02:59:49 +00:00
Anders Carlsson 37147ea14f More record layout builder cleanup and simplification.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98238 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 05:42:17 +00:00
Anders Carlsson 88f4296e85 Get rid of the PrimaryBase parameter from LayoutVirtualBases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 04:33:54 +00:00
Anders Carlsson 622e2477d0 More cleanup towards fixing the real bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98232 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 04:24:02 +00:00
Anders Carlsson 147b5ddc6c Replace the class offset vectors in RecordLayoutBuilder with maps instead so we'll have faster lookup and so we can detect duplicates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 04:10:39 +00:00
Anders Carlsson 584e1dfaf6 More cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98230 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 03:39:12 +00:00
Anders Carlsson 23a5fcba19 More record layout builder cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98229 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 02:41:30 +00:00
Anders Carlsson 9dc82d2193 Remove the IndirectPrimary parameter in LayoutVirtualBases; it's already there as a member variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 00:21:21 +00:00
Anders Carlsson 200c5c2d94 More cleanup and simplification of the record layout builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 00:15:35 +00:00
Anders Carlsson e3bdbee470 Get rid of the LayoutBaseNonVirtually; it was used to lay out a base either as a non-virtual base or a virtual base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 22:26:24 +00:00
Anders Carlsson e239b9d5da More shuffling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98197 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 22:21:28 +00:00
Anders Carlsson 4c3a7b04a6 Cleanups, no functionality change yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98196 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 22:16:06 +00:00
Ted Kremenek 503524acc7 Allocate ASTRecordLayout objects using the allocator associated with ASTContext.
This allows them to be allocated using a BumpPtrAllocated
in the common case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97978 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-08 20:56:29 +00:00
Fariborz Jahanian 11062e1123 Patch removes IVars list from ObjCInterfaceDecl and
instead relies on their DeclContext for iteration, etc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 00:31:17 +00:00
Zhongxing Xu 94ba380b82 Simplify code. If we can reach here, the base must be virtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 04:28:35 +00:00
Mike Stump 6ebee078ec Be sure to select primary bases among the nearly empties in preorder,
not just among the direct bases.  Before we where missing nearly
empties that were bases of virtual base classes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:27:17 +00:00
Douglas Gregor bd6d6197fc Improve key-function computation for templates. In particular:
- All classes can have a key function; templates don't change that.
  non-template classes when computing the key function.
  - We always mark all of the virtual member functions of class
  template instantiations. 
  - The vtable for an instantiation of a class template has weak
  linkage. 

We could probably use available_externally linkage for vtables of
classes instantiated by explicit instantiation declarations (extern
templates), but GCC doesn't do this and I'm not 100% that the ABI
permits it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92753 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 19:06:31 +00:00
Eli Friedman 61eab88721 Misc key function fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90831 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 03:56:49 +00:00
Anders Carlsson 863dbcb45e Instantiated or specialized class templates never have a key function. This (and the previous check-in) fixes PR5557.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90753 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-07 08:29:39 +00:00
Anders Carlsson f53df2398e Move key functions to a separate map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90745 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-07 04:35:11 +00:00
Eli Friedman d7d7f67c1d Move helper onto CXXMethodDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90716 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 20:50:05 +00:00
Eli Friedman 378fe06b93 Tweak "key function" rules so that they work for templates with virtual
inline functions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-05 04:55:55 +00:00
Anders Carlsson 5ec02ae147 In Sema, whenever we think that a function is going to cause a vtable to be generated, we mark any virtual implicit member functions as referenced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90327 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 17:15:43 +00:00
Anders Carlsson 1a5e0d7f18 Have ASTRecordLayout keep track of the key function, in preparation of fixing a synthetic ctor/dtor bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90168 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-30 23:41:22 +00:00
Anders Carlsson 261fba6cf5 Use a PointerIntPair for the PrimaryBaseInfo. Yay for clever LLVM data structures!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90020 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-27 22:14:40 +00:00
Anders Carlsson ce2009ab2f Add a new PrimaryBaseInfo struct that combines the record decl of a primary base with whether it's virtual or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-27 22:05:05 +00:00
Anders Carlsson e4fc0d9742 When laying out bitfields, make sure that the data size is always aligned to a byte. This fixes PR5580.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89611 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-22 19:13:51 +00:00
Anders Carlsson 42dbcc4d8f Move bit-field layout out into a separate function. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89604 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-22 17:37:31 +00:00
Sean Hunt bbd37c62e3 Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
 - align() - semantics believed to be conformant to n3000, except for
   redeclarations and what entities it may apply to
 - final - semantics believed to be conformant to CWG issue 817's proposed
   wording, except for redeclarations
 - noreturn - semantics believed to be conformant to n3000, except for
   redeclarations
 - carries_dependency - currently ignored (this is an optimization hint)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89543 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-21 08:43:09 +00:00
Mike Stump 37acf5a57f Fixup spacing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 02:49:00 +00:00
Mike Stump 968db33646 Refine layout for indirect virtual base classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86116 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 04:02:15 +00:00
Sebastian Redl 9994a34f6c Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:03:50 +00:00
Anders Carlsson ff2460883b Address comment from Daniel.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82865 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 16:55:29 +00:00
Anders Carlsson a223935e5c Rename NextOffset to DataSize.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82832 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 01:34:51 +00:00
Anders Carlsson dfde681bdd Start at NextOffset when laying out bases as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82831 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 01:29:10 +00:00
Anders Carlsson 7e41038723 Use NextOffset when laying out a field.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 01:09:35 +00:00
Anders Carlsson 1eca99b815 Even more work on empty classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82770 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 15:39:00 +00:00
Anders Carlsson a4c6081abd Who would have thought that empty classes were so tricky? Handle cases where an empty virtual base class needs to be moved aside because it conflicts with the first field.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82746 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 01:54:38 +00:00
Anders Carlsson fbbce49c11 Handle array fields that contain empty structs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82744 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 01:23:32 +00:00
Anders Carlsson 6026504302 More work on empty classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82736 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 00:02:51 +00:00
Anders Carlsson ffbdefc7a2 More improvements with laying out empty bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82682 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 05:21:31 +00:00
Anders Carlsson 1345bd2b09 More work on empty classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82679 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 03:22:10 +00:00
Anders Carlsson 9606149722 Scaffolding for supporting empty bases/fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82678 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 03:13:30 +00:00
Anders Carlsson 56cfdc183e If we already set a primary base, don't set it to the first nearly empty base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82563 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 19:16:59 +00:00
Anders Carlsson 0cd40e4f90 Explicitly initialize the PrimaryBase and PrimaryBaseWasVirtual members.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82560 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 18:21:58 +00:00
Mike Stump a48f552c74 Yes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 17:38:02 +00:00
Anders Carlsson 3f06652234 Store the set of indirect primary bases directly in the record layout builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82513 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 03:02:06 +00:00
Anders Carlsson e4feb834fb Record layout builder cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 00:04:45 +00:00
Anders Carlsson b237fd6f36 Temporary band-aid for handling empty classes somewhat better.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82124 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-17 04:42:56 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
Mike Stump fe3010d09c Refine vbase offset calculations. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 19:04:13 +00:00
Mike Stump 276b9f1d81 Cleanups and fixups for calculating the virtual base offsets. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79156 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 01:46:26 +00:00
Mike Stump 2153891806 Deconflate virtual base offsets from non-virtual base offsets.
Deconflate a virtual base primary from a non-virtual base.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-14 01:44:03 +00:00
Mike Stump 0880e75541 We can't avoid doing the work to find all the indirect primary virtual
base classes as we'll need that to layout the virtual bases...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78954 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 23:26:06 +00:00
Mike Stump 4ef980984f Refine vtable layout for virtual bases and keep better track of
primaries.  WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78950 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 22:53:07 +00:00
Mike Stump d53cef178d Prep for vbase layout refinements. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78882 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 02:02:14 +00:00
Mike Stump 94d0bceeb3 Refine virtual base layout. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78873 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 00:34:14 +00:00
Mike Stump 0a5cfd86de Remove another done audit FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 22:10:00 +00:00
Mike Stump 02b16238a3 Refactor a bit and remove some FIXME audit markers, now that the code
has been audited for correctness.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 22:06:55 +00:00
Mike Stump d76264e0b2 Refine primary vbase selection ordering. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 21:50:08 +00:00
Mike Stump 49520944c6 Implement more of the inductive case for vtable layout involving
virtual base primaries and improve the layout of classes with virtual
bases.  WIP.

Hey, I've decided I want a change to FileCheck, I need to ensure that
the group is together, nothing in between.  Can we change it to check
the match line is from the line immediately following the last matched
line, if the source for the matched line is immediately after the
source for the previously matched line?

// CHECK: 1
// CHECK: 2
// CHECK: 3

// CHECK: 4
// CHECK: 5
// CHECK: 6

would require 1 2 and 3 to be continuous in the output, and 4 5 and 6
to be continuous.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 04:03:59 +00:00
Anders Carlsson a5dd722bdf Take #pragma pack into account when laying out structs. Fixes rdar://problem/7095436.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78490 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 19:38:24 +00:00
Anders Carlsson a860e755f1 Introduce a new PragmaPack attribute, and use it for #pragma pack. The PackedAttr now only represents __attribute__((packed)).
This is necessary because #pragma pack and __attribute__((packed)) have different semantics. No functionality change yet, but this lays the groundwork for fixing a record layout bug.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78483 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 18:23:56 +00:00
Mike Stump 928f1506eb Add ability to generate vcall offsets for primary virtual base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-07 19:00:50 +00:00
Mike Stump eb19fa9481 Layout virtual bases. Work in progress.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78308 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 13:41:24 +00:00
Mike Stump a71d5713ea Fix spell-o.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78303 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 12:52:13 +00:00
Mike Stump 2effeca6b4 Fixup object layout when we have a primary base (it goes first). Start preping for
virtual base layout.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 00:38:46 +00:00
Mike Stump 6f37633613 Calculate the primary base class better and use that when laying down
the vtable.  Still a work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 22:37:18 +00:00
Mike Stump f121677b6b Add code to setup the vtable pointer in the constructor. Work in progress.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77699 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 18:25:34 +00:00
Mike Stump b49ef009e4 Update based upon comments. Explain why we have an assert.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77612 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 18:01:44 +00:00
Mike Stump 90f6708388 We'll also need a vtable pointer if we have virtual bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77610 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 17:53:53 +00:00
Mike Stump 3dee6efcad Add ability to layout the vtable pointer in trivial cases. I noticed
that we would silently do bad things with virtual bases in the layout
code, so, we just turn them off.  When people do better things with
them, we can turn them back on.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77556 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 00:22:38 +00:00
Ted Kremenek 6217b80b7a Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 21:53:49 +00:00
Fariborz Jahanian 8a8a629844 No longer need to keep base class offsets in the offset
table as it has its own place now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77491 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 18:50:06 +00:00
Anders Carlsson b2fafd4978 Add a field for C++ specific data to ASTRecordLayout. Use it to store the non-virtual size and alignment + base offsets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 19:24:15 +00:00
Fariborz Jahanian 742cd1b7bb ir-gen for non-virtual base class initialization
in constructors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77087 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-25 21:12:28 +00:00
Anders Carlsson 74cbe22620 Handle layout of non-virtual base classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76348 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-19 00:18:47 +00:00
Anders Carlsson a2df41c107 Refactor field layout into a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76343 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 21:48:39 +00:00
Anders Carlsson 243a68551a Rename NextOffset to DataSize, which better matches the Itanium C++ ABI
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76339 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 21:26:44 +00:00
Anders Carlsson 93fab9d67c More layout builder work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76333 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 20:50:59 +00:00
Anders Carlsson bda4c1015e Add a new ASTRecordLayoutBuilder class. Not used yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76330 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 20:20:21 +00:00