Commit Graph

185 Commits

Author SHA1 Message Date
Ken Dyck 02ced6fd19 Convert MaxFieldAlignment to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125704
2011-02-17 01:49:42 +00:00
Ken Dyck 1300b3b357 Convert the UnpackedAlignment field to CharUnits from bits. No change in
functionality intended.

llvm-svn: 125643
2011-02-16 02:11:31 +00:00
Ken Dyck 4731d5b65a Convert Alignment member to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125641
2011-02-16 02:05:21 +00:00
Ken Dyck af1c83fbe7 Convert NonVirtualSize to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125639
2011-02-16 01:52:01 +00:00
Ken Dyck a2d3dda041 Convert NonVirtualAlignment to CharUnits. No change in functionality
intended.

llvm-svn: 125638
2011-02-16 01:43:15 +00:00
Ken Dyck 7ad11e70b6 Convert RecordLayout::Alignment to CharUnits from bit units. No change in
functionality intended. 

llvm-svn: 125549
2011-02-15 02:32:40 +00:00
Ken Dyck d5090c16f8 Convert RecordLayout::DataSize to CharUnits from bits, eliminating two
unnecessary calls to RoundUpToAlignment. No changes to functionality
intended.

llvm-svn: 125356
2011-02-11 02:20:09 +00:00
Ken Dyck b0fcc59e19 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.

llvm-svn: 125332
2011-02-11 01:54:29 +00:00
Ken Dyck c8ae55050d Convert RecordLayout::Size to CharUnits from bits. No changes to
functionality intended.

llvm-svn: 125156
2011-02-09 01:59:34 +00:00
Ken Dyck bec0285d7f Convert RecordLayout::NonVirtualAlign to CharUnits. No change in
functionality intended.

llvm-svn: 125069
2011-02-08 02:02:47 +00:00
Fariborz Jahanian 09b2331cf7 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

llvm-svn: 124741
2011-02-02 19:36:18 +00:00
Douglas Gregor dbe3927026 Basic support for -mms-bitfields, from Carl Norum!
llvm-svn: 124661
2011-02-01 15:15:22 +00:00
Ken Dyck 316d6f69bc Convert RecordLayout::NonVirtualSize from bit units to CharUnits.
llvm-svn: 124646
2011-02-01 01:52:10 +00:00
Ken Dyck 7c4026bea7 Remove private toCharUnits() helper method, replacing with calls to
ASTContext::toCharUnitsFromBits().

llvm-svn: 124092
2011-01-24 01:28:50 +00:00
Ken Dyck 86a7fcc19c Replace calls to CharUnits::fromQuantity() with ones
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units.

llvm-svn: 123715
2011-01-18 01:56:16 +00:00
Jay Foad 39c7980772 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.

llvm-svn: 123314
2011-01-12 09:06:06 +00:00
Rafael Espindola 7bcde197d7 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.

llvm-svn: 122633
2010-12-29 23:02:58 +00:00
Argyrios Kyrtzidis d62c9be4fc Fix another unnecessary-struct-padding issue.
llvm-svn: 121352
2010-12-09 02:47:58 +00:00
Argyrios Kyrtzidis 8b54274fcf 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

llvm-svn: 121335
2010-12-09 00:35:20 +00:00
Anders Carlsson 60a6263ee8 Move isNearlyEmpty out into the ASTContext so it can be called from CodeGen as well.
llvm-svn: 120137
2010-11-25 01:51:53 +00:00
Anders Carlsson 7f95cd1817 Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.
llvm-svn: 120133
2010-11-24 23:12:57 +00:00
Anders Carlsson 5adde29d86 Use the newly added function in ASTRecordLayoutBuilder.
llvm-svn: 120131
2010-11-24 22:55:48 +00:00
Argyrios Kyrtzidis d004064864 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.

llvm-svn: 119730
2010-11-18 20:06:41 +00:00
Anders Carlsson 09814d3f3a Don't update empty field subobjects for bitfields. Fixes PR8519.
llvm-svn: 117921
2010-11-01 15:14:51 +00:00
Anders Carlsson 0a14ee9ed8 Get rid of more calls to getBaseClassOffsetInBits.
llvm-svn: 117883
2010-11-01 00:21:58 +00:00
Anders Carlsson 3f01871647 Port over a couple of getVBaseClassOffsetInBits call sites to use getVBaseClassOffset instead.
llvm-svn: 117882
2010-10-31 23:45:59 +00:00
Anders Carlsson fd88a6160d Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset.
llvm-svn: 117881
2010-10-31 23:22:37 +00:00
Anders Carlsson a2f8e41a0a Start converting over the RecordLayoutBuilder next.
llvm-svn: 117878
2010-10-31 22:20:42 +00:00
Anders Carlsson 28466ab8f4 EmptyObjectMap now uses CharUnits wherever possible.
llvm-svn: 117877
2010-10-31 22:13:23 +00:00
Anders Carlsson 233e272775 More CharUnits conversion.
llvm-svn: 117875
2010-10-31 21:54:55 +00:00
Anders Carlsson 725190ff3f More CharUnits conversion.
llvm-svn: 117874
2010-10-31 21:39:24 +00:00
Anders Carlsson f8f756d1d5 Use CharUnits in the EmptyClassOffsets map.
llvm-svn: 117873
2010-10-31 21:22:43 +00:00
Anders Carlsson 22f5720c27 Baby steps towards using only CharUnits for base class offsets in ASTRecordLayout. Start by storing the offsets in CharUnits in the ASTRecordLayout object.
llvm-svn: 117869
2010-10-31 21:01:46 +00:00
Benjamin Kramer 2fc373e155 Move classes into anonymous namespaces.
llvm-svn: 117104
2010-10-22 16:33:16 +00:00
Argyrios Kyrtzidis 6843141d39 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.

llvm-svn: 116508
2010-10-14 20:14:38 +00:00
Argyrios Kyrtzidis 8c64bbe032 Embrace C++ ABI 5.2.6 and consider that template instantiations don't have key functions (same as GCC).
llvm-svn: 116391
2010-10-13 02:39:41 +00:00
Argyrios Kyrtzidis ca0d0cd3b9 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.

llvm-svn: 114544
2010-09-22 14:32:24 +00:00
Argyrios Kyrtzidis 3c6cd17c8a Use a smart pointer instead of delete.
llvm-svn: 112005
2010-08-25 00:32:14 +00:00
Chandler Carruth 76c0cb493f Add a virtual destructor to the base of another class hierarchy with virtual
methods.

llvm-svn: 111804
2010-08-23 08:37:21 +00:00
Charles Davis 6bcb07ad71 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. :)

llvm-svn: 111507
2010-08-19 02:18:14 +00:00
John McCall 1ed0182413 Restore the build
llvm-svn: 111498
2010-08-19 01:21:57 +00:00
Charles Davis c2c576a9e7 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.

llvm-svn: 111493
2010-08-19 00:55:19 +00:00
Alexis Hunt dcfba7b35b 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.

llvm-svn: 111455
2010-08-18 23:23:40 +00:00
Daniel Dunbar 56df97761d StringRef'ication of lots stuff, patch by Peter Davies!
llvm-svn: 111314
2010-08-17 22:39:59 +00:00
Argyrios Kyrtzidis 499e6e49e7 Remove ATTRIBUTE_UNUSED from the common pattern of disallowing copying.
llvm-svn: 111101
2010-08-15 10:17:39 +00:00
Argyrios Kyrtzidis 0a33cb62a6 Add ATTRIBUTE_UNUSED to methods not supposed to be used.
llvm-svn: 111087
2010-08-15 01:15:27 +00:00
Daniel Dunbar f35e76552f Sema: Fix a subtle i64 -> i32 truncation which broke layout of large structures
with bit-fields.

llvm-svn: 107185
2010-06-29 18:34:35 +00:00
Jeffrey Yasskin bb219e01a6 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.

llvm-svn: 107143
2010-06-29 15:27:35 +00:00
Anders Carlsson cc59cc5d80 Do the same short-circuit optimization when laying out bases.
llvm-svn: 105920
2010-06-13 18:00:18 +00:00
Anders Carlsson ae111dc821 Implement part of the EmptySubobjectMap optimization described in PR6998. We still need to do this for bases.
llvm-svn: 105919
2010-06-13 17:49:16 +00:00