Commit Graph

5036 Commits

Author SHA1 Message Date
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