Commit Graph

5427 Commits

Author SHA1 Message Date
Richard Smith 7073a2da15 Reapply r198845, reverted in r198849, with a fix to make it valid C++98, not
just valid C++11 =)

Original commit message:

PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on
SPARC, where uint64_t apparently requires higher alignment than void*.

llvm-svn: 198903
2014-01-10 00:40:45 +00:00
Warren Hunt 640015cbc3 [ms-abi] Fixing CGRecordLayoutBuilder w.r.t. MS NonVirutalBase Layout
The MS abi lays out *all* non-virtual bases with leading vfptrs before 
laying out non-virutal bases without vfptrs.  This guarantees that the 
primary base is laid out first.  r198818 fixed RecordLayoutBuilder to 
produce compatiable layouts.  This patch fixes CGRecordLayoutBuilder to 
be able to consume those layouts and produce meaningful output without 
tripping any asserts about assumed incoming layout.

A test case is included that shows CGRecordLayoutBuilder in fact 
produces output in the compatiable order.

llvm-svn: 198900
2014-01-09 23:51:31 +00:00
Argyrios Kyrtzidis 62a85daecd Revert "PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on"
It broke building.
This reverts commit r198845.

llvm-svn: 198849
2014-01-09 05:01:04 +00:00
Richard Smith e2f4a2744c PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on
SPARC, where uint64_t apparently requires higher alignment than void*.

llvm-svn: 198845
2014-01-09 03:29:54 +00:00
David Blaikie 461f1eaaa1 Fix the clang -Werror build after r198818
llvm-svn: 198837
2014-01-09 02:34:06 +00:00
Warren Hunt d640d7d96e [ms-abi] Refactor Microsoft Record Layout
This patch refactors microsoft record layout to be more "natural".  The 
most dominant change is that vbptrs and vfptrs are injected after the 
fact.  This simplifies the implementation and the math for the offest 
for the first base/field after the vbptr.

llvm-svn: 198818
2014-01-09 00:30:56 +00:00
Richard Smith 26d11be738 RP18408: If a member template is used as a template template argument, it does
not cause the template specialization to have no linkage.

llvm-svn: 198726
2014-01-08 01:51:59 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Fariborz Jahanian f1a66de5b9 ObjectiveC. Computation of offsets when doing @encode type encoding
is only used in an assert. Do not do it if assert is not on.

llvm-svn: 198652
2014-01-07 01:02:50 +00:00
Alp Toker b9fa512954 Highlight the previous underlying enum type when diagnosing a mismatch
enum-scoped.cpp:93:6: error: enumeration redeclared with different underlying type 'short' (was 'int')
  enum Redeclare6 : short;
       ^
enum-scoped.cpp:92:6: note: previous declaration is here
  enum Redeclare6 : int;
       ^            ~~~

The redeclaration source range is still missing but this is a step forward,
potentially edging towards a FixIt.

llvm-svn: 198601
2014-01-06 11:31:18 +00:00
Alp Toker ef6b007dc5 Only mark dump() function definitions 'used' in debug builds
This has the dual effect of (1) enabling more dead-stripping in release builds
and (2) ensuring that debug helper functions aren't stripped away in debug
builds, as they're intended to be called from the debugger.

Note that the attribute is applied to definitions rather than declarations in
headers going forward because it's now conditional on NDEBUG:

  /// \brief Mark debug helper function definitions like dump() that should not be
  /// stripped from debug builds.

Requires corresponding macro added in LLVM r198456.

llvm-svn: 198489
2014-01-04 13:47:14 +00:00
Reid Kleckner 5f08094106 [ms-cxxabi] Improve vbtable name mangling accuracy
Summary:
This makes us more compatible with MSVC 2012+ and fixes PR17748 where we
would give two tables the same name.

Rather than doing a fresh depth-first traversal of the inheritance graph
for every record's vbtables, now we memoize vbtable paths for each
record.  By doing memoization, we end up considering virtual bases of
subobjects that come later in the depth-first traversal.  Where
previously we would have ignored a virtual base that we'd already seen,
we now consider it for name mangling purposes without emitting a
duplicate vbtable for it.

Reviewers: majnemer

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2509

llvm-svn: 198462
2014-01-03 23:42:00 +00:00
Aaron Ballman 68af21c975 Fixing a FIXME; the RetTy template parameter is always bool in practice, and so it has been removed. No functional changes intended.
llvm-svn: 198440
2014-01-03 19:26:43 +00:00
Aaron Ballman 75ee4cc830 Removed one of the string versions of getQualifiedNameAsString, and switched over to using printQualifiedName where possible. No functional changes intended.
llvm-svn: 198433
2014-01-03 18:42:48 +00:00
Argyrios Kyrtzidis 2080d90f37 [objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
  all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
  This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.

rdar://15727325

llvm-svn: 198432
2014-01-03 18:32:18 +00:00
Aaron Ballman b190f974c9 Fixed a FIXME; created a print method for Selectors that accepts a raw_ostream, and started using it in places it made sense.
No functional changes intended, just API cleanliness.

llvm-svn: 198428
2014-01-03 17:59:55 +00:00
Reid Kleckner b40a27dad8 [ms-cxxabi] Move VBTableBuilder from CodeGen over to AST/VTableBuilder.cpp
Summary:
No functionality change.

This code should live here long-term because we should be able to use it
to compute correct vftable names.

It turns out that the most natural way to implement the naming algorithm
is to use a caching layer similar to what we already have for virtual
table info in VTableContext.  Subsequent changes will take advantage of
this to fix PR17748, where we have a vbtable name collision.

Reviewers: majnemer

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2499

llvm-svn: 198380
2014-01-03 00:14:35 +00:00
Alp Toker 95e7ff2ed1 Eliminate UnaryTypeTraitExpr
Remove UnaryTypeTraitExpr and switch all remaining type trait related handling
over to TypeTraitExpr.

The UTT/BTT/TT enum prefix and evaluation code is retained pending further
cleanup.

This is part of the ongoing work to unify type traits following the removal of
BinaryTypeTraitExpr in r197273.

llvm-svn: 198271
2014-01-01 05:57:51 +00:00
DeLesley Hutchins c4a82438a7 Update RecursiveASTVisitor so that it visits attributes. This is currently
important for thread safety attributes, which contain expressions that were
not being visited, and were thus invisible to various tools.  There are now
Visit*Attr methods that can be overridden for every attribute.

llvm-svn: 198224
2013-12-30 17:24:36 +00:00
Alp Toker a724cff01b Rename isBuiltinCall() to getBuiltinCallee()
This better describes what the function does.

Cleanup only.

llvm-svn: 198127
2013-12-28 21:59:02 +00:00
Reid Kleckner 31a9f74c1d Reduce indentation of some VFTableBuilder code.
No functionality change.

llvm-svn: 198085
2013-12-27 20:29:16 +00:00
Reid Kleckner 558cab2f49 Fix incorrect copy-pasted method decl that MSVC allowed.
llvm-svn: 198081
2013-12-27 19:45:53 +00:00
Reid Kleckner 604c8b45e4 [ms-cxxabi] Emit fewer trivial return adjusting thunks
Most importantly, this makes our vtable layout match MSVC's.  Previously
we would emit a return adjusting thunk whenever the return types
differed, even if the adjustment would have been trivial.

MSVC does emit some trivial return adjusting thunks, but only if there
was already an overridden method that required a return adjustment.

llvm-svn: 198080
2013-12-27 19:43:59 +00:00
Warren Hunt 50de3522e6 [ms-abi] Fixes improperly sized vfptrs with pragma pack
With pragma pack, the layout engine would produce vfptrs that were 
packed width rather than pointer width.  This patch addresses the issue 
and adds a test case.

llvm-svn: 198059
2013-12-26 22:09:12 +00:00
Aaron Ballman 3e424b5070 Teach the diagnostics engine about the Attr type to make reporting on semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting.
llvm-svn: 198055
2013-12-26 18:30:57 +00:00
Alp Toker a5d645976f Assert that tag decls are never marked (in)valid after definition is complete
Sema relies on this assumption.

Follow-up to r197848.

llvm-svn: 197850
2013-12-21 01:10:54 +00:00
Reid Kleckner b60a3d5bc1 Eliminate the ItaniumVTableContext object from CodeGenVTables
Now CodeGenVTables has only one VTableContext object, which is either
Itanium or Microsoft.

Fixes a FIXME with no functionality change intended.

Ideally we could avoid the downcasts by pushing the things that
reference the Itanium vtable context into ItaniumCXXABI.cpp, but we're
not there yet.

llvm-svn: 197845
2013-12-20 23:58:52 +00:00
Reid Kleckner d2d1cc5156 Compare canonical return types when generating MS C++ ABI vtable thunks
This was part of the cause for PR17655.  We were generating thunks when
we shouldn't have.  I suspect that if we tweak the test case for PR17655
to actually require thunks, we can reproduce the same crash.

llvm-svn: 197836
2013-12-20 21:44:05 +00:00
Aaron Ballman 9ead1243a5 Replacing calls to getAttr with calls to hasAttr for clarity. No functional change intended -- this only replaces Boolean uses of getAttr.
llvm-svn: 197648
2013-12-19 02:39:40 +00:00
Warren Hunt f037bd1e7c [ms-abi] Update Alignment for VtorDisps
The alignment impact of the virtual bases apperas to be applied in 
order, rather than up front.  This patch adds the new behavior and 
provides a test case.

llvm-svn: 197639
2013-12-19 00:43:59 +00:00
Aaron Ballman 8edb5c2081 Refactor the Microsoft inheritance attribute handling so that it no longer has special treatment. Also fixes a minor bug where the attributes were being parsed as though they were GNU-style attributes when they were in fact keyword attributes.
llvm-svn: 197629
2013-12-18 23:44:18 +00:00
Reid Kleckner e7106c9e0b Use getAsCXXRecordDecl to shorten some gets and casts
llvm-svn: 197626
2013-12-18 23:17:05 +00:00
Dmitri Gribenko e8bc31f0ab Documentation comment parsing: when checking if we have typedef to something
that we consider a function for the purposes of checking \param and \returns,
look through reference types.

llvm-svn: 197530
2013-12-17 22:22:14 +00:00
Dmitri Gribenko fa68a57cf7 Documentation comment parsing: allow \param and \returns on std::function,
boost::function and similar function-like objects

llvm-svn: 197528
2013-12-17 22:06:11 +00:00
Dmitri Gribenko 110dfa81fd Fix strange indentation and remove trailing whitespace on empty lines
llvm-svn: 197513
2013-12-17 19:28:18 +00:00
Alp Toker b164a349f9 Fix indentation from r197490 plus some typos
llvm-svn: 197507
2013-12-17 17:25:19 +00:00
Alp Toker 2dea15b53c ASTContext: Refactor implicit record creation
Tidy up built-in record creation to reduce code duplication.

Continuation of r197336.

llvm-svn: 197452
2013-12-17 01:22:38 +00:00
Alp Toker 56b5cc91af ASTContext: Declare builtin types implicitly
__builtin_va_list and friends have been showing up where they shouldn't for way
to long, making unwanted appearences in -ast-print, tooling and source level
visitors and even the hello world tutorial on the clang website.

This commit factors down the implicit typedef and record creation facilities to
ensure they're marked implicit.

Also fixes a unit test that was testing incorrect behaviour, and removes old
hacks in the DeclPrinter that tried to skip implicit declarations manually.

llvm-svn: 197336
2013-12-15 10:36:26 +00:00
Richard Smith 8a0dde75f1 PR18232: implement instantiation for class-scope explicit specializations of
class templates (a Microsoft extension).

llvm-svn: 197298
2013-12-14 01:04:22 +00:00
Alp Toker 88f64e6aeb Remove an unused parameter and include after r197273
llvm-svn: 197274
2013-12-13 21:19:30 +00:00
Alp Toker cbb9034e2a Eliminate BinaryTypeTraitExpr
There's nothing special about type traits accepting two arguments.

This commit eliminates BinaryTypeTraitExpr and switches all related handling
over to TypeTraitExpr.

Also fixes a CodeGen failure with variadic type traits appearing in a
non-constant expression.

The BTT/TT prefix and evaluation code is retained as-is for now but will soon
be further cleaned up.

This is part of the ongoing work to unify type traits.

llvm-svn: 197273
2013-12-13 20:49:58 +00:00
David Majnemer b4119f7459 [-cxx-abi microsoft] Remove trailing spaces from the mangler
No functional change, just a tidying up.

llvm-svn: 197196
2013-12-13 01:06:04 +00:00
David Majnemer 9855994d81 AST: Update URL for Itanium ABI spec
The old URL hasn't worked for quite some time.  While we are here, also
change the link so that it will send us straight to the mangling portion
of the ABI doc.

llvm-svn: 197195
2013-12-13 00:54:42 +00:00
David Majnemer 25e1a5e7e3 [-cxx-abi microsoft] Add commentary for mangleStaticGuardVariable
We will need to do some work here if we want to play nice with MSVC2013.
Add a TODO indicating what changed and why this matters.

llvm-svn: 197193
2013-12-13 00:52:45 +00:00
David Majnemer 210e6bfa19 Revert "[-cxx-abi microsoft] Mangle reference temporaries"
This reverts commit r197184.

Richard Smith brings up some good points, a proper implementation will
require us to mangle unnameable entities compatibly with MSVC.

llvm-svn: 197192
2013-12-13 00:39:38 +00:00
David Majnemer 0834f13c95 [-cxx-abi microsoft] Mangle reference temporaries
They are mangled the same as normal references, nothing special is going
on here.

llvm-svn: 197184
2013-12-12 23:12:01 +00:00
Warren Hunt 4431fe6bec [ms-abi] Refactoring Non-virtual base layout in record layout
This refactor addresses bugzilla bug 18167 and simplifies the code at 
the same time.  Also I add a test case for the bug.  Also I make a 
non-functional change to the basic layout lit tests to make them more 
reliable (using CHECK-NEXT instead of CHECK).

llvm-svn: 197183
2013-12-12 22:33:37 +00:00
Alp Toker 40f9b1cd69 Unify type trait parsing
Type trait parsing is all over the place at the moment with unary, binary and
n-ary C++11 type traits that were developed independently at different points
in clang's history.

There's no good reason to handle them separately -- there are three parsers,
three AST nodes and lots of duplicated handling code with slightly different
implementations and diags for each kind.

This commit unifies parsing of type traits and sets the stage for further
consolidation.

No change in behaviour other than more consistent error recovery.

llvm-svn: 197179
2013-12-12 21:23:03 +00:00
Rafael Espindola 3497069784 Switch to the new MingW ABI.
GCC 4.7 changed the MingW ABI. On the clang side this means that methods now
have the thiscall calling convention by default.

llvm-svn: 197164
2013-12-12 16:07:11 +00:00
Richard Smith c934e4fd2c PR18217: Rewrite JumpDiagnostics' handling of temporaries, to correctly handle
declarations that might lifetime-extend multiple temporaries. In passing, fix a
crasher (PR18217) if an initializer was dependent and exactly the wrong shape,
and remove a bogus function (Expr::findMaterializedTemporary) now its last use
is gone.

llvm-svn: 197103
2013-12-12 01:27:02 +00:00
Ted Kremenek 8844660641 Add new PrintingPolicy entry to trim number of newlines. Useful for the CFG printer.
The change isn't completely comprehensive.  This can be filled in
lazily as needed.  There is one consumer right now.

llvm-svn: 197093
2013-12-11 23:44:02 +00:00
Warren Hunt c33843178d [ms-abi][cleanup] Removing FinalizeCXXLayout : no functional change
After r196549 there is no need to separate FinalizeCXXLayout and 
FinalizeLayout so they were merged and FinalizeCXXLayout was eliminated.

llvm-svn: 197083
2013-12-11 22:28:32 +00:00
David Tweed e1468322eb Add front-end infrastructure now address space casts are in LLVM IR.
With the introduction of explicit address space casts into LLVM, there's
a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA
and code to produce address space casts from those kinds when appropriate.

Patch by Michele Scandale!

llvm-svn: 197036
2013-12-11 13:39:46 +00:00
Warren Hunt 1b5184321d [ms-abi] Makes Virtual Base Alignment Look at All Virtual Bases
Prior to this patch, the alignment imposed by virtual bases only 
included direct virtual bases.  This patch fixes it to look at all 
virtual bases.

llvm-svn: 196997
2013-12-11 02:21:03 +00:00
Ted Kremenek f41cf7f10f Rename attribute 'objc_suppress_protocol_methods' to 'objc_protocol_requires_explicit_implementation'.
That's a mouthful, and not necessarily the final name.  This also
reflects a semantic change where this attribute is now on the
protocol itself instead of a class.  This attribute will require
that a protocol, when adopted by a class, is explicitly implemented
by the class itself (instead of walking the super class chain).

Note that this attribute is not "done".  This should be considered
a WIP.

llvm-svn: 196955
2013-12-10 19:43:48 +00:00
Argyrios Kyrtzidis e919fc20a6 [AST] In ObjCInterfaceDecl::isDesignatedInitializer(), use getMethod() instead of lookupMethod().
lookupMethod also goes through categories, which we don't need there.

llvm-svn: 196942
2013-12-10 18:36:43 +00:00
Richard Smith ab44d5badf Implement DR1460: fix handling of default initializers in unions; don't allow
more than one such initializer in a union, make mem-initializers override
default initializers for other union members, handle anonymous unions with
anonymous struct members better. Fix a couple of semi-related bugs exposed by
the tests for same.

llvm-svn: 196892
2013-12-10 08:25:00 +00:00
Warren Hunt 1603e52700 [ms-abi] 64-bit fixes for r196549
In order to address latent bugs that were easier to expose in 64-bit 
mode, we move the application of __declspec(align) to before the layout 
of vbases rather than after.

llvm-svn: 196861
2013-12-10 01:44:39 +00:00
David Majnemer 2a81645de5 [-cxx-abi microsoft] Mangle large integral constants correctly
Testing has revealed that large integral constants (i.e. > INT64_MAX)
are always mangled as-if they are negative, even in places where it
would not make sense for them to be negative (like non-type template
parameters of type unsigned long long).

To address this, we change the way we model number mangling: always
mangle as-if our number is an int64_t.  This should result in correct
results when we have large unsigned numbers.

N.B.  Bizarrely, things that are 32-bit displacements like vbptr offsets
are mangled as-if they are unsigned 32-bit numbers.  This is a pretty
egregious waste of space, it would be a 4x savings if we could mangle it
like a signed 32-bit number.  Instead, we explicitly cast these
displacements to uint32_t and let the mangler proceed.

llvm-svn: 196771
2013-12-09 10:44:32 +00:00
David Majnemer 048f90cc04 [-cxx-abi microsoft] Properly mangle enums
While testing our ability to mangle large constants (PR18175), I
incidentally discovered that we did not properly mangle enums correctly.

Previously, we would append the width of the enum in bytes after the
type-tag differentiator.

This would mean "enum : short" would be mangled as 'W2' while "enum :
char" would be mangled as 'W1'.  Upon testing this with several versions
of MSVC, I found that this did not match their behavior: they always use
'W4'.

N.B.  Quick testing uncovered that undname allows different numbers to
follow the 'W' in the following way:

'W0' -> "enum char"
'W1' -> "enum unsigned char"
'W2' -> "enum short"
'W3' -> "enum unsigned short"
'W4' -> "enum"
'W5' -> "enum unsigned int"
'W6' -> "enum long"
'W7' -> "enum unsigned long"

However this scheme appears abandoned, I cannot get MSVC to trigger it.
Furthermore, it's incomplete: it doesn't handle "bool" or "long long".

llvm-svn: 196752
2013-12-09 04:28:34 +00:00
Rafael Espindola 7ab1ce04bb Fix pr18174.
Clang outputs LLVM one top level decl at a time. This combined with the
visibility computation code looking for the newest NamespaceDecl would cause
it to produce different results for nested namespaces.

The two options for producing consistent results are
* Delay codegen of anything inside a namespace until the end of the file.
* Don't look for the newest NamespaceDecl.

This patch implements the second option.
This matches the gcc behavior too.

llvm-svn: 196712
2013-12-08 01:13:22 +00:00
Alp Toker c108676822 Eliminate the last trivial NDEBUG uses in clang headers
assert(sanity()) reads so much better than preprocessor conditional blocks.

llvm-svn: 196657
2013-12-07 13:51:35 +00:00
Alp Toker 3ffab05f54 CommentLexer: eliminate an NDEBUG from the headers
Code in headers shouldn't be conditional on the build configuration.

llvm-svn: 196656
2013-12-07 13:51:26 +00:00
Warren Hunt 4aafaee7df Fixing assertion failure introduced in 196602.
Also includes a minor refactor with no functional change.

llvm-svn: 196627
2013-12-07 00:15:04 +00:00
Warren Hunt 71140d68f8 [MS-ABI] adds padding before all vbases after a bitfield
MS-ABI adds padding before *every* vbase if the last field in a record 
is a bit-field. This changes clangs behavior to match. I also fix some 
windows-style line endings in the test file.

Differential Revision: http://llvm-reviews.chandlerc.com/D2277

llvm-svn: 196605
2013-12-06 20:16:49 +00:00
Warren Hunt 049f673dae [MS-ABI] Fix alias-avoidance padding between bases
Adds padding between bases or virtual bases in an attempt to avoid 
aliasing of zero-sized sub-objects.  The approach used by the ABI adds 
two more bits of state.  Detailed comments are in the code.  Test cases 
included.

Differential Revision: http://llvm-reviews.chandlerc.com/D2258

llvm-svn: 196602
2013-12-06 19:54:25 +00:00
Alp Toker 028ed91127 Fix code typos spotted while working on type traits
llvm-svn: 196587
2013-12-06 17:56:43 +00:00
Richard Smith c275da6a14 PR18152: When computing the semantic form for an initializer list, keep track
of whether the initializer list is dependent.

llvm-svn: 196558
2013-12-06 01:27:24 +00:00
Warren Hunt 7b252d24ad Support MS-ABI's concept of "Required Alignment" imposed by
__declspec(align())

This patch implements required alignment in a way that makes 
__declspec(align()) and #pragma pack play correctly together. In the 
MS-ABI, __declspec(align()) is a hard rule and cannot be overridden by 
#pragma pack. This cases each record to have two interesting alignments 
"preferred alignment" (which matches Itanium's concept of alignment) and 
"required alignment" which is an alignment that must never be violated, 
even in the case of #pragma pack. This patch introduces the concept of 
Required Alignment to the record builder and tracks/uses it 
appropriately. Test cases are included.

Differential Revision: http://llvm-reviews.chandlerc.com/D2283

llvm-svn: 196549
2013-12-06 00:01:17 +00:00
Alp Toker f6a24ce40f Fix a tranche of comment, test and doc typos
llvm-svn: 196510
2013-12-05 16:25:25 +00:00
Argyrios Kyrtzidis b9a405b33e [objc] If an interface has no initializer marked as designated and introduces at least one new initializer,
don't assume that it inherits the designated initializers from the super class.

If the assumption was wrong because a new initializer was a designated one that was not marked as such,
we will emit misleading warnings for subclasses of the interface.

llvm-svn: 196476
2013-12-05 07:07:03 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Reid Kleckner 0503a870a9 Add an AdjustedType sugar node for adjusting calling conventions
Summary:
In general, this type node can be used to represent any type adjustment
that occurs implicitly without losing type sugar.  The immediate use of
this is to adjust the calling conventions of member function pointer
types without breaking template instantiation.

Fixes PR17996.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D2332

llvm-svn: 196451
2013-12-05 01:23:43 +00:00
Argyrios Kyrtzidis b66d3cf5cf [objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.

A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.

llvm-svn: 196318
2013-12-03 21:11:49 +00:00
Argyrios Kyrtzidis fcded9b93a [objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.

llvm-svn: 196317
2013-12-03 21:11:43 +00:00
Argyrios Kyrtzidis 22bfa2c28b [objc] Emit a warning when the implementation of a designated initializer does not chain to
an init method that is a designated initializer for the superclass.

llvm-svn: 196316
2013-12-03 21:11:36 +00:00
Argyrios Kyrtzidis 9ed9e5f31c [objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get the
designated initializers of an interface.

If the interface declaration does not have methods marked as designated
initializers then the interface inherits the designated initializers of
its super class.

llvm-svn: 196315
2013-12-03 21:11:30 +00:00
Benjamin Kramer 2dece5747a CommentLexer: When proceeding with a typo corrected name don't clobber the token.
This would crash if the token is used in another diagnostic. PR18051.

llvm-svn: 196048
2013-12-01 15:09:32 +00:00
Rafael Espindola 9ad6112772 Don't call getMostRecentDecl when we know we have it.
On a Release build this takes the testcase in pr18055 from 0m3.892s to 0m1.452s.

llvm-svn: 195768
2013-11-26 16:09:08 +00:00
Rafael Espindola 8ef7f6828c Move these virtual methods out of line.
llvm-svn: 195767
2013-11-26 15:12:20 +00:00
Alp Toker aced95a0b0 Remove some unused locals
llvm-svn: 195714
2013-11-26 02:52:41 +00:00
David Majnemer 956bc117d9 [-cxx-abi microsoft] Create backrefs for <unnamed-type-`id'>
It wasn't possible for an anonymous type to show up inside of function arguments.
However, decltype (which MSVC added support for in 2010) makes this
possible.  Further, backrefs to these anonymous types can now be formed.

This fixes PR18022.

N.B. We do not, and very likely _will not_, support MSVC's bug where
subsequent typedefs of anonymous types leak into the linkage name; this
is a gross violation of the ABI.  A warning should be introduced to
inform our users of this particular shortcoming.

llvm-svn: 195669
2013-11-25 17:50:19 +00:00
Richard Smith c91d12ce80 Take cv-qualifiers on fields of class type into account when determining
whether a defaulted special member function should be deleted.

llvm-svn: 195620
2013-11-25 07:07:05 +00:00
Ted Kremenek 5ec76a0084 Use specific_attr_iterator to tighten loop over ObjCSuppressProtocolAttrs.
llvm-svn: 195561
2013-11-23 22:51:36 +00:00
Ted Kremenek 33f504328f Move logic to check if a class is tagged with objc_suppress_protocol_methods into a helper.
llvm-svn: 195559
2013-11-23 22:29:06 +00:00
Peter Collingbourne f0c1f59d7e Add Distance parameter to ASTNodeKind::isBaseOf.
This will allow the completer to order results by relevance.

Differential Revision: http://llvm-reviews.chandlerc.com/D2209

llvm-svn: 195540
2013-11-23 01:40:07 +00:00
Ted Kremenek 28eace65c0 Add back experimental attribute objc_suppress_protocol_methods (slightly renamed).
This is still an experimental attribute, but I wanted it in tree
for review.  It may still get yanked.

This attribute can only be applied to a class @interface, not
a class extension or category.  It does not change the type
system rules for Objective-C, but rather the implementation checking
for Objective-C classes that explicitly conform to a protocol.
During protocol conformance checking, clang recursively searches
up the class hierarchy for the set of methods that compose
a protocol.  This attribute will cause the compiler to not consider
the methods contributed by a super class, its categories, and those
from its ancestor classes.  Thus this attribute is used to force
subclasses to redeclare (and hopefully re-implement) methods if
they decide to explicitly conform to a protocol where some of those
methods may be provided by a super class.

This attribute intentionally leaves out properties, which are associated
with state.  This attribute only considers methods (at least right now)
that are non-property accessors.  These represent methods that "do something"
as dictated by the protocol.  This may be further refined, and this
should be considered a WIP until documentation gets written or this
gets removed.

llvm-svn: 195533
2013-11-23 01:01:34 +00:00
Ted Kremenek 0078150c43 Change ObjCIntefaceDecl::lookupMethod() to have optional 'followsSuper' argument.
This enables a micro-optimization in protocol conformance checking
to not examine the class hierarchy twice per method.

As part of this change, remove the default arguments from lookupInstanceMethod()
and lookupClassMethod().  It was becoming very redundant.  For clients
needing the default arguments, have them use the full API instead of
these convenience methods.

llvm-svn: 195532
2013-11-23 01:01:29 +00:00
Richard Smith f798172419 Add class-specific operator new to Decl hierarchy. This guarantees that Decls
can't accidentally be allocated the wrong way (missing prefix data for decls
from AST files, for instance) and simplifies the CreateDeserialized functions a
little. An extra DeclContext* parameter to the not-from-AST-file operator new
allows us to ensure that we don't accidentally call the wrong one when
deserializing (when we don't have a DeclContext), allows some extra checks, and
prepares for some planned modules-related changes to Decl allocation.

No functionality change intended.

llvm-svn: 195426
2013-11-22 09:01:48 +00:00
Ekaterina Romanova 91b655b683 Test commit for the user "kromanova" to verify commit access. I removed "UNSUPPORTED" comment because unsigned __int128 type is in fact supported.
llvm-svn: 195378
2013-11-21 22:25:24 +00:00
Ted Kremenek a14c3119ac Revert "Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class."
After implementing this patch, a few concerns about the language
feature itself emerged in my head that I had previously not considered.
I want to resolve those design concerns first before having
a half-designed language feature in the tree.

llvm-svn: 195328
2013-11-21 07:57:53 +00:00
Ted Kremenek a4bd9a0c0e Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class.
The idea is to allow a class to stipulate that its methods (and those
of its parents) cannot be used for protocol conformance in a subclass.
A subclass is then explicitly required to re-implement those methods
of they are present in the class marked with this attribute.

Currently the attribute can only be applied to an @interface, and
not a category or class extension.  This is by design.  Unlike
protocol conformance, where a category can add explicit conformance
of a protocol to class, this anti-conformance really needs to be
observed uniformly by all clients of the class.  That's because
the absence of the attribute implies more permissive checking of
protocol conformance.

This unfortunately required changing method lookup in ObjCInterfaceDecl
to take an optional protocol parameter.  This should not slow down
method lookup in most cases, and is just used for protocol conformance.

llvm-svn: 195323
2013-11-21 07:20:42 +00:00
Fariborz Jahanian 91fb0be96a ObjectiveC ARC. Better checking of toll free briding
from qualified-id objects to CF types with 
objc_bridge annotation. // rdar://15454846

llvm-svn: 195264
2013-11-20 19:01:50 +00:00
Fariborz Jahanian 92ab2985da ObjectiveC ARC. validate toll free bridge casting
to or from 'id' and qualified-id types.
// rdar://15454846

llvm-svn: 195178
2013-11-20 00:32:12 +00:00
Reid Kleckner cc99e26475 Add a mangler entry point for TBAA rather than using RTTI directly
Summary:
RTTI is not yet implemented for the Microsoft C++ ABI and isn't expected
soon.  We could easily add the mangling, but the error is what prevents
us from silently miscompiling code that expects RTTI.

Instead, add a new mangleTypeName entry point that simply forwards to
mangleName or mangleType to produce a string that isn't part of the ABI.
Itanium can continue to use RTTI names to avoid unecessary test
breakage.

This also seems like the right design.  The fact that TBAA names happen
to be RTTI names is now an implementation detail of the mangler, rather
than part of TBAA.

Differential Revision: http://llvm-reviews.chandlerc.com/D2153

llvm-svn: 195168
2013-11-19 23:23:00 +00:00
Warren Hunt c0df47dfed Microsoft Record Layout: zero sized base after base with vbtbl fix
Microsoft adds an extra byte of padding before laying out zero sized 
non-virtual bases if the non-virtual base before it contains a vbptr.  
This patch adds the same behavior to clang.

Differential Revision: http://llvm-reviews.chandlerc.com/D2106

llvm-svn: 195158
2013-11-19 22:11:09 +00:00
Hao Liu 90ee2f1fd7 Fix the problem that the arm_neon.h can't be used in a cpp file. Also fix a minor bug with poly64 name mangling.
llvm-svn: 194952
2013-11-17 09:14:46 +00:00
Hans Wennborg 88497d6157 [-cxx-abi microsoft] Emit thunks for pointers to virtual member functions
Instead of storing the vtable offset directly in the function pointer and
doing a branch to check for virtualness at each call site, the MS ABI
generates a thunk for calling the function at a specific vtable offset,
and puts that in the function pointer.

This patch adds support for emitting such thunks. However, it doesn't support
pointers to virtual member functions that are variadic, have an incomplete
aggregate return type or parameter, or are overriding a function in a virtual
base class.

Differential Revision: http://llvm-reviews.chandlerc.com/D2104

llvm-svn: 194827
2013-11-15 17:24:45 +00:00
Richard Smith e6c19f22b2 Modern gcc is happy to constant evaluate __builtin_strlen in various cases
where we didn't. Extend our constant evaluation for __builtin_strlen to handle
any constant array of chars, not just string literals, to match.

llvm-svn: 194762
2013-11-15 02:10:04 +00:00
Richard Smith 00f5d8927b DR408: If a static data member of incomplete array type is declared in a class
template, that member has a dependent type (even if we can see the definition
of the member of the primary template), because the array size could change in
a member specialization.

Patch by Karthik Bhat!

llvm-svn: 194740
2013-11-14 22:40:45 +00:00
Joey Gouly 561bba2e9f [OpenCL] Make sure we put string literals in the constant address space.
llvm-svn: 194717
2013-11-14 18:26:10 +00:00
Serge Pavlov 3cb8022849 Added warning on structures/unions that are empty or contain only
bit fields of zero size. Warnings are generated in C++ mode and if
only such type is defined inside extern "C" block.
The patch fixed PR5065.

Differential Revision: http://llvm-reviews.chandlerc.com/D2151

llvm-svn: 194653
2013-11-14 02:13:03 +00:00
Warren Hunt 486e71460d No functional change. Renaming a variable in RecordLayoutBuilder and
improving comments to make documentation more accurate.

Differential Revision:http://llvm-reviews.chandlerc.com/D2172

llvm-svn: 194609
2013-11-13 22:16:13 +00:00
Robert Lytton eaf6f36e6d XCore target requires preferred alignment.
The xcore llvm backend does not handle 8 byte alignment viz:
  "%BadAlignment = alloca i64, align 8"
So getPreferredTypeAlign() must never overalign.

llvm-svn: 194462
2013-11-12 10:09:34 +00:00
Reid Kleckner a5eef14eba -fms-compatibility: Use C++98 null pointer constant rules
Patch by Will Wilson!

llvm-svn: 194441
2013-11-12 02:22:34 +00:00
Benjamin Kramer eed8061b9f Avoid double StringMap lookups. No functionality change.
llvm-svn: 194355
2013-11-10 16:55:11 +00:00
Benjamin Kramer 70e2e17872 CommentSema: Factor code better. No functionality change.
llvm-svn: 194354
2013-11-10 16:26:43 +00:00
Reid Kleckner 5bc6d0fbe4 Make -fdump-vtable-layouts print to stdout, not stderr
This makes it consistent with -fdump-record-layouts, which was moved to
outs() in r186219.  My reasoning for going with stdout is that when one
of these options is present, the layouts are really a program output,
and shouldn't be interleaved with diagnostics, which are on stderr.

Reviewers: timurrrr

Differential Revision: http://llvm-reviews.chandlerc.com/D2127

llvm-svn: 194279
2013-11-08 21:28:00 +00:00
Timur Iskhodzhanov 2c9341f979 Thread the info about vbptr sharing through ASTRecordLayout
Reviewed at http://llvm-reviews.chandlerc.com/D2120

llvm-svn: 194256
2013-11-08 11:45:35 +00:00
Richard Smith 9ff62af3aa PR17615: A delegating constructor initializer is a full-expression. Don't
forget to clean up temporaries at the end of it.

llvm-svn: 194213
2013-11-07 18:45:03 +00:00
Timur Iskhodzhanov 9e7f505515 Minor refinement of VTableBuilder.h: fix wrong indentation, rename a struct field with a more appropriate name
llvm-svn: 194202
2013-11-07 13:34:02 +00:00
David Majnemer bed356a9ea [-fms-extensions] Add support for __FUNCDNAME__
Summary:
Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled
function name via __FUNCDNAME__.  This implementation is very naive and
unoptimized, it is expected that __FUNCDNAME__ would be used rarely in
practice.

Reviewers: rnk, rsmith, thakis

CC: cfe-commits, silvas

Differential Revision: http://llvm-reviews.chandlerc.com/D2109

llvm-svn: 194181
2013-11-06 23:31:56 +00:00
Aaron Ballman f682f53012 Silencing some MSVC warnings about not all control paths returning a value when they actually do.
llvm-svn: 194156
2013-11-06 18:15:02 +00:00
Timur Iskhodzhanov 053142a90d Fix PR17738 - add support for vtordisp thunks when using -cxx-abi microsoft
llvm-svn: 194132
2013-11-06 06:24:31 +00:00
Richard Smith 4e66f1faa1 More constant evaluation cleanup, and fix an issue where we'd override an
earlier 'non-constant' diagnostic with a later one if the earlier one was from
a side-effect we thought we could evaluate past.

llvm-svn: 194117
2013-11-06 02:19:10 +00:00
Warren Hunt 6b7048ddd8 Microsoft adds weird padding before virtual bases if the last field was a bitfield
This patch adds the same behavior to clang.

Differential Revision: http://llvm-reviews.chandlerc.com/D2103

llvm-svn: 194115
2013-11-06 00:54:59 +00:00
Peter Collingbourne b23b39da21 Introduce DynTypedNode::print, dump and getSourceRange.
These functions can generally be applied to multiple kinds of AST node,
so it makes sense to add them to DynTypedNode.

Differential Revision: http://llvm-reviews.chandlerc.com/D2096

llvm-svn: 194113
2013-11-06 00:27:12 +00:00
Richard Smith e9ff770f8b Simplify: we don't care why constant evaluation might have failed when we're
checking an expression for constant overflow.

llvm-svn: 194099
2013-11-05 22:23:30 +00:00
Richard Smith 6d4c6586c9 Refactor constant expression handling and make a couple of tweaks to make it a
bit more robust against future changes. This includes a slight diagnostic
improvement: if we know we're only trying to form a constant expression, take
the first diagnostic which shows the expression is not a constant expression,
rather than preferring the first one which makes the expression unfoldable.

llvm-svn: 194098
2013-11-05 22:18:15 +00:00
Timur Iskhodzhanov 5877663622 Fix vbtable indices when a class shares the vbptr with a non-virtual base
llvm-svn: 194082
2013-11-05 15:54:58 +00:00
Richard Smith b47c36f8e1 C++1y sized deallocation: if we have a use, but not a definition, of a sized
deallocation function (and the corresponding unsized deallocation function has
been declared), emit a weak discardable definition of the function that
forwards to the corresponding unsized deallocation.

This allows a C++ standard library implementation to provide both a sized and
an unsized deallocation function, where the unsized one does not just call the
sized one, for instance by putting both in the same object file within an
archive.

llvm-svn: 194055
2013-11-05 09:12:18 +00:00
Richard Smith 8b86f2d401 Implement final resolution of DR1402: implicitly-declared move operators that
would be deleted are still declared, but are ignored by overload resolution.

Also, don't delete such members if a subobject has no corresponding move
operation and a non-trivial copy. This causes us to implicitly declare move
operations in more cases, but risks move-assigning virtual bases multiple
times in some circumstances (a warning for that is to follow).

llvm-svn: 193969
2013-11-04 01:48:18 +00:00
David Majnemer 42350dfcc8 Sema: Do not allow overloading between methods based on restrict
If the sole distinction between two declarations is that one has a
__restrict qualifier then we should not consider it to be an overload.

Instead, we will consider it as an incompatible redeclaration which is
similar to how MSVC, ICC and GCC would handle it.

This fixes PR17786.

N.B. We must not mangle in __restrict into method qualifiers becase we
don't allow overloading between such declarations anymore.  To do
otherwise would be a violation of the Itanium ABI.

llvm-svn: 193964
2013-11-03 23:51:28 +00:00
Bob Wilson 2c82c3d033 OS X 10.9+ and iOS 7+ support load/store of big atomic objects.
rdar://13973577

Patch by Fariborz Jahanian.

llvm-svn: 193935
2013-11-02 23:27:49 +00:00
Warren Hunt 5ae586ad45 Improves compatibility with cl.exe when laying out array fields
Differential Revision: http://llvm-reviews.chandlerc.com/D2090

Clang was "improperly" over-aligning arrays with sizes are not a multiple of 
their alignment. 
This behavior was removed in microsoft 32 bit mode.

In addition, after examination of ASTContext::getTypeInfoImpl, a redundant code block in 
MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo was deleted.

llvm-svn: 193898
2013-11-01 23:59:41 +00:00
Warren Hunt 445d83eb47 Wraps lazily generated builtins in an extern "C" context
Differential Revision: http://llvm-reviews.chandlerc.com/D2082

Adds a lang_c LinkageSpecDecl to lazily generated builtins. This enforces correct 
behavior for builtins in a variety of cases without special treatment elsewhere within 
the compiler (special treatment is removed by the patch). It also allows for C++ 
overloads of builtin functions, which Microsoft uses in their headers e.g. 
_InterlockedExchangeAdd is an extern C builtin for the long type but an inline wrapper 
for int type.

llvm-svn: 193896
2013-11-01 23:46:51 +00:00
Timur Iskhodzhanov 0201432a5e Make thunk this/return adjustment ABI-specific. Also, fix the return adjustment when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D2026

llvm-svn: 193679
2013-10-30 11:55:43 +00:00
Timur Iskhodzhanov 66f4381b39 Fix an assertion when handling a custom case of virtual inheritance; also reduce code duplication
llvm-svn: 193610
2013-10-29 14:13:45 +00:00
Fariborz Jahanian 5e3429c395 ObjectiveC: under -Wunused-property-ivar warn if property's
backing warning is not used in one of its accessor methods.
// rdar://14989999

llvm-svn: 193439
2013-10-25 21:44:50 +00:00
Benjamin Kramer 273670aaaa Remove dead variables.
llvm-svn: 193395
2013-10-25 07:40:50 +00:00
Benjamin Kramer e90c975dbc Remove dead recursive function.
llvm-svn: 193313
2013-10-24 07:39:30 +00:00
Warren Hunt 55d8e82f86 Implements 64 bit microsoft record layout and adds lit tests to cover
it.  Also removes all of the microsoft C++ ABI related code from the 
itanium layout builder.

Differential Revision: http://llvm-reviews.chandlerc.com/D2003

llvm-svn: 193290
2013-10-23 23:53:07 +00:00
David Majnemer 0eb8bbdeab AST: Mangle fields in anonymous structs/unions
The Itanium mangler couldn't cope with mangling an IndirectFieldDecl.
Instead, mangle the field the IndirectFieldDecl refers to.

Further, give IndirectFieldDecl no linkage just like FieldDecl.

N.B. Decl.cpp:getLVForNamespaceScopeDecl tried to calculate linkage for
data members of anonymous structs/unions.  However, this seems
impossible so turn it into an assertion.

llvm-svn: 193269
2013-10-23 20:52:43 +00:00
Faisal Vali c1a6dc4907 Refactor out the circular reference to LambdaExpr in CXXRecordDecl.
A prior commit of this patch was reverted because it was within the blamelist's purview of a failing test.  The failure of that test has been addressed here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131021/091546.html.  Therefore I am recommitting this patch (all tests pass on windows, except for the usual modules & index suspects that never pass on my box).

Some background: Both Doug and Richard had asked me in Chicago to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl.
 
In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. 

No change in functionality.

This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): 
http://llvm-reviews.chandlerc.com/D1856

Thanks!

llvm-svn: 193246
2013-10-23 16:10:50 +00:00
Rafael Espindola 09b00e34fa Revert r193223 and r193216.
They were causing CodeGenCXX/mangle-exprs.cpp to fail.

Revert "Remove the circular reference to LambdaExpr in CXXRecordDecl."

Revert "Again: Teach TreeTransform and family how to transform generic lambdas nested within templates and themselves."

llvm-svn: 193226
2013-10-23 04:12:23 +00:00
Faisal Vali 632fba3cb2 Remove the circular reference to LambdaExpr in CXXRecordDecl.
Both Doug and Richard had asked me to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl.

No change in functionality. 

In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. 

This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): 
http://llvm-reviews.chandlerc.com/D1856

Thanks!

llvm-svn: 193223
2013-10-23 02:59:27 +00:00
Richard Smith 15fc7df535 Teach AST dumper to dump the containing module and hidden flag for declarations.
llvm-svn: 193210
2013-10-22 23:50:38 +00:00
Rafael Espindola d53ffa0a70 Treat aliases as definitions.
This fixes pr17639.

Before this patch clang would consider

void foo(void) __attribute((alias("__foo")));

a declaration. It now correctly handles it as a definition.

Initial patch by Alp Toker. I added support for variables.

llvm-svn: 193200
2013-10-22 21:39:03 +00:00
Timur Iskhodzhanov 8b14242fe5 Drop the unneeded VBase field from MethodInfo in the VFTableBuilder class
llvm-svn: 193164
2013-10-22 14:50:20 +00:00
Rafael Espindola 7b56f6c3c2 Simplify some implementations of get*Decl.
* NamedDecl and CXXMethodDecl were missing getMostRecentDecl.
* The const version can just forward to the non const.
* getMostRecentDecl can use cast instead of cast_or_null.

This then removes some casts from the callers.

llvm-svn: 193039
2013-10-19 16:55:03 +00:00
Rafael Espindola cb444fe739 Reduce indentation with an early exit.
llvm-svn: 193028
2013-10-19 02:28:17 +00:00
Rafael Espindola 3f9e4442c8 Add isFirstDecl to DecBase too and use it instead of getPreviousDecl() == 0.
Redeclarable already had a isFirstDecl, but it was missing from DeclBase.

llvm-svn: 193027
2013-10-19 02:13:21 +00:00
Rafael Espindola 4450301eaf Simplify FunctionDecl::getBody.
llvm-svn: 193025
2013-10-19 01:37:17 +00:00
Richard Smith 77c5bb5e4a Fix 80-column violation.
llvm-svn: 192937
2013-10-18 01:34:56 +00:00
David Majnemer a543308ce5 [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for 'final'
Summary: Some MS headers use these features.

Reviewers: rnk, rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1948

llvm-svn: 192936
2013-10-18 00:33:31 +00:00
Rafael Espindola 8db352d532 Rename some functions for consistency.
Every other function in Redeclarable.h was using Decl instead of Declaration.

llvm-svn: 192900
2013-10-17 15:37:26 +00:00
Timur Iskhodzhanov 62082b7e0b [-cxx-abi microsoft] Fix this argument/parameter offsets for virtual destructors in the presence of virtual bases
Reviewed at http://llvm-reviews.chandlerc.com/D1939

llvm-svn: 192822
2013-10-16 18:24:06 +00:00
Rafael Espindola 002667c32b On 32 bit windows, mangle stdcall and fastcall decls in clang.
This removes the dependency on the llvm mangler doing it for us. In isolation,
the benefit is that the testing of what mangling is applied is all in one place:
(C, C++) X (Itanium, Microsoft) are all handled by clang.

This also gives me hope that in the future the llvm mangler (and llvm-ar) will
not depend on TargetMachine.

llvm-svn: 192762
2013-10-16 01:40:34 +00:00
Richard Smith 71bec06c36 Teach the AST dumper to dump the canonical declaration for a mergeable declaration.
llvm-svn: 192739
2013-10-15 21:58:30 +00:00
Richard Smith ea3019d23a Add constant evaluation support for __builtin_isinf, __builtin_isfinite,
__builtin_isnan, and __builtin_isnormal. Patch by Karthik Bhat! Tests by me.

llvm-svn: 192729
2013-10-15 19:07:14 +00:00
Reid Kleckner 916ac4d233 ms-compat: Fix taking the address of a member of a dependent base
If unqualified id lookup fails while parsing a class template with a
dependent base, clang with -fms-compatibility will pretend the user
prefixed the name with 'this->' in order to delay the lookup.  However,
if there was a unary ampersand, Sema::ActOnDependentIdExpression() will
create a DependentDeclRefExpr, which is not what we wanted at all.  Fix
this by building the CXXDependentScopeMemberExpr directly instead.

In order to be fully MSVC compatible, we would have to defer all
attempts at name lookup to instantiation time.  However, until we have
real problems with system headers that can't be parsed, we'll put off
implementing that.

Fixes PR16014.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1892

llvm-svn: 192727
2013-10-15 18:38:02 +00:00
Richard Smith e952106164 Correctly skip type sugar when determining the width of an enum type. Derived
from a patch by Justin Bogner.

llvm-svn: 192671
2013-10-15 04:56:17 +00:00
Reid Kleckner bd5bd4b36a PR17576: Fix assertion on polymorphic classes with small alignment
We have to reserve at least the width of a pointer for the vfptr.  For
classes with small alignment, we weren't reserving enough space, and
were overlapping the first field with the vfptr.

llvm-svn: 192626
2013-10-14 21:14:05 +00:00
Warren Hunt 42be77672a Correctly check for distructors when realizing vtordisps
This patch fixes the distructor test when checking for vtordisp requirements in 
microsoft record layout.  A test case is also included.

Addresses:
http://llvm.org/bugs/show_bug.cgi?id=16406#c7

llvm-svn: 192616
2013-10-14 20:14:09 +00:00
Benjamin Kramer 9f8e2d77c1 Reduce double set lookups by using the result of insert.
No functionality change.

llvm-svn: 192598
2013-10-14 15:16:10 +00:00
Reid Kleckner 4c42732cf8 Only use the MS record layout when using the MS C++ ABI
We're not ready to use it everywhere we use a win32 triple yet.

llvm-svn: 192502
2013-10-11 21:10:11 +00:00
Reid Kleckner f5370dddff Fix unused variable warning in MS record layout.
llvm-svn: 192495
2013-10-11 20:41:08 +00:00
Warren Hunt 8f8bad723d Adds Microsoft compatiable C++ record layout code to clang.
llvm-svn: 192494
2013-10-11 20:19:00 +00:00
Ted Kremenek e65ab9e80e Fix getIntegerTypeOrder() to properly handle enums by first unwrapping their underlying integer type. This is a precondition for calling getIntegerRank().
Fixes an assertion failure in a test case involving vectors.

Fixes <rdar://problem/15091442>

Please somebody check this.

llvm-svn: 192334
2013-10-10 00:54:01 +00:00
Sean Callanan c665c9ecf4 This patch addresses a problem encountered by the
ASTImporter when importing the following types:

typedef struct {
} A;

typedef struct {
  A a;
} B;

Suppose we have imported B, but we did not at that
time need to complete it.  Then later we want to
import A.  The struct is anonymous, so the first
thing we want to do is make sure no other anonymous
struct already matches it.  So we set up an
StructuralEquivalenceContext and compare B with A.

This happens at ASTImporter.cpp:2179.

Now, in this scenario, B is not complete.  So we go
and import its fields, including a, which causes A
to be imported.  The ASTImporter doesn’t yet have A
in its list of already-imported things, so we
import A.

After the StructuralEquivalenceContext is finished
determining that A and B are different, the
ASTImporter concludes that A must be imported
because no equivalent exists, so it imports a second
copy of A.  Now we have two different structs
representing A.  This is really bad news.

The patch allows the StructuralEquivalenceContext to
use the original version of B when making its
comparison, obviating the need for an import and
cutting this loop.

llvm-svn: 192324
2013-10-09 21:45:11 +00:00
Fariborz Jahanian de557f84dd ObjectiveC migrator. Introduce a new print policy for
suppression of strong lifetime qualifiers when
inferring property. // rdar://15082812

llvm-svn: 192305
2013-10-09 17:37:28 +00:00
Timur Iskhodzhanov e1ebc5fb66 Code cleanup: rename VTableContext to ItaniumVTableContext, VTableBuilder to ItaniumVTableBuilder and clang-format code around
llvm-svn: 192288
2013-10-09 11:33:51 +00:00
Timur Iskhodzhanov ad9d3b8fd1 Reland 192220 "Abstract out parts of thunk emission code, add support for simple thunks when using -cxx-abi microsoft" with relaxed assertions
llvm-svn: 192285
2013-10-09 09:23:58 +00:00
Timur Iskhodzhanov c7113073dd Revert 192220 as it fails on an assertion
llvm-svn: 192225
2013-10-08 20:09:50 +00:00
Timur Iskhodzhanov 1ffb3916ce Abstract out parts of thunk emission code, add support for simple thunks when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D1787

llvm-svn: 192220
2013-10-08 19:15:38 +00:00
Benjamin Kramer 3b05e20031 Fix an edge case in the template differ with default arguments.
In the test case one type is coming from a typedef with no default arg, the
other has the default arg. Taking the default arg from the typedef crashes, so
always use the real template paramter declaration. PR17510.

llvm-svn: 192202
2013-10-08 16:58:52 +00:00
Faisal Vali d2598e97a4 Fix linkage calculation of auto member functions returning lambdas
As described by Richard in https://groups.google.com/a/isocpp.org/d/msg/std-discussion/S1kmj0wF5-g/fb6agEYoL2IJ

we should allow:

template<typename S>
struct A {

template<typename T> static auto default_lambda() {
  return [](const T&) { return 42; };
}

template<class U = decltype(default_lambda<S>())>
  U func(U u = default_lambda<S>()) { return u; }

};

int run2 = A<double>{}.func()(3.14);

int run3 = A<char>{}.func()('a');

This patch allows the code using the same trickery that was used to allow the code in non-member functions at namespace scope.


Please see http://llvm-reviews.chandlerc.com/D1844 for richard's approval.

llvm-svn: 192166
2013-10-08 04:15:04 +00:00
Reid Kleckner 9a7f3e61a9 [ms-cxxabi] Fix the calling convention for operator new in records
Summary:
Operator new, new[], delete, and delete[] are all implicitly static when
declared inside a record.  CXXMethodDecl already knows this, but we need
to account for that before we pick the calling convention for the
function type.

Fixes PR17371.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1761

llvm-svn: 192150
2013-10-08 00:58:57 +00:00
Richard Smith fee2c8d814 Remove -ast-dump-xml.
llvm-svn: 192131
2013-10-07 20:56:34 +00:00
Richard Smith 0b87e0739e When merging class definitions across modules in C++, merge together fields.
This change doesn't go all the way to making fields redeclarable; instead, it
makes them 'mergeable', which means we can find the canonical declaration, but
not much else (and for a declaration that's not from a module, the canonical
declaration is always that declaration).

llvm-svn: 192092
2013-10-07 08:02:11 +00:00
Timur Iskhodzhanov 20df98c0d0 Fix PR17382 - properly group virtual method overloads in the vftable
llvm-svn: 192067
2013-10-06 15:31:37 +00:00
Timur Iskhodzhanov 555a7727c1 Simplify MicrosoftCXXNameMangler::mangleFunctionType
llvm-svn: 191950
2013-10-04 11:25:05 +00:00
Timur Iskhodzhanov 6745522f89 Extract ABI-specific parts of MangleContext into separate classes
Reviewed at http://llvm-reviews.chandlerc.com/D1807

llvm-svn: 191878
2013-10-03 06:26:13 +00:00
Alexey Bataev d5af8e472d [OpenMP] Added parsing and semantic analysis for firstprivate clause
llvm-svn: 191730
2013-10-01 05:32:34 +00:00
Faisal Vali 49b4c1f0c8 Fix computation of linkage within nested lambdas.
When nested C++11 lambdas are used in NSDMI's - this patch prevents infinite recursion by computing the linkage of any nested lambda by determining the linkage of the outermost enclosing lambda (which might inherit its linkage from its parent).

See http://llvm-reviews.chandlerc.com/D1783 for Doug's approval.

[On a related note, I need this patch so as to pass tests of transformations of nested lambdas returned from member functions]

llvm-svn: 191727
2013-10-01 02:51:53 +00:00
Eli Friedman 4a962f03be Tweak changes in r186464 to avoid a crash.
Currently, IR generation can't handle file-scope compound literals with
non-constant initializers in C++.

Fixes PR17415 (the first crash in the bug).

(We should probably change (T){1,2,3} to use the same codepath as T{1,2,3} in
C++ eventually, given that the semantics of the latter are actually defined by
the standard.)

llvm-svn: 191719
2013-10-01 00:28:29 +00:00
Faisal Vali 98b8e18379 Revert the linkage fix.
I got a bunch of buildbot failures that i don't understand - sorry.

llvm-svn: 191647
2013-09-29 20:27:06 +00:00
Faisal Vali db29268b10 Fix computation of linkage within nested lambdas.
When nested lambdas are used in NSDMI's - this prevents infinite recursion.

See http://llvm-reviews.chandlerc.com/D1783 for Doug's approval regarding the code, and then request for some tests.

[On a related note, I need this patch so as to pass tests of transformations of nested lambdas returned from member functions]

llvm-svn: 191645
2013-09-29 20:00:15 +00:00
Faisal Vali 850da1a3a2 Fix windows newlines :(
llvm-svn: 191641
2013-09-29 17:08:32 +00:00
Faisal Vali 571df12581 Implement conversion to function pointer for generic lambdas without captures.
The general strategy is to create template versions of the conversion function and static invoker and then during template argument deduction of the conversion function, create the corresponding call-operator and static invoker specializations, and when the conversion function is marked referenced generate the body of the conversion function using the corresponding static-invoker specialization.  Similarly, Codegen does something similar - when asked to emit the IR for a specialized static invoker of a generic lambda, it forwards emission to the corresponding call operator. 

This patch has been reviewed in person both by Doug and Richard.  Richard gave me the LGTM.

A few minor changes:
  - per Richard's request i added a simple check to gracefully inform that captures (init, explicit or default) have not been added to generic lambdas just yet (instead of the assertion violation).
  - I removed a few lines of code that added the call operators instantiated parameters to the currentinstantiationscope. Not only did it not handle parameter packs, but it is more relevant in the patch for nested lambdas which will follow this one, and fix that problem more comprehensively.
  - Doug had commented that the original implementation strategy of using the TypeSourceInfo of the call operator to create the static-invoker was flawed and allowed const as a member qualifier to creep into the type of the static-invoker.  I currently kludge around it - but after my initial discussion with Doug, with a follow up session with Richard, I have added a FIXME so that a more elegant solution that involves the use of TrivialTypeSourceInfo call followed by the correct wiring of the template parameters to the functionprototypeloc is forthcoming.

Thanks! 
 

llvm-svn: 191634
2013-09-29 08:45:24 +00:00
Richard Smith 1cdec019e8 Implement C++1y sized deallocation (n3778). This is not enabled by -std=c++1y;
instead, it's enabled by the -cc1 flag -fsized-deallocation, until we sort out
the backward-compatibility issues.

llvm-svn: 191629
2013-09-29 04:40:38 +00:00
Benjamin Kramer 20c28bebf9 Refactor comment merging.
- We scan for whitespace between comments anyways, remember any newlines seen
  along the way.
- Use this newline number to decide whether two comments are adjacent.
- Since the newline check is now free remove the caching and unused code.
- Remove unnecessary boolean state from the comment list.
- No behavioral change.

llvm-svn: 191614
2013-09-28 15:06:27 +00:00
Richard Smith bb13c9a49d Per latest drafting, switch to implementing init-captures as if by declaring
and capturing a variable declaration, and complete the implementation of them.

llvm-svn: 191605
2013-09-28 04:02:39 +00:00
Richard Smith 8809a0c95e Variable templates: handle instantiation of static data member templates
appropriately, especially when they appear within class templates.

llvm-svn: 191548
2013-09-27 20:14:12 +00:00
Timur Iskhodzhanov 8b5987eba5 Abstract out the emission of vtables, add basic support for vtable emission when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D1532

llvm-svn: 191523
2013-09-27 14:48:01 +00:00
David Majnemer 68c880b5f9 AST: Handle multidimensional arrays inside of __uuidof()
We previously handled one-dimensional arrays but didn't consider the
general case.  The fix is simple: keep going through subsequent
dimensions until we get to the base element.

llvm-svn: 191493
2013-09-27 07:57:34 +00:00
David Majnemer 143c55ead2 AST: Handle qualified array types in typeid() expressions
The intent of getTypeOperand() was to yield an unqualified type.
However QualType::getUnqualifiedType() does not strip away qualifiers on
arrays.

N.B.  This worked fine when typeid() was applied to an expression
because we would inject as implicit cast to the unqualified array type
in the AST.

llvm-svn: 191487
2013-09-27 07:04:31 +00:00
Faisal Vali 2b391ab708 Implement a rudimentary form of generic lambdas.
Specifically, the following features are not included in this commit:
  - any sort of capturing within generic lambdas 
  - generic lambdas within template functions and nested 
    within other generic lambdas
  - conversion operator for captureless lambdas
  - ensuring all visitors are generic lambda aware
  (Although I have gotten some useful feedback on my patches of the above and will be incorporating that as I submit those patches for commit)

As an example of what compiles through this commit:

template <class F1, class F2>
struct overload : F1, F2 {
    using F1::operator();
    using F2::operator();
    overload(F1 f1, F2 f2) : F1(f1), F2(f2) { }
  };

  auto Recursive = [](auto Self, auto h, auto ... rest) {
    return 1 + Self(Self, rest...);
  };
  auto Base = [](auto Self, auto h) {
      return 1;
  };
  overload<decltype(Base), decltype(Recursive)> O(Base, Recursive);
  int num_params =  O(O, 5, 3, "abc", 3.14, 'a');

Please see attached tests for more examples.

This patch has been reviewed by Doug and Richard.  Minor changes (non-functionality affecting) have been made since both of them formally looked at it, but the changes involve removal of supernumerary return type deduction changes (since they are now redundant, with richard having committed a recent patch to address return type deduction for C++11 lambdas using C++14 semantics). 



Some implementation notes:

  - Add a new Declarator context => LambdaExprParameterContext to 
    clang::Declarator to allow the use of 'auto' in declaring generic
    lambda parameters
      
  - Add various helpers to CXXRecordDecl to facilitate identifying
    and querying a closure class
  
  - LambdaScopeInfo (which maintains the current lambda's Sema state)
    was augmented to house the current depth of the template being
    parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth)
    so that SemaType.cpp::ConvertDeclSpecToType may use it to immediately 
    generate a template-parameter-type when 'auto' is parsed in a generic
    lambda parameter context.  (i.e we do NOT use AutoType deduced to 
    a template parameter type - Richard seemed ok with this approach).  
    We encode that this template type was generated from an auto by simply
    adding $auto to the name which can be used for better diagnostics if needed.

  - SemaLambda.h was added to hold some common lambda utility
    functions (this file is likely to grow ...)
    
  - Teach Sema::ActOnStartOfFunctionDef to check whether it
    is being called to instantiate a generic lambda's call
    operator, and if so, push an appropriately prepared
    LambdaScopeInfo object on the stack.
    
  - various tests were added - but much more will be needed.

There is obviously more work to be done, and both Richard (weakly) and Doug (strongly) 
have requested that LambdaExpr be removed form the CXXRecordDecl LambdaDefinitionaData
in a future patch which is forthcoming.

A greatful thanks to all reviewers including Eli Friedman, James Dennett, 
and especially the two gracious wizards (Richard Smith and Doug Gregor) 
who spent hours providing feedback (in person in Chicago and on the mailing lists).  
And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified!

Thanks!

llvm-svn: 191453
2013-09-26 19:54:12 +00:00
Alexey Bataev 7d2960bd2a [OPENMP] Improved variable lookup procedure for threadprivate variables.
llvm-svn: 191416
2013-09-26 03:24:06 +00:00
Reid Kleckner c5cc338ab3 Remove unused param from MicrosoftMangle::mangleCallingConvention()
llvm-svn: 191405
2013-09-25 22:28:52 +00:00
Alexey Bataev 756c196f14 [OPENMP] Bug fixes and improvements.
1. Fixed constructor of shared clause.
2. Some macros for clauses processing are replaced by private template methods.
3. Additional checks in sema analysis of OpenMP clauses.

llvm-svn: 191265
2013-09-24 03:17:45 +00:00
Nick Lewycky e2b2caaded Fix comment to match name of variable.
llvm-svn: 191171
2013-09-22 10:07:22 +00:00
Hal Finkel c4d7c82c7f Add the intrinsic __builtin_convertvector
LLVM supports applying conversion instructions to vectors of the same number of
elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to
cause such instructions to be generated when using builtin vector types.

C-style casting on vectors is already defined in terms of bitcasts, and so
cannot be used for these conversions as well (without leading to a very
confusing set of semantics). As a result, this adds a __builtin_convertvector
intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is
intended to aid the creation of vector intrinsic headers that create generic IR
instead of target-dependent intrinsics (in other words, this is a generic
_mm_cvtepi32_ps). As noted in the documentation, the action of
__builtin_convertvector is defined in terms of the action of a C-style cast on
each vector element.

llvm-svn: 190915
2013-09-18 03:29:45 +00:00
Eli Friedman 1d24af872d Fix ObjC @encode for C++ classes w/virtual bases.
PR17142.

llvm-svn: 190912
2013-09-18 01:59:16 +00:00
Richard Smith d25789a671 -ast-dump support for variable templates.
llvm-svn: 190911
2013-09-18 01:36:02 +00:00
David Majnemer 50ce835ecb Revert "Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately""
This reverts commit r190895 which reverted r190892.

llvm-svn: 190904
2013-09-17 23:57:10 +00:00
David Majnemer 3775441379 Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately"
This reverts commit r190892.

llvm-svn: 190895
2013-09-17 22:45:28 +00:00
David Majnemer 1ebb145bdf [-cxx-abi microsoft] Mangle local TagDecls appropriately
Summary:
When selecting a mangling for an anonymous tag type:
- We should first try it's typedef'd name.
- If that doesn't work, we should mangle in the name of the declarator
  that specified it as a declaration specifier.
- If that doesn't work, fall back to a static mangling of
  <unnamed-type>.

This should make our anonymous type mangling compatible.

This partially fixes PR16994; we would need to have an implementation of
scope numbering to get it right (a separate issue).

Reviewers: rnk, rsmith, rjmccall, cdavis5x

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1540

llvm-svn: 190892
2013-09-17 22:21:27 +00:00
Eli Friedman 1409e6e7c6 Fix const-eval of vector init-lists of a vector.
Like any other type, an init list for a vector can have the same type as
the vector itself; handle that case.

<rdar://problem/14990460>

llvm-svn: 190844
2013-09-17 04:07:02 +00:00
David Majnemer c729b0b506 [-cxx-abi microsoft] Correctly identify Win32 entry points
Summary:
This fixes several issues with the original implementation:
- Win32 entry points cannot be in namespaces
- A Win32 entry point cannot be a function template, diagnose if we it.
- Win32 entry points cannot be overloaded.
- Win32 entry points implicitly return, similar to main.

Reviewers: rnk, rsmith, whunt, timurrrr

Reviewed By: rnk

CC: cfe-commits, nrieck

Differential Revision: http://llvm-reviews.chandlerc.com/D1683

llvm-svn: 190818
2013-09-16 22:44:20 +00:00
NAKAMURA Takumi c5d86153ed Prune "return" after llvm_unreachable(). It was redundant.
llvm-svn: 190774
2013-09-16 01:58:47 +00:00
Richard Smith 17e32460ed Part three of PR15721: if we have an invalid CXXDefaultInitExpr, don't crash if
we try to constant-evaluate it. Patch by Karthik Bhat, test by me.

llvm-svn: 190722
2013-09-13 20:51:45 +00:00
NAKAMURA Takumi 5c81ca460e ASTContext.cpp: Fix a warning in r190684. [-Wcovered-switch-default]
llvm-svn: 190705
2013-09-13 17:12:09 +00:00
David Tweed 4fd0234e54 A buildbot compiling with strict error on unused variables pointed out a
historical remnant in r190684; remove it.

llvm-svn: 190687
2013-09-13 12:51:05 +00:00
David Tweed 31d09b0cef Certain multi-platform languages, such as OpenCL, have the concept of
address spaces which is both (1) a "semantic" concept and
(2) possibly a hardware level restriction. It is desirable to
be able to discard/merge the LLVM-level address spaces on arguments for which
there is no difference to the current backend while keeping
track of the semantic address spaces in a funciton prototype. To do this
enable addition of the address space into the name-mangling process. Add
some tests to document this behaviour against inadvertent changes.

Patch by Michele Scandale!

llvm-svn: 190684
2013-09-13 12:04:22 +00:00
David Majnemer 9d0bb9d2ba [-cxx-abi microsoft] Mangle user defined entry points properly
Summary:
Functions named "main", "wmain", "WinMain", "wWinMain", and "DllMain"
are never mangled regardless of linkage, even when compiling for kernel
mode.
Depends on D1655

Reviewers: timurrrr, pcc, rnk, whunt

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1670

llvm-svn: 190675
2013-09-13 09:40:55 +00:00
David Majnemer d5a42b8b48 [-cxx-abi microsoft] Mangle declarations inside extern "C"
Summary:
This is a first step to getting extern "C" working properly inside
clang.  There are a number of quirks but mangling declarations inside
such a function are a good first step.

Reviewers: timurrrr, pcc, cdavis5x

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1655

llvm-svn: 190671
2013-09-13 09:03:14 +00:00
Argyrios Kyrtzidis 623ecfdba0 Fix the end-location of a CXXTemporaryObjectExpr when it is created with a initializer_list.
rdar://14887351

llvm-svn: 190561
2013-09-11 23:23:27 +00:00
Aaron Ballman 682ee42550 Tablegen now generates a StringSwitch for attributes containing enumeration arguments to map strings to the proper enumeration value. This makes error checking more consistent and reduces the amount of hand-written code required.
llvm-svn: 190545
2013-09-11 19:47:58 +00:00
David Majnemer 5a1b2045dc [-cxx-abi microsoft] Canonicalize array parameters better
Summary:
More accurately characterize the nature of array parameters. Doing this
removes false back-reference opportunities.  Remove some hacks now that
we characterize these better.

Reviewers: rnk, timurrrr, whunt, cdavis5x

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1626

llvm-svn: 190488
2013-09-11 04:44:30 +00:00
Eli Friedman aa76981400 volatile types are not trivially copyable.
PR17123.

llvm-svn: 190484
2013-09-11 03:49:34 +00:00
Eli Friedman dc41d791f9 Add unused markings to suppress warnings.
trunk clang is a bit more aggressive about emitting unused-declaration
warnings, so adjust some AST code to match.  Specifically, use
LLVM_ATTRIBUTE_UNUSED for declarations which are never supposed to be
referenced, and turn references to declarations which are supposed to be
referenced into odr-uses.

llvm-svn: 190443
2013-09-10 22:57:15 +00:00
Richard Smith 84c6b3d293 PR5683: Issue a warning when subtracting pointers to types of zero size, and
treat such subtractions as being non-constant. Patch by Serge Pavlov! With a
few tweaks by me.

llvm-svn: 190439
2013-09-10 21:34:14 +00:00
Reid Kleckner 1ece9fc806 [ms-cxxabi] Mangle dynamic initializer stubs the same way MSVC does
Summary: Dynamic initializers are mangled as ??__E <name> YAXXZ.

Reviewers: timurrrr

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1477

llvm-svn: 190434
2013-09-10 20:43:12 +00:00
Reid Kleckner d8110b6558 [ms-cxxabi] Implement guard variables for static initialization
Static locals requiring initialization are not thread safe on Windows.
Unfortunately, it's possible to create static locals that are actually
externally visible with inline functions and templates.  As a result, we
have to implement an initialization guard scheme that is compatible with
TUs built by MSVC, which makes thread safety prohibitively difficult.

MSVC's scheme is that every function that requires a guard gets an i32
bitfield.  Each static local is assigned a bit that indicates if it has
been initialized, up to 32 bits, at which point a new bitfield is
created.  MSVC rejects inline functions with more than 32 static locals,
and the externally visible mangling (?_B) only allows for one guard
variable per function.

On Eli's recommendation, I used MangleNumberingContext to track which
bit each static corresponds to.

Implements PR16888.

Reviewers: rjmccall, eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1416

llvm-svn: 190427
2013-09-10 20:14:30 +00:00
Richard Smith 4abe0a8d82 C++ modules: fix a bug where loading a declaration with some name would prevent
name lookup from lazily deserializing the other declarations with the same
name, by tracking a bit to indicate whether a name in a DeclContext might have
additional external results. This also allows lazier reconciling of the lookup
table if a module import adds decls to a pre-existing DC.

However, this exposes a pre-existing bug, which causes a regression in
test/Modules/decldef.mm: if we have a reference to a declaration, and a
later-imported module adds a redeclaration, nothing causes us to load that
redeclaration when we use or emit the reference (which can manifest as a
reference to an undefined inline function, a use of an incomplete type, and so
on). decldef.mm has been extended with an additional testcase which fails with
or without this change.

llvm-svn: 190293
2013-09-09 07:34:56 +00:00
David Majnemer 37c921e354 Correct typo.
llvm-svn: 190257
2013-09-07 20:21:47 +00:00
David Majnemer 5d22e7e4c3 'return' before 'else' is bad style
llvm-svn: 190241
2013-09-07 07:11:04 +00:00
David Majnemer 59c0ec2396 AST: __uuidof should leak through templated types
Summary:
__uuidof on templated types should exmaine if any of its template
parameters have a uuid declspec.  If exactly one does, then take it.
Otherwise, issue an appropriate error.

Reviewers: rsmith, thakis, rnk

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1419

llvm-svn: 190240
2013-09-07 06:59:46 +00:00
Enea Zaffanella 76e98feb57 Fix missing source location in CXXTemporaryObjectExpr nodes.
For clarity, renamed (get/set)ParenRange as (get/set)ParenOrBraceRange
in CXXConstructExpr nodes.
Added testcase.

llvm-svn: 190239
2013-09-07 05:49:53 +00:00
Alexey Bataev 758e55ee58 OpenMP: Data-sharing attributes analysis and clause 'shared' (fixed test threadprivate_messages.cpp)
llvm-svn: 190183
2013-09-06 18:03:48 +00:00
James Dennett 8f60cdd54b Mark lambda closure classes as being implicitly-generated.
Summary: Closure classes for C++ lambdas are always compiler-generated.  This one-line change calls setImplicit(true) on them at creation time, such that a default RecursiveASTVisitor (or any for which shouldVisitImplicitCode returns false) will skip them.

Reviewers: rsmith, dblaikie

Reviewed By: dblaikie

CC: klimek, revane, cfe-commits, jordan_rose

Differential Revision: http://llvm-reviews.chandlerc.com/D1593

llvm-svn: 190073
2013-09-05 17:46:21 +00:00
Stepan Dyatkovskiy 5a63792239 Add new methods for TargetInfo:
getRealTypeByWidth and getIntTypeByWidth
  for ASTContext names are almost same(invokes new methods from TargetInfo):
     getIntTypeForBitwidth and getRealTypeForBitwidth.

As first commit for PR16752 fix: 'mode' attribute for unusual targets doesn't work properly
Description:
Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp).
For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only.
Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct.
Please consider the next solution:
1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth virtual methods. By default current behaviour could be implemented here.
2. Fix handleModeAttr according to new methods in TargetInfo.
This approach is implemented in the patch attached to this post.

Fixes:
1st Commit (Current): Add new methods for TargetInfo:
     getRealTypeByWidth and getIntTypeByWidth
  for ASTContext names are almost same(invokes new methods from TargetInfo):
     getIntTypeForBitwidth and getRealTypeForBitwidth

2nd Commit (Next): Fix SemaDeclAttr, handleModeAttr function.

llvm-svn: 190044
2013-09-05 11:23:21 +00:00
Eli Friedman 276dd188c4 Note when a decl is used in AST files.
When an AST file is built based on another AST file, it can use a decl from
the fist file, and therefore mark the "isUsed" bit.  We need to note this in
the AST file so that the bit is set correctly when the second AST file is
loaded.

This patch introduces the distinction between setIsUsed() and markUsed() so
that we don't call into the ASTMutationListener callback when it wouldn't
be appropriate.

Fixes PR16635.

llvm-svn: 190016
2013-09-05 00:02:25 +00:00
Richard Smith 49a497fa6c PR17103: Scoped enumerations with signed integer types have signed integer
representation. Don't emit comparisons on them as 'icmp ult'!

llvm-svn: 190010
2013-09-04 23:34:21 +00:00
Pavel Labath 1ef8342e11 ASTDumper: fix dump of CXXCatchStmt
Summary: I added the display of the VarDecl contained in the statement.

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1596

llvm-svn: 189941
2013-09-04 14:35:00 +00:00
Pavel Labath 515f4db4f9 Remove useless reinterpret_casts from Stmt.cpp
Summary:
I have no idea why these were there in the first place, but now they are
certainly not necessary.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1581

llvm-svn: 189813
2013-09-03 14:41:16 +00:00
Rafael Espindola e892ccec0d Revert "OpenMP: Data-sharing attributes analysis and clause 'shared'"
This reverts commit r189795.

threadprivate_messages.cpp is faling on windows.

llvm-svn: 189811
2013-09-03 14:33:09 +00:00
Alexey Bataev d4183dabd7 OpenMP: Data-sharing attributes analysis and clause 'shared'
llvm-svn: 189795
2013-09-03 12:55:52 +00:00
Chandler Carruth b4a4326824 Mark that qualifiers can prefix the auto type. This seems to just have
been an oversight, as it definitely works. Every test which changed had
the const written on the LHS of the auto already.

Notably, this also makes things like cpp11-migrate's formation of 'const
auto &' variables much more familiar.

Yes, many people feel that 'const' and other qualifiers belong on the
RHS of the type. I'm not going to argue about that because Clang already
*overwhelming* places the qualifiers on the LHS when it can and on the
RHS when it must. We shouldn't diverge for auto. We should add a tool to
clang-tidy that fixes this in either direction, and then wire up
clang-tidy to tools like cpp11-migrate to fix their placement after
transforms.

llvm-svn: 189769
2013-09-02 19:20:06 +00:00
Richard Smith 99bc1b99d3 Mention in AST dump whether a class declaration is a definition.
llvm-svn: 189647
2013-08-30 05:32:29 +00:00
Richard Smith a4ba74c5f5 Don't eagerly load all conversion operators when loading a class declaration
from a PCH/module.

llvm-svn: 189646
2013-08-30 04:46:40 +00:00
Charles Davis b5a214e4f3 Add ms_abi and sysv_abi attribute handling.
Based on a patch by Benno Rice!

llvm-svn: 189644
2013-08-30 04:39:01 +00:00
Richard Smith 676c404dec Be lazier when loading KeyFunctions from PCH/modules. We don't need to load
these in eagerly if we're not actually processing a translation unit. The added
laziness here also avoids us loading in parts of a CXXRecordDecl earlier than an
upcoming class template specialization merging patch would like.

Ideally, we should mark the vtable as used when we see a definition for the key
function, rather than having a separate pass over dynamic classes at the end of
the TU. The existing approach is pretty bad for PCH/modules, since it forcibly
loads the declarations of all key functions in all imported modules, whether or
not those key functions are defined.

llvm-svn: 189627
2013-08-29 23:59:27 +00:00
Eli Friedman 0718591771 Adjust clang for change to APFloat::toString.
I changed the diagnostic printing code because it's probably better
to cut off a digit from DBL_MAX than to print something like
1.300000001 when the user wrote 1.3.

llvm-svn: 189625
2013-08-29 23:44:43 +00:00
David Majnemer 03f4ab7531 AST: Don't treat a TemplateExpansion as a Template
Summary:
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.

This fixes PR16997.

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1512

llvm-svn: 189422
2013-08-28 00:00:27 +00:00
Reid Kleckner 78af0708b7 Delete CC_Default and use the target default CC everywhere
Summary:
Makes functions with implicit calling convention compatible with
function types with a matching explicit calling convention.  This fixes
things like calls to qsort(), which has an explicit __cdecl attribute on
the comparator in Windows headers.

Clang will now infer the calling convention from the declarator.  There
are two cases when the CC must be adjusted during redeclaration:
1. When defining a non-inline static method.
2. When redeclaring a function with an implicit or mismatched
convention.

Fixes PR13457, and allows clang to compile CommandLine.cpp for the
Microsoft C++ ABI.

Excellent test cases provided by Alexander Zinenko!

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1231

llvm-svn: 189412
2013-08-27 23:08:25 +00:00
David Majnemer 08177c5053 [-cxx-abi microsoft] Remove ArgIndex, we handle all template argument kinds!
TemplateExpansion cannot happen here because MSVC doesn't mangle
anything but the fully substituted template arguments.

llvm-svn: 189325
2013-08-27 08:21:25 +00:00
Nick Lewycky a382db0293 Show which decls are marked invalid in -ast-dump.
llvm-svn: 189306
2013-08-27 03:15:56 +00:00
Richard Smith eb0133c112 Itanium mangler: remove "proposal" comments for manglings that are in the
latest draft of the ABI.

llvm-svn: 189303
2013-08-27 01:03:46 +00:00
Wei Pan 8d6b19a518 Handle predefined expression for a captured statement
- __func__ or __FUNCTION__ returns captured statement's parent
  function name, not the one compiler generated.

Differential Revision: http://llvm-reviews.chandlerc.com/D1491

Reviewed by bkramer

llvm-svn: 189219
2013-08-26 14:27:34 +00:00
Timur Iskhodzhanov f46993e40a Fix virtual destructor mangling when using "-cxx-abi microsoft" on x64
llvm-svn: 189214
2013-08-26 10:32:04 +00:00
David Majnemer a4778cc2f1 [-cxx-abi microsoft] Unnamed types are mangled less wrong
llvm-svn: 189208
2013-08-26 02:35:51 +00:00
Larisse Voufo 30616383ab A clean-up pass, exploring the unification of traversals of class, variable and function templates.
llvm-svn: 189152
2013-08-23 22:21:36 +00:00
Dmitri Gribenko 1e50cbf366 Comment parsing: fix a bug where a line with whitespace between two paragraphs
would cause us to concatenate these paragraphs into a single one.

The no-op whitespace churn in test/Index test happened because these tests
don't use the correct approach for testing and are more strict than required
for they are testing.

llvm-svn: 189126
2013-08-23 18:03:40 +00:00
Dmitri Gribenko 11f54e86bb Fix indentation
llvm-svn: 189119
2013-08-23 17:48:41 +00:00
Dmitri Gribenko db6adaba68 Use CharInfo.h routines in TextComment::isWhitespaceNoCache
llvm-svn: 189115
2013-08-23 17:45:43 +00:00
Robert Wilhelm 25284cc95b Use pop_back_val() instead of both back() and pop_back().
No functionality change intended.

llvm-svn: 189112
2013-08-23 16:11:15 +00:00
Richard Smith b2f61b4a05 Remove SequenceNumber from class/variable template partial specializations.
This was only used to ensure that the traversal order was the same as the
insertion order, but that guarantee was already being provided by the use
of a FoldingSetVector.

llvm-svn: 189075
2013-08-22 23:27:37 +00:00
Manuel Klimek 2fdbea2819 Revert "Implement a rudimentary form of generic lambdas."
This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7.

llvm-svn: 189004
2013-08-22 12:12:24 +00:00