Roman Divacky
31ba613537
Dont cast away const needlessly. Found by gcc48 -Wcast-qual.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163325 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06 15:59:27 +00:00
Benjamin Kramer
7aaa167abb
Remove windows line endings.
...
While there fix a dead assert.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163031 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 22:14:25 +00:00
Joao Matos
6666ed4ed2
Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163013 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 18:45:21 +00:00
Benjamin Kramer
c23aca4475
Flesh out test for defaulted key functions a bit more.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161243 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-03 15:43:22 +00:00
Benjamin Kramer
f3fce80bb2
Fix failed to generate vtables in certain cases.
...
By C++ standard, the vtable should be generated if the first non-inline
virtual function is defined in the TU. Current version of clang doesn't
generate vtable if the first virtual function is defaulted, because the
key function is regarded as the defaulted function.
Patch by Li Kan!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161236 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-03 08:39:58 +00:00
Benjamin Kramer
d4f5198ae0
Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used instead.
...
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159719 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-04 18:45:14 +00:00
David Blaikie
581deb3da4
Revert Decl's iterators back to pointer value_type rather than reference value_type
...
In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.
This rolls back r155808 and r155869.
Review by Doug Gregor incorporating feedback from Chandler Carruth.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158104 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 20:45:41 +00:00
John McCall
441c6239c6
Add support for laying out vtordisps according to our current
...
working knowledge of the Microsoft ABI. Based on a patch by
Dmitry Sokolov.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155905 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 08:55:32 +00:00
David Blaikie
262bc18e32
Remove the ref/value inconsistency in filter_decl_iterator.
...
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.
This change errs on the side of value, making op-> return T* and op* return
T&.
(reviewed by Richard Smith)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155808 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-30 02:36:29 +00:00
Sean Callanan
cad313bd7b
When laying out an Objective-C object, consult
...
the external source to complete the Decl if it
hasn't been completed already.
This fixes a crash in LLDB.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152807 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 16:33:08 +00:00
David Blaikie
4e4d08403c
Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
...
The member variable is always "LangOpts" and the member function is always "getLangOpts".
Reviewed by Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 07:00:24 +00:00
Sean Callanan
fd5a5f547c
If a struct needs to be laid out, and it has not
...
been completed yet, then complete it if possible.
This fixes some assertion failures encountered by
LLDB.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150020 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-08 00:04:52 +00:00
Douglas Gregor
394f7b650a
Allow the external AST source to provide a layout without specifying
...
the alignment (because it's not encoded in DWARF). In this case, make
an educated guess at the alignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149161 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-28 00:53:29 +00:00
Douglas Gregor
453dbcbe30
Extend the ExternalASTSource interface to allow the AST source to
...
provide the layout of records, rather than letting Clang compute
the layout itself. LLDB provides the motivation for this feature:
because various layout-altering attributes (packed, aligned, etc.)
don't get reliably get placed into DWARF, the record layouts computed
by LLDB from the reconstructed records differ from the actual layouts,
and badness occurs. This interface lets the DWARF data drive layout,
so we don't need the attributes preserved to get the answer write.
The testing methodology for this change is fun. I've introduced a
variant of -fdump-record-layouts called -fdump-record-layouts-simple
that always has the simple C format and provides size/alignment/field
offsets. There is also a -cc1 option -foverride-record-layout=<file>
to take the output of -fdump-record-layouts-simple and parse it to
produce a set of overridden layouts, which is introduced into the AST
via a testing-only ExternalASTSource (called
LayoutOverrideSource). Each test contains a number of records to lay
out, which use various layout-changing attributes, and then dumps the
layouts. We then run the test again, using the preprocessor to
eliminate the layout-changing attributes entirely (which would give us
different layouts for the records), but supplying the
previously-computed record layouts. Finally, we diff the layouts
produced from the two runs to be sure that they are identical.
Note that this code makes the assumption that we don't *have* to
provide the offsets of bases or virtual bases to get the layout right,
because the alignment attributes don't affect it. I believe this
assumption holds, but if it does not, we can extend
LayoutOverrideSource to also provide base offset information.
Fixes the Clang side of <rdar://problem/10169539>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149055 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-26 07:55:45 +00:00
Richard Smith
2d6a567046
constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,
...
APValue::Array and APValue::MemberPointer. All APValue values can now be emitted
as constants.
Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other
entrypoints dealing with constant member pointers are no longer necessary and
will be removed in a later change.
Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to
VarDecl::evaluateValue. This performs caching and deals with the nasty cases in
C++11 where a non-const object's initializer can refer indirectly to
previously-initialized fields within the same object.
Building the intermediate APValue object incurs a measurable performance hit on
pathological testcases with huge initializer lists, so we continue to build IR
directly from the Expr nodes for array and record types outside of C++11.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148178 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-14 04:30:29 +00:00
Eli Friedman
83be12c863
Recommit r148056 with fixes to deal with weirdness with bitfields in unions.
...
Original message: Make sure adding a field to a struct never reduces its size. PR11745.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148070 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12 23:48:56 +00:00
Eli Friedman
cd7a21b85e
Revert r148056 while I investigate failures.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148068 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12 23:27:03 +00:00
Eli Friedman
a179682672
Make sure adding a field to a struct never reduces its size. PR11745.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148056 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12 22:41:25 +00:00
Douglas Gregor
e7aa27a826
When performing layout for an Objective-C class, make sure to dig out
...
the definition of that class. Fixes PR11613 / <rdar://problem/10604077>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146976 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-20 15:50:13 +00:00
Douglas Gregor
7723fec9b4
Keep track of all declarations of an Objective-C class (both forward
...
declarations and definitions) as ObjCInterfaceDecls within the same
redeclaration chain. This new representation matches what we do for
C/C++ variables/functions/classes/templates/etc., and makes it
possible to answer the query "where are all of the declarations of
this class?"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146679 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-15 20:29:51 +00:00
Fariborz Jahanian
364a59ed8f
Fixes a bug in calculation of field offsets of ms_struct
...
fields by just following what comment says.
// rdar://10513599
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146414 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-12 21:16:36 +00:00
Eli Friedman
bff22ac1f8
Fix bitfield handling for record layout with #pragma pack. <rdar://problem/10494810> and PR9560.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-02 02:38:48 +00:00
Eli Friedman
901dd66893
Fix MSVC class layout for empty classes. Patch by Dmitry Sokolov.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145544 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-01 00:37:01 +00:00
John McCall
9da235244c
Fix the layout of vb-tables and vf-tables in the MS C++ ABI.
...
Based on work by Dmitry Sokolov!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144072 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-08 04:01:03 +00:00
Benjamin Kramer
e4ebbf79c7
Now that we have a portable 64 bit format string use it to make this simple again.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143800 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-05 09:02:52 +00:00
Eli Friedman
8a5d0aedc1
Fix incorrect format string in debug output.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143768 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-05 00:38:30 +00:00
Eli Friedman
227e483cb1
More ASTRecordLayout changes for MS ABI; based on patch by r4start.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142694 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 22:49:56 +00:00
Eli Friedman
66f284632d
Revert accidental commit.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142326 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18 01:18:41 +00:00
Eli Friedman
97c0aefe8c
Rewrite parts of MS ABI C++ layout. Based on work by r4start; I ended up doing this while I was trying to review his patch.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142325 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18 00:55:28 +00:00
Benjamin Kramer
b8989f27f1
Change operator<< for raw_ostream and NamedDecl to take a reference instead of a pointer.
...
Passing a pointer was a bad idea as it collides with the overload for void*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 18:45:37 +00:00
Richard Smith
a6b8b2c096
Constant expression evaluation refactoring:
...
- Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions,
and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert
behaviour.
- Factor out evaluation of bitfield bit widths.
- Fix a few places which would evaluate an expression twice: once to determine
whether it is a constant expression, then again to get the value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141561 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10 18:28:20 +00:00
John McCall
5e1cdac63c
Rename TagDecl::isDefinition -> isCompleteDefinition
...
for better self-documenting code, since the semantics
are subtly different from getDefinition().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141355 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 06:10:15 +00:00
John McCall
6595935602
Record layout requires not just a definition, but a complete
...
definition. Assert this. Change IR generation to not try to
aggressively emit the IR translation of a record during its
own definition. Fixes PR10912.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 02:39:22 +00:00
Daniel Dunbar
88934e85f8
Driver & AST: Implement support for -fpack-struct and -fpack-struct= command
...
line options.
- <rdar://problem/10120602>, PR9631
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141211 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 21:04:55 +00:00
Eric Christopher
68395a7a9c
Fix doxygen comment.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141165 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 06:00:51 +00:00
Eli Friedman
2fe363622c
Some changes to improve compatibility for MSVC-style C++ struct layout. Patch from r4start at gmail.com (with some minor modifications by me).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140623 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 19:12:27 +00:00
Ted Kremenek
ae5860e178
Don't emit -Wpadded warnings without a valid SourceLocation. This can happen when RecordLayoutBuilder is used by Codegen, not Sema.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139162 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 19:40:45 +00:00
Douglas Gregor
bcfd1f55bf
Extend the ASTContext constructor to delay the initialization of
...
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138985 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 00:18:52 +00:00
Chad Rosier
b8fca90263
Add support for using anonymous bitfields (e.g., int : 0) to enforce alignment.
...
This fixes cases where the anonymous bitfield is followed by a bitfield member.
E.g.,
struct t4
{
char foo;
long : 0;
char bar : 1;
};
rdar://9859156
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136991 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 22:38:04 +00:00
Chad Rosier
dd7fddb5b6
More whitespace and naming fixup. No functionality change.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136944 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 23:34:15 +00:00
Chad Rosier
0e7bf40027
Fix style and remove obviously redundant code.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 19:25:14 +00:00
Chad Rosier
6e43f3f0e2
Additional comments and whitespace.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136892 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 17:52:43 +00:00
Chad Rosier
61a62216a0
Add partial support for using anonymous bitfields (e.g., int : 0) to enforce
...
alignment. This fixes cases where the anonymous bitfield is followed by a
non-bitfield member. E.g.,
struct t4
{
int foo : 1;
long : 0;
char bar;
};
Part of rdar://9859156
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 01:21:14 +00:00
Chris Lattner
5f9e272e63
remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
...
them into the clang namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 10:55:15 +00:00
Jordy Rose
db8264e4c5
Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
...
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 02:08:32 +00:00
Fariborz Jahanian
bf9eb88792
Eliminate most uses of ShallowCollectObjCIvars which requires
...
a vector for collection. Use iterators where needed instead.
// rdar://6817577
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134015 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 18:05:25 +00:00
Eli Friedman
cb5d2d0647
PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates.
...
While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-10 21:53:06 +00:00
Fariborz Jahanian
6ec50ad4b1
Implenment #pack pragma and ms_struct attribute layout.
...
Concludes // radar://8823265.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131188 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-11 16:58:31 +00:00
Fariborz Jahanian
ed63e03e35
Support pack pragma and ms_struct attributes. // rdar://8823265
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131142 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-10 19:00:50 +00:00
Fariborz Jahanian
30364d0a64
'long long' requires special treatment in ms_struct
...
structs (impacts 32-bit only though).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-09 22:03:17 +00:00
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