Commit Graph

1067 Commits

Author SHA1 Message Date
Erik Pilkington 30526a0d0c Reapply r277058: "[ObjC] Consider availability of context when emitting availability warnings"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277175 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 17:37:38 +00:00
Erik Pilkington 1148c92bdb Revert "[ObjC] Consider availability of context when emitting availability warnings"
Reverting r277058, while I fugure out why it broke internal bots.

This reverts commit e514ffa8b6.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277070 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 22:51:11 +00:00
Erik Pilkington e514ffa8b6 [ObjC] Consider availability of context when emitting availability warnings
This means that a function marked with an availability attribute can safely
refer to a declaration that is greater than the deployment target, but less then
or equal to the context availability without -Wpartial-availability firing.

Differential revision: https://reviews.llvm.org/D22697

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277058 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 22:09:53 +00:00
Mehdi Amini 2e23251d3e [NFC] Header cleanup
Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

Differential Revision: https://reviews.llvm.org/D20100

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 19:02:11 +00:00
Aaron Ballman d1642265a7 Add XRay flags to Clang. We implement two flags to control the XRay behaviour:
-fxray-instrument: enables XRay annotation of IR
-fxray-instruction-threshold: configures the threshold for function size (looking at IR instructions), and allow LLVM to decide whether to add the nop sleds later on in the process.

Also implements the related xray_always_instrument and xray_never_instrument function attributes.

Patch by Dean Michael Berris.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275330 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 22:32:15 +00:00
Dmitry Polukhin 1b7c219dcc [GCC] PR23529 Mangler part of attrbute abi_tag support
Original patch by Stefan Bühler http://reviews.llvm.org/D12834

Difference between original and this one:
- fixed all failing tests
- fixed mangling for global variable outside namespace
- emit ABI tags for guards and local names
- clang-format + other stylistic changes
- significantly reworked patch according to Richard's suggestions

Sema part, committed before http://reviews.llvm.org/D17567

Differential revision: http://reviews.llvm.org/D18035

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274222 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 09:40:38 +00:00
Pirama Arumuga Nainar fd44536292 Revise RenderScript attribute declaration
Summary:
Address post-patch comments to r272342.

- Rename the 'kernel' attribute's name
- Idiomatically restrict the attribute to the 'RenderScript' LangOpt.

Reviewers: aaron.ballman, rsmith

Subscribers: cfe-commits, srhines

Differential Revision: http://reviews.llvm.org/D21240

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272438 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 21:51:18 +00:00
Nico Weber 0d3963456d Remove a few gendered pronouns.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272415 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 18:53:04 +00:00
Pirama Arumuga Nainar 1ba5b9cd94 RenderScript support in the Frontend
Summary:

Create a new Frontend LangOpt to specify the renderscript language. It
is enabled by the "-x renderscript" option from the driver.

Add a "kernel" function attribute only for RenderScript (an "ignored
attribute" warning is generated otherwise).

Make the NativeHalfType and NativeHalfArgsAndReturns LangOpts be implied
by the RenderScript LangOpt.

Reviewers: rsmith

Subscribers: cfe-commits, srhines

Differential Revision: http://reviews.llvm.org/D21198

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272342 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:34:20 +00:00
Artem Belevich e9331c36e8 [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.
Fixes clang crash reported in PR27778.

Differential Revision: http://reviews.llvm.org/D20985

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 22:54:57 +00:00
David Majnemer 6b373d1dab [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version)
The layout_version attribute is pretty straightforward: use the layout
rules from version XYZ of MSVC when used like
struct __declspec(layout_version(XYZ)) S {};

The empty_bases attribute is more interesting.  It tries to get the C++
empty base optimization to fire more often by tweaking the MSVC ABI
rules in subtle ways:
1. Disable the leading and trailing zero-sized object flags if a class
   is marked __declspec(empty_bases) and is empty.

   This means that given:
   struct __declspec(empty_bases) A {};
   struct __declspec(empty_bases) B {};
   struct C : A, B {};

   'C' will have size 1 and nvsize 0 despite not being annotated
   __declspec(empty_bases).

2. When laying out virtual or non-virtual bases, disable the injection
   of padding between classes if the most derived class is marked
   __declspec(empty_bases).

   This means that given:
   struct A {};
   struct B {};
   struct __declspec(empty_bases) C : A, B {};

   'C' will have size 1 and nvsize 0.

3. When calculating the offset of a non-virtual base, choose offset zero
   if the most derived class is marked __declspec(empty_bases) and the
   base is empty _and_ has an nvsize of 0.

   Because of the ABI rules, this does not mean that empty bases
   reliably get placed at offset 0!

   For example:
   struct A {};
   struct B {};
   struct __declspec(empty_bases) C : A, B { virtual ~C(); };

   'C' will be pointer sized to account for the vfptr at offset 0.
   'A' and 'B' will _not_ be at offset 0 despite being empty!
   Instead, they will be located right after the vfptr.

   This occurs due to the interaction betweeen non-virtual base layout
   and virtual function pointer injection: injection occurs after the
   nv-bases and shifts them down by the size of a pointer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270457 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 17:16:12 +00:00
Alexey Bataev e14f516c98 Support for MSVS default calling convention options (/Gd, /Gz, /Gv,
/Gr), by Alexander Makarov

Patch for bug #27711
Differential Revision: http://reviews.llvm.org/D20171

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269891 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 09:06:38 +00:00
Manman Ren ae16b820f9 Availability: set location when creating attribute for tvos, watchos.
When inferring availability attributes for tvos, watchos from ios, we
use the same source location and set the implicit bit to true.

So when emitting diagnostics on inferred attributes, we have a source
location.

rdar://25893544


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268793 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-06 21:04:01 +00:00
Manman Ren 99a5d7a278 Availability: attach the note to the declaration with the attributes.
Sometimes, the declaration we found has inherited availability
attributes, attaching the note to it does not tell us where the
availability attributes are in the source.

Go through the redecl chain to find the declaration with actual
availability attributes.

rdar://25221771


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268786 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-06 19:57:16 +00:00
Paul Robinson a5cff8c36d Add a Subjects line to NoDebugAttr [NFC].
The 'nodebug' attribute had hand-coded constraints; replace those with
a Subjects line in Attr.td.
Also add a missing test to verify the attribute is okay on an
Objective-C method.

Differential Revision: http://reviews.llvm.org/D19689


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268065 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-29 17:03:34 +00:00
Peter Collingbourne 5b0d0a6495 Re-apply r267784, r267824 and r267830.
I have updated the compiler-rt tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267903 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 17:09:37 +00:00
Benjamin Kramer ce850d4bf5 Revert r267784, r267824 and r267830.
It makes compiler-rt tests fail if the gold plugin is enabled.

Revert "Rework interface for bitset-using features to use a notion of LTO visibility."
Revert "Driver: only produce CFI -fvisibility= error when compiling."
Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi."

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267871 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 12:14:47 +00:00
Peter Collingbourne 47213cf975 Rework interface for bitset-using features to use a notion of LTO visibility.
Bitsets, and the compiler features they rely on (vtable opt, CFI),
only have visibility within the LTO'd part of the linkage unit. Therefore,
only enable these features for classes with hidden LTO visibility. This
notion is based on object file visibility or (on Windows)
dllimport/dllexport attributes.

We provide the [[clang::lto_visibility_public]] attribute to override the
compiler's LTO visibility inference in cases where the class is defined
in the non-LTO'd part of the linkage unit, or where the ABI supports
calling classes derived from abstract base classes with hidden visibility
in other linkage units (e.g. COM on Windows).

If the cross-DSO CFI mode is enabled, bitset checks are emitted even for
classes with public LTO visibility, as that mode uses a separate mechanism
to cause bitsets to be exported.

This mechanism replaces the whole-program-vtables blacklist, so remove the
-fwhole-program-vtables-blacklist flag.

Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the
support for the special attr:uuid blacklist entry is removed.

Differential Revision: http://reviews.llvm.org/D18635

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267784 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 20:39:53 +00:00
Dmitry Polukhin 1903a4e080 [GCC] Attribute ifunc support in clang
This patch add support for GCC attribute((ifunc("resolver"))) for
targets that use ELF as object file format. In general ifunc is a
special kind of function alias with type @gnu_indirect_function. LLVM
patch http://reviews.llvm.org/D15525

Differential Revision: http://reviews.llvm.org/D15524

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265917 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 07:48:59 +00:00
Douglas Gregor cf7bc8edf8 [Objective-C] Introduce objc_runtime_visible attribute.
The objc_runtime_visible attribute deals with an odd corner case where
a particular Objective-C class is known to the Objective-C runtime
(and, therefore, accessible by name) but its symbol has been hidden
for some reason. For such classes, teach CodeGen to use
objc_lookUpClass to retrieve the Class object, rather than referencing
the class symbol directly.

Classes annotated with objc_runtime_visible have two major limitations
that fall out from places where Objective-C metadata needs to refer to
the class (or metaclass) symbol directly:

* One cannot implement a subclass of an objc_runtime_visible class.
* One cannot implement a category on an objc_runtime_visible class.

Implements rdar://problem/25494092.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265201 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 23:23:52 +00:00
Anastasia Stulova c648b00b4f [OpenCL] Moved nosvm attribute handling in Sema to other OpenCL attrs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265146 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 16:05:09 +00:00
Anastasia Stulova f2ac35e313 [OpenCL] Added nosvm attribute for OpenCL v2.0.
It is not widely used and removed from OpenCL v2.1.

This change modifies Clang to parse the attribute for OpenCL
but ignores it afterwards.

Patch by Liu Yaxun (Sam)!

Differential Revision: http://reviews.llvm.org/D17861



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265006 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 11:07:22 +00:00
Manman Ren 77012dd049 Add replacement = "xxx" to AvailabilityAttr.
This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)).

This was commited in r263687 and reverted in 263752 due to misaligned
access.

rdar://20588929


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263958 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21 17:30:55 +00:00
Manman Ren e93a96965b Revert r263687 for ubsan bot failure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263752 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 22:13:50 +00:00
Manman Ren 6e7a77e077 Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)). This enables the
compiler to provide Fix-Its for deprecated declarations.

rdar://20588929


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263687 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 03:09:55 +00:00
Manman Ren 081f300e64 Add an optional string argument to DeprecatedAttr for Fix-It.
We only add this to __attribute__((deprecated)).

Differential Revision: http://reviews.llvm.org/D17865


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263652 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 18:50:49 +00:00
Roman Levenstein 5e8bd88711 Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end
Till now, preserve_mostcc/preserve_allcc calling convention attributes were only
available at the LLVM IR level. This patch adds attributes for
preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.

The code was mostly written by Juergen Ributzka.
I just added support for the AArch64 target and tests.

Differential Revision: http://reviews.llvm.org/D18025

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 18:00:46 +00:00
Aaron Ballman ba9f6803ce Implement support for [[maybe_unused]] in C++1z that is based off existing support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-09 16:48:08 +00:00
Dmitry Polukhin 707118c24c [GCC] PR23529 Sema part of attrbute abi_tag support
Original patch by Stefan Bühler http://reviews.llvm.org/D12834

Difference between original and this one:
- fixed all comments in original code review
- added more tests, all new diagnostics now covered by tests
- moved abi_tag on re-declaration checks to Sema::mergeDeclAttributes
  where they actually may work as designed
- clang-format + other stylistic changes

Mangle part will be sent for review as a separate patch.

Differential Revision: http://reviews.llvm.org/D17567

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263015 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-09 15:30:53 +00:00
Richard Smith 14b538d62d P0188R1: add support for standard [[fallthrough]] attribute. This is almost
exactly the same as clang's existing [[clang::fallthrough]] attribute, which
has been updated to have the same semantics. The one significant difference
is that [[fallthrough]] is ill-formed if it's not used immediately before a
switch label (even when -Wimplicit-fallthrough is disabled). To support that,
we now build a CFG of any function that uses a '[[fallthrough]];' statement
to check.

In passing, fix some bugs with our support for statement attributes -- in
particular, diagnose their use on declarations, rather than asserting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262881 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-08 00:32:55 +00:00
Aaron Ballman 3827f56644 Implement support for [[nodiscard]] in C++1z that is based off existing support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262872 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-07 22:44:55 +00:00
John McCall a29b4d2ff1 Semantic analysis for the swiftcall calling convention.
I've tried to keep the infrastructure behind parameter ABI
treatments fairly general.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03 06:39:32 +00:00
John McCall ad080499c5 Improve some infrastructure for extended parameter infos and
fix a bug with the instantiation of ns_consumed parameter
attributes in ARC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262551 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03 00:10:03 +00:00
Xiuli Pan 2d12e2d6c9 [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr
Summary:
OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading,

Add semacheck for OpenCL access qualifier as well as test caees.

Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D16040

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261961 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26 03:13:03 +00:00
Manman Ren 7391f7f03c Addressing review comments for r261163.
Use "strict" instead of "nopartial". Also make strictly not-introduced
share the same diagnostics as Obsolete and Unavailable.

rdar://23791325


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261512 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-22 04:47:24 +00:00
Saleem Abdulrasool 1d51805adb Sema: provide an extension warning for enable_if
Clang implements an enable_if attribute as an extension.  Hook up `-Wpedantic`
to issue an extension usage warning when __enable_if__ is used.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261192 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-18 06:49:31 +00:00
Manman Ren 83a9e40e5f Add 'nopartial' qualifier for availability attributes.
An optional nopartial can be placed after the platform name.
int bar() __attribute__((availability(macosx,nopartial,introduced=10.12))

When deploying back to a platform version prior to when the declaration was
introduced, with 'nopartial', Clang emits an error specifying that the function
is not introduced yet; without 'nopartial', the behavior stays the same: the
declaration is `weakly linked`.

A member is added to the end of AttributeList to save the location of the
'nopartial' keyword. A bool member is added to AvailabilityAttr.

The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as
we handle unavailable cases.

Reviewed by Doug Gregor and Jordan Rose.

rdar://23791325


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261163 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-17 22:05:48 +00:00
Benjamin Kramer c563475a9f Fix a leak in the generated code for attributes with strings.
Storing std::strings in attributes simply doesn't work, we never call
the destructor. Use an array of StringRefs instead of std::strings and
copy the data into memory taken from the ASTContext.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260831 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 18:11:49 +00:00
Eugene Zelenko 24d973f5ae Fix remaining Clang-tidy readability-redundant-control-flow warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D17218


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260757 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-12 22:53:10 +00:00
Denis Zobnin e733f6bc15 Fix for PR8901: attribute "mode" rejected for enums and dependent types.
Allow "mode" attribute for enum types, except for vector modes, for compatibility with GCC.
Support "mode" attribute with dependent types.

Differential Revision: http://reviews.llvm.org/D16219


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259497 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02 13:50:39 +00:00
Reid Kleckner ba0b391504 Fix attribute((mode([word|unwind_word]))) for x32
Patch by H.J. Lu

```
typedef unsigned int gcc_word __attribute__((mode(word)));
```
and

```
typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
```
define the largest unsigned integer types which can be stored in a
general purpose register, which may not be the pointer type.  For x32,
they aren't pointer nor unsigned long.  We should

1. Make getUnwindWordWidth and getRegisterWidth virtual,
2. Override them for x32, similar to hasInt128Type.
3. Use getRegisterWidth for __attribute__((mode(word)));

This fixes PR 24706.

Reviewers: rnk

Differential Revision: http://reviews.llvm.org/D16779

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-01 18:58:24 +00:00
David Majnemer 202433cccd [MS ABI] Allow a member pointers' converted type to change
Member pointers in the MS ABI are tricky for a variety of reasons.
The size of a member pointer is indeterminate until the program reaches
a point where the representation is required to be known.  However,
*pointers* to member pointers may exist without knowing the pointee
type's representation.  In these cases, we synthesize an opaque LLVM
type for the pointee type.

However, we can be in a situation where the underlying member pointer's
representation became known mid-way through the program.  To account for
this, we attempted to manicure CodeGen's type-cache so that we can
replace the opaque member pointer type with the real deal while leaving
the pointer types unperturbed.  This, unfortunately, is a problematic
approach to take as we will violate CodeGen's invariants.

These violations are mostly harmless but let's do the right thing
instead: invalidate the type-cache if a member pointer's LLVM
representation changes.

This fixes PR26313.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258839 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 19:30:26 +00:00
Justin Lebar 937c06abd5 [CUDA] Reject the alias attribute in CUDA device code.
Summary: CUDA (well, strictly speaking, NVPTX) doesn't support aliases.

Reviewers: echristo

Subscribers: cfe-commits, jhen, tra

Differential Revision: http://reviews.llvm.org/D16502

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258641 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-23 21:28:10 +00:00
Justin Lebar f946780157 [CUDA] Only allow __global__ on free functions and static member functions.
Summary:
Warn for NVCC compatibility if you declare a static member function or
inline function as __global__.

Reviewers: tra

Subscribers: jhen, echristo, cfe-commits

Differential Revision: http://reviews.llvm.org/D16261

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258263 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-20 00:26:57 +00:00
Aaron Ballman 1d2a84e04f Allow __attribute__((mode)) to appertain to field declarations again. Corrects compile issues with LibreOffice.
Patch by Stephan Bergmann

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258213 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 22:54:26 +00:00
Alexey Bataev 0fb199899e PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration, by Denis Zobnin
Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which includes FunctionDecl and EnumConstantDecl), emit an error if this attribute is used with function declarations and enum constants.
Differential Revision: http://reviews.llvm.org/D16112


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257868 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15 04:36:32 +00:00
Alexey Bataev c08aea954f [X86] Support 'interrupt' attribute for x86
This attribute may be attached to a function definition and instructs the backend to generate appropriate function entry/exit code so that
it can be used directly as an interrupt handler.
The IRET instruction, instead of the RET instruction, is used to return from interrupt or exception handlers. All registers, except for the EFLAGS register which is restored by the IRET instruction, are preserved by the compiler.
Any interruptible-without-stack-switch code must be compiled with -mno-red-zone since interrupt handlers can and will, because of the hardware design, touch
the red zone.

interrupt handler must be declared with a mandatory pointer argument:
struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame) {
    ...
}
and user must properly define the structure the pointer pointing to.

exception handler: 

The exception handler is very similar to the interrupt handler with a different mandatory function signature:
#ifdef __x86_64__
typedef unsigned long long int uword_t;
#else
typedef unsigned int uword_t;
#endif

struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame, uword_t error_code) {
    ...
}
and compiler pops the error code off stack before the IRET instruction.

The exception handler should only be used for exceptions which push an error code and all other exceptions must use the interrupt handler.
The system will crash if the wrong handler is used.
Differential Revision: http://reviews.llvm.org/D15709


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257867 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15 04:06:31 +00:00
Justin Lebar a9b21a2f1a [CUDA] Report an error if code tries to mix incompatible CUDA attributes.
Summary: Thanks to jhen for helping me figure this out.

Reviewers: tra, echristo

Subscribers: jhen

Differential Revision: http://reviews.llvm.org/D16129

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 01:07:35 +00:00
Alexander Kornienko 769d8f4822 Revert "Fix for merging decls in pragma weak Calling CheckFunctionDeclaration so that 2 decls for the 'weak' are merged. Differential Revision: http://reviews.llvm.org/D13048"
This reverts commit r254143 which introduces a crash on the following input:
  f(char *);
  g(char *);
  #pragma weak f = g
  int g(char *p) {}


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254605 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03 11:37:28 +00:00
Alexey Bataev 1f64d37106 PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type, patch by D. Polukhin
This CL is for discussion how to better fix bit-filed layout compatibility issue with GCC (see PR25575 for test case and more details). Current clang behavior is compatible with GCC 4.1-4.3 series but it was fixed in 4.4+. Ignoring packed attribute looks very odd and because it was also fixed in GCC 4.4+, it makes sense also fix it in clang.
Differential Revision: http://reviews.llvm.org/D14872


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254596 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03 09:34:49 +00:00
George Burgess IV 7727f3dca1 Add the `pass_object_size` attribute to clang.
`pass_object_size` is our way of enabling `__builtin_object_size` to
produce high quality results without requiring inlining to happen
everywhere.

A link to the design doc for this attribute is available at the
Differential review link below.

Differential Revision: http://reviews.llvm.org/D13263


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254554 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-02 21:58:08 +00:00
Daniel Sanders 91f593226b [mips] Interrupt attribute support.
Summary: This patch adds support for the interrupt attribute for mips32r2+.

Patch by Simon Dardis.

Reviewers: dsanders, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D10802


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254205 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-27 18:03:44 +00:00
Daniel Sanders b4dacc31f3 Revert r254203: [mips] Interrupt attribute support.
I forgot to credit the author.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254204 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-27 18:00:36 +00:00
Daniel Sanders 16e3a3a943 [mips] Interrupt attribute support.
Summary: This patch adds support for the interrupt attribute for mips32r2+.

Reviewers: dsanders, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D10802

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-27 17:39:20 +00:00
Alexander Musman f4db326a17 Fix for merging decls in pragma weak
Calling CheckFunctionDeclaration so that 2 decls for the 'weak' are merged.
Differential Revision: http://reviews.llvm.org/D13048



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254143 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-26 09:34:30 +00:00
Alexey Bataev ad01cf79a7 PR10235: support for vector mode attributes + warning, by Dmitry Polukhin.
Add support for vector mode attributes like "attribute((mode(V4SF)))". Also add warning about deprecated vector modes like GCC does.
Differential Revision: http://reviews.llvm.org/D14744


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253551 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 10:13:11 +00:00
Craig Topper 5c9558ca58 [Sema] Minor formatting fixes. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253314 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 05:40:05 +00:00
Craig Topper ee5949e86b Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-15 02:31:46 +00:00
Akira Hatanaka 361b11deda Add support for function attribute 'disable_tail_calls'.
The ``disable_tail_calls`` attribute instructs the backend to not
perform tail call optimization inside the marked function.

For example, 

int callee(int);

int foo(int a) __attribute__((disable_tail_calls)) {
  return callee(a); // This call is not tail-call optimized.
}

Note that this attribute is different from 'not_tail_called', which
prevents tail-call optimization to the marked function.

rdar://problem/8973573

Differential Revision: http://reviews.llvm.org/D12547


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252986 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-13 00:42:21 +00:00
Evgeniy Stepanov b964ad11c0 Implement __attribute__((internal_linkage)).
The attrubite is applicable to functions and variables and changes
the linkage of the subject to internal.

This is the same functionality as C-style "static", but applicable to
class methods; and the same as anonymouns namespaces, but can apply
to individual methods of a class.

Following the proposal in
http://lists.llvm.org/pipermail/cfe-dev/2015-October/045580.html

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252648 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-10 21:28:44 +00:00
Akira Hatanaka 08bdfb571a Add support for function attribute 'not_tail_called'.
This attribute is used to prevent tail-call optimizations to the marked
function. For example, in the following piece of code, foo1 will not be
tail-call optimized: 

int __attribute__((not_tail_called)) foo1(int);

int foo2(int a) {
  return foo1(a); // Tail-call optimization is not performed.
}

The attribute has effect only on statically bound calls. It has no
effect on indirect calls. Also, virtual functions and objective-c
methods cannot be marked as 'not_tail_called'.

rdar://problem/22667622

Differential Revision: http://reviews.llvm.org/D12922


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252369 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 23:56:15 +00:00
Tim Northover b1250fb274 Support tvOS and watchOS availability attributes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251711 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-30 16:30:49 +00:00
John McCall 46c4622350 Refine r251469 to give better (and more localizable) diagnostics
for all the reasons that ARC makes things implicitly unavailable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251496 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 05:03:19 +00:00
John McCall 68098861a7 Add the ability to define "fake" arguments on attributes.
Fake arguments are automatically handled for serialization, cloning,
and other representational tasks, but aren't included in pretty-printing
or parsing (should we eventually ever automate that).

This is chiefly useful for attributes that can be written by the
user, but which are also frequently synthesized by the compiler,
and which we'd like to remember details of the synthesis for.
As a simple example, use this to narrow the cases in which we were
generating a specialized note for implicitly unavailable declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251469 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 00:17:34 +00:00
John McCall b4f5854951 Be more conservative about diagnosing "incorrect" uses of __weak:
allow them to be written in certain kinds of user declaration and
diagnose on the use-site instead.

Also, improve and fix some diagnostics relating to __weak and
properties.

rdar://23228631

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251384 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-27 04:54:50 +00:00
Aaron Ballman 2b1ded52c2 Amending r249721 to properly handle pathological attribute-related names like __ and ____.
Patch by Adrian Zgorzalek!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 13:53:24 +00:00
Aaron Ballman 5e8b924038 When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.
Patch by Adrian Zgorzalek!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 19:24:08 +00:00
Douglas Gregor bd3ba16165 Don't inherit availability information when implementing a protocol requirement.
When an Objective-C method implements a protocol requirement, do not
inherit any availability information from the protocol
requirement. Rather, check that the implementation is not less
available than the protocol requirement, as we do when overriding a
method that has availability. Fixes rdar://problem/22734745.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248949 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 21:27:42 +00:00
DeLesley Hutchins 78011164eb Thread Safety Analysis: allow capability attribute on unions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248805 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 16:24:18 +00:00
Artem Belevich b7a9667a41 [CUDA] __global__ functions should always be visible externally.
Adjust __global__ functions with DiscardableODR linkage to use
StrongODR linkage instead, so they are visible externally.

Differential Revision: http://reviews.llvm.org/D13067

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248400 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-23 17:44:53 +00:00
Artem Belevich 2ead4d5eab [CUDA] Add implicit __attribute__((used)) to all __global__ functions.
This makes sure that we emit kernels that were instantiated from the
host code and which would never be explicitly referenced by anything
else on device side.

Differential Revision: http://reviews.llvm.org/D11666

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248293 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:22:51 +00:00
Hans Wennborg faa64297d5 MS ABI: Don't allow dllexport/import on lambdas
This is to follow up on David's comment in
http://reviews.llvm.org/D12422#235509

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247718 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15 21:05:30 +00:00
Eric Christopher 424a1694ae Fix some coding standard issues and delete a dead conditional.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244959 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-13 21:34:35 +00:00
Daniel Jasper a92ab3bb56 Revert "[CUDA] Add implicit __attribute__((used)) to all __global__ functions."
This is breaking internal test. I'll provide a reproduction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244583 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-11 11:02:09 +00:00
Artem Belevich 830e9302b9 [CUDA] Add implicit __attribute__((used)) to all __global__ functions.
This allows emitting kernels that were instantiated from the host code
and which would never be explicitly referenced otherwise.

Differential Revision: http://reviews.llvm.org/D11666

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-10 20:57:02 +00:00
David Majnemer a15ae4a506 [Sema] Refactor AddAlignedAttr to reduce indentation
No functionality change intended, just a tidy-up.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243242 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 09:02:21 +00:00
David Majnemer 22e268be98 [Sema] The alignment of an object has an upper bound from the object file format
Don't use the spelling of the alignment attribute to determine whether
or not an alignment amount makes sense.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 01:48:59 +00:00
Benjamin Kramer af49942c7c [AST] Turn the callbacks of lookupInBases and forallBases into a function_ref
This lets us pass functors (and lambdas) without void * tricks. On the
downside we can't pass CXXRecordDecl's Find* members (which are now type
safe) to lookupInBases directly, but a lambda trampoline is a small
price to pay. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-25 15:07:25 +00:00
Bob Wilson 4e5f9fb46e Ignore the "novtable" declspec when not using the Microsoft C++ ABI.
Clang used to silently ignore __declspec(novtable). It is implemented
now, but leaving the vtable uninitialized does not work when using the
Itanium ABI, where the class layout for complex class hierarchies is
stored in the vtable. It might be possible to honor the novtable
attribute in some simple cases and either report an error or ignore
it in more complex situations, but it’s not clear if that would be
worthwhile. There is also value in having a simple and predictable
behavior, so this changes clang to simply ignore novtable when not using
the Microsoft C++ ABI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242730 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 22:57:31 +00:00
David Majnemer f3e8e6409f [MS Compat] Add support for __declspec(noalias)
The attribute '__declspec(noalias)' communicates that the function only
accesses memory pointed to by its pointer-typed arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242728 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 22:51:52 +00:00
Paul Robinson d574782178 Add a "maximum TLS alignment" characteristic to the target info, so it
can be different from the normal variable maximum.
Add an error diagnostic for when TLS variables exceed maximum TLS alignment.
Currenty only PS4 sets an explicit maximum TLS alignment.

Patch by Charles Li!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242198 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 20:52:32 +00:00
Alex Denisov 3849076ca6 [ObjC] Add NSValue support for objc_boxed_expressions
Patch extends ObjCBoxedExpr to accept records (structs and unions):

typedef struct __attribute__((objc_boxable)) _Color {
  int r, g, b;
} Color;

Color color;
NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)];



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240761 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-26 05:28:36 +00:00
Douglas Gregor 619f53c205 Allow the cf_returns_[not_]retained attributes to appear on out-parameters.
Includes a simple static analyzer check and not much else, but we'll also
be able to take advantage of this in Swift.

This feature can be tested for using __has_feature(cf_returns_on_parameters).

This commit also contains two fixes:
- Look through non-typedef sugar when deciding whether something is a CF type.
- When (cf|ns)_returns(_not)?_retained is applied to invalid properties,
  refer to "property" instead of "method" in the error message.

rdar://problem/18742441

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240185 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 23:17:46 +00:00
Alexey Bataev ed0926c176 [ATTRIBUTE] Support base vector types of __attribute__((mode)), patch by Alexey Frolov
Base type of attribute((mode)) can actually be a vector type.
The patch is to distinguish between base type and base element type.

This fixes http://llvm.org/PR17453.
Differential Revision: http://reviews.llvm.org/D10058


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240125 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 07:46:21 +00:00
Eric Christopher b8e7e4d0ca Add a warning for unsupported elements of the target attribute.
Since we're ignoring the tune= and fpmath= attributes go ahead
and add a warning alerting people to the fact that we're going
to ignore that part of it during code generation and tie it to
the attribute warning set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239583 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-12 01:36:05 +00:00
Eric Christopher 1086da71a7 Add support for the the target attribute.
Modeled after the gcc attribute of the same name, this feature
allows source level annotations to correspond to backend code
generation. In llvm particular parlance, this allows the adding
of subtarget features and changing the cpu for a particular function
based on source level hints.

This has been added into the existing support for function level
attributes without particular verification for any target outside
of whether or not the backend will support the features/cpu given
(similar to section, etc).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239579 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-12 01:35:52 +00:00
Richard Smith b8ffc7f221 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238526 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 23:38:53 +00:00
Peter Collingbourne 2d7c006c4c Use llvm::StringSwitch<std::string> to take advantage of implicit asserting conversion to std::string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237475 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 20:11:18 +00:00
Peter Collingbourne bb987e72f3 Implement no_sanitize attribute.
Differential Revision: http://reviews.llvm.org/D9631

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237463 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 18:33:32 +00:00
Jordan Rose 1e3d41bd8e Don't warn about use of deprecated API when the containing context is unavailable.
This probably won't come up much, but it seems tidier.

Related to rdar://problem/20713550

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236242 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 17:20:35 +00:00
Artem Belevich 9f539454a3 [cuda] Allow using integral non-type template parameters as launch_bounds attribute arguments.
- Changed CUDALaunchBounds arguments from integers to Expr* so they can
   be saved in AST for instantiation.
 - Added support for template instantiation of launch_bounds attrubute.
 - Moved evaluation of launch_bounds arguments to NVPTXTargetCodeGenInfo::
   SetTargetAttributes() where it can be done after template instantiation.
 - Added a warning on negative launch_bounds arguments.
 - Amended test cases.

Differential Revision: http://reviews.llvm.org/D8985

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235452 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-21 22:55:54 +00:00
Fariborz Jahanian e8d60ed0ef [Objective-C Sema] patch to introduce IndependentClass
attribute to be placed on Objective-C pointer typedef
to make them strong enough so on their "new" method
family no attempt is made to override these 
types. rdar://20255473


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235128 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-16 18:38:44 +00:00
David Majnemer ba273a2094 [Sema] Don't crash when __attribute__((nonnull)) is applied to blocks
A simple case of asserting isFunctionOrMethod when we should have
asserted isFunctionOrMethodOrBlock.

This fixes PR23117.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234297 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 06:01:53 +00:00
David Majnemer bd329541be [Sema] Don't permit dependent alignments on non-dependent typedef-names
A dependent alignment attribute (like __attribute__((aligned(...))) or
__declspec(align(...))) on a non-dependent typedef or using declaration
poses a considerable challenge: the type is _not_ dependent, the size
_may_ be dependent if the type is used as an array type, the alignment
_is_ dependent.

It is reasonable for a compiler to be able to query the size and
alignment of a complete type.  Let's help that become an invariant.

This fixes PR22042.

Differential Revision: http://reviews.llvm.org/D8693

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234280 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 02:37:09 +00:00
Chandler Carruth f8cf68746c [Modules] Make "#pragma weak" undeclared identifiers be tracked
deterministically.

This fixes a latent issue where even Clang's Sema (and diagnostics) were
non-deterministic in the face of this pragma. The fix is super simple --
just use a MapVector so we track the order in which these are parsed (or
imported). Especially considering how rare they are, this seems like the
perfect tradeoff. I've also simplified the client code with judicious
use of auto and range based for loops.

I've added some pretty hilarious code to my stress test which now
survives the binary diff without issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-26 08:32:49 +00:00
Nico Weber 86877a8679 Add -Wpartial-availability.
This warns when using decls that are not available on all deployment targets.
For example, a call to

  - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8)));

will warn if -mmacosx-version-min is set to less than 10.8.

To silence the warning, one has to explicitly redeclare the method like so:

  @interface Whatever(MountainLionAPI)
  - (void)ppartialMethod;
  @end

This way, one cannot accidentally call a function that isn't available
everywhere.  Having to add the redeclaration will hopefully remind the user
to add an explicit respondsToSelector: call as well.

Some projects build against old SDKs to get this effect, but building against
old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples.
The hope is that SDK headers are annotated well enough with availability
attributes that new SDK + this warning offers the same amount of protection
as using an old SDK.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232750 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 19:18:22 +00:00
Reid Kleckner 54ccb94652 Implement section pragma feedback on r205810
Mostly short-circuits some conditionals.  Adds target validation of
sections passed to these pragmas.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231317 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 23:39:17 +00:00
Reid Kleckner 413d8cac1a Win64: Silently ignore __stdcall, __fastcall, and __thiscall
MSVC doesn't warn on this. Users are expected to apply the WINAPI macro
to functions passed by pointer to the Win32 API, and this macro expands
to __stdcall. This means we end up with a lot of useless noisy warnings
about ignored calling conventions when compiling code with clang for
Win64.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230668 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-26 19:43:46 +00:00
Richard Smith a8229d2c00 Cleanup: remove artificial division between lookup results and const lookup
results. No-one was ever modifying a lookup result, and it would not be
reasonable to do so.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230123 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-21 02:45:19 +00:00
Fariborz Jahanian 4124d39ea0 [Objective-C]. Provide a new formatting kind, "os_trace" which
can take a "const char*" format but supports standard printf 
and CF/NS types . rdar://19904147


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230109 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-21 00:45:58 +00:00
Dimitry Andric a53dd09cce Add support for analyzing FreeBSD kernel printf extensions.
This adds a new __freebsd_kprintf__ format string type, which enables
checking when used in __attribute__((format(...))) attributes.  It can
check the FreeBSD kernel specific %b, %D, %r and %y specifiers, using
existing diagnostic messages.  Also adds test cases for all these
specifiers.

Differential Revision: http://reviews.llvm.org/D7154


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229921 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-19 22:32:33 +00:00
Saleem Abdulrasool d9b0013b7a Sema: partially address post-commit comments
Un-parameterize the warning as there is exactly one attribute added in C++14.
Partially addresses post-commit review comments from Richard Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229636 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 04:33:26 +00:00
Aaron Ballman 58179568b8 Minor tweaks to r229447 to ensure the attribute is properly quoted when diagnosed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229454 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-16 23:12:37 +00:00
Saleem Abdulrasool ac03901885 Sema: diagnose use of unscoped deprecated prior to C++14
The deprecated attribute was adopted as part of the C++14, however, there is a
GNU version available in C++11.  When using C++ earlier than C++14, diagnose the
use of the attribute without the GNU scope, but only when using the generalised
attribute syntax.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229447 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-16 22:27:01 +00:00
David Majnemer a0cdc21a43 Sema: Add support for __declspec(restrict)
__declspec(restrict) and __attribute(malloc) are both handled
identically by clang: they are allowed to the noalias LLVM attribute.

Seeing as how noalias models the C99 notion of 'restrict', rename the
internal clang attribute to Restrict from Malloc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04 07:23:21 +00:00
David Majnemer 9e1c1866cd The prefix 'Ms-' should be 'MS-'
Clang is otherwise consistent that Microsoft be abbreviated as MS, not
Ms.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 19:30:52 +00:00
David Majnemer 2ed5fe8195 MS ABI: Implement support for 'novtable'
It is common for COM interface classes to be marked as 'novtable' to
tell the compiler that constructors and destructors should not reference
virtual function tables.

This commit implements this feature in clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227796 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 10:22:20 +00:00
John McCall 1931c2457a Allow objc_bridge(id) to be used on typedefs of [cv] void*.
rdar://19678874

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227774 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-01 22:34:06 +00:00
Derek Schuff bf6f6d5f28 Remove support for pnaclcall attribute
Summary:
It was used for interoperability with PNaCl's calling conventions, but
it's no longer needed.

Also Remove NaCl*ABIInfo which just existed to delegate to either the portable
or native ABIInfo, and remove checkCallingConvention which was now a no-op
override.

Reviewers: jvoung

Subscribers: jfb, llvm-commits

Differential Revision: http://reviews.llvm.org/D7206

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-28 20:24:52 +00:00
David Majnemer c9301cf73a AST: Don't ignore alignas on EnumDecls when calculating alignment
We didn't consider any alignment attributes on an EnumDecl when
calculating alignment.

While we are here, ignore alignment specifications on typedef types if
one is used as the underlying type.  Otherwise, weird things happen:

enum Y : int;
Y y;

typedef int __attribute__((aligned(64))) u;
enum Y : u {};

What is the alignment of 'Y'?  It would be more consistent with the
overall design of enums with fixed underlying types to consider the
underlying type's UnqualifiedDesugaredType.

This fixes PR22279.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226653 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 10:54:38 +00:00
Ben Langmuir 1b3cb15b99 Fix crashes on missing @interface for category
In a few places we didn't check that Category->getClassInterface() was
not null before using it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226605 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 20:41:36 +00:00
David Majnemer 7e7e7a90a1 Sema: Variable definitions cannot be __attribute__((alias))
Things that are OK:
  extern int var1 __attribute((alias("v1")));
  static int var2 __attribute((alias("v2")));

Things that are not OK:
  int var3 __attribute((alias("v3")));
  extern int var4 __attribute((alias("v4"))) = 4;

We choose to accpet:
  struct S { static int var5 __attribute((alias("v5"))); };

  This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have
  no reason to reject it.

This partially fixes PR22217.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226436 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 09:00:28 +00:00
Paul Robinson 02e4be86fb When attribute 'optnone' appears on the same declaration with a
conflicting attribute, warn about the conflict and pick a "winning"
attribute to preserve, instead of emitting an error.  This matches the
behavior when the conflicting attributes are on different declarations.

Along the way I discovered that conflicts involving __forceinline were
reported as 'always_inline' (alternate spelling, same attribute) so
fixed that up to report the attribute as spelled in the source.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225813 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 18:34:56 +00:00
Nico Weber 78edcbb6a4 Wrap to 80 columns. No behavior change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225414 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07 23:50:05 +00:00
Aaron Ballman c77fbd026e Attributes accepting an EnumArgument are allowed to pass a string literal, or an identifier. VariadicEnumArguments now behave consistently instead of only accepting a string literal.
This change affects the only attribute accepting a variadic enumeration: callable_when.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224582 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 16:42:04 +00:00
Paul Robinson eefcef89c7 Warn when attribute 'optnone' conflicts with attributes on a
different declaration of the same function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224256 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 18:57:28 +00:00
David Majnemer 81fcac7206 Sema: attribute((annotate)) must have at least one argument
Sema::handleAnnotateAttr expects that some basic validation is done on
the given AttributeList.  However, ProcessAccessDeclAttributeList called
it directly.  Instead, pass the list to ProcessDeclAttribute.

This fixes PR21847.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224204 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-14 01:05:01 +00:00
Paul Robinson 0a37dbd750 Diagnose attributes 'optnone' and 'minsize' on the same declaration.
Eventually we'll diagnose them on different declarations, but let's
get this part out of the way first.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223985 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10 23:34:36 +00:00
Paul Robinson dc4cf2db23 Revert r223980 as it had wrong commit message.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223984 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10 23:32:57 +00:00
Paul Robinson 66d950e502 Rename a couple of preprocessor symbols to be more descriptive. NFC.
Review feedback from recent changes to GetSVN.cmake.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223980 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10 23:12:37 +00:00
Matt Arsenault dcbb8fe6d5 Workaround attribute ordering issue with kernel only attributes
Placing the attribute after the kernel keyword would incorrectly
reject the attribute, so use the smae workaround that other
kernel only attributes use.

Also add a FIXME because there are two different phrasings now
for the same error, althoug amdgpu_num_[sv]gpr uses a consistent one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223490 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 18:03:58 +00:00
Matt Arsenault aefc430bcd Use else if when checking multiple attributes.
Only one of these can really match.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223489 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 18:03:55 +00:00
Aaron Ballman 93102416e5 Adding a FIXME to the code, based on a discussion in IRC; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223403 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 22:45:31 +00:00
Matt Arsenault 501dbb269d Add attributes for AMDGPU register limits.
This is a performance hint that can be applied to kernels
to attempt to limit the number of used registers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223384 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 20:38:18 +00:00
Sean Hunt 6724817052 Create a new 'flag_enum' attribute.
This attribute serves as a hint to improve warnings about the ranges of
enumerators used as flag types. It currently has no working C++ implementation
due to different semantics for enums in C++. For more explanation, see the docs
and testcases.

Reviewed by Aaron Ballman.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222906 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-28 00:53:20 +00:00
Aaron Ballman 00dccd63cd [c++1z] Support [[deprecated]] attributes on namespaces. Note that it only applies to situations where the namespace is mentioned. Thus, use on anonymous namespaces is diagnosed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222054 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 22:34:56 +00:00
Hans Wennborg 956edcd5d5 Don't dllimport inline functions when targeting MinGW (PR21366)
It turns out that MinGW never dllimports of exports inline functions.
This means that code compiled with Clang would fail to link with
MinGW-compiled libraries since we might try to import functions that
are not imported.

To fix this, make Clang never dllimport inline functions when targeting
MinGW.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221154 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03 14:24:45 +00:00
Reid Kleckner cb348a9ab7 Add frontend support for __vectorcall
Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

Differential Revision: http://reviews.llvm.org/D5808

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220573 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 17:42:17 +00:00
Aaron Ballman c8261ffe67 Turned Sema::HandleDelayedAvailabilityCheck into a static function; NFC.
Did a bit of drive-by reformatting as well since it required rearranging some other static functions in the file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219795 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-15 15:37:51 +00:00
Hal Finkel d4bc37b9dd Initial support for the align_value attribute
This adds support for the align_value attribute. This attribute is supported by
Intel's compiler (versions 14.0+), and several of my HPC users have requested
support in Clang. It specifies an alignment assumption on the values to which a
pointer points, and is used by numerical libraries to encourage efficient
generation of vector code.

Of course, we already have an aligned attribute that can specify enhanced
alignment for a type, so why is this additional attribute important? The
problem is that if you want to specify that an input array of T is, say,
64-byte aligned, you could try this:

  typedef double aligned_double attribute((aligned(64)));
  void foo(aligned_double *P) {
    double x = P[0]; // This is fine.
    double y = P[1]; // What alignment did those doubles have again?
  }

the access here to P[1] causes problems. P was specified as a pointer to type
aligned_double, and any object of type aligned_double must be 64-byte aligned.
But if P[0] is 64-byte aligned, then P[1] cannot be, and this access causes
undefined behavior. Getting round this problem requires a lot of awkward
casting and hand-unrolling of loops, all of which is bad.

With the align_value attribute, we can accomplish what we'd like in a well
defined way:

  typedef double *aligned_double_ptr attribute((align_value(64)));
  void foo(aligned_double_ptr P) {
    double x = P[0]; // This is fine.
    double y = P[1]; // This is fine too.
  }

This attribute does not create a new type (and so it not part of the type
system), and so will only "propagate" through templates, auto, etc. by
optimizer deduction after inlining. This seems consistent with Intel's
implementation (thanks to Alexey for confirming the various Intel-compiler
behaviors).

As a final note, I would have chosen to call this aligned_value, not
align_value, for better naming consistency with the aligned attribute, but I
think it would be more useful to users to adopt Intel's name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218910 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 21:21:25 +00:00
Hal Finkel 8602f3c564 Support the assume_aligned function attribute
In addition to __builtin_assume_aligned, GCC also supports an assume_aligned
attribute which specifies the alignment (and optional offset) of a function's
return value. Here we implement support for the assume_aligned attribute by making
use of the @llvm.assume intrinsic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218500 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-26 05:04:30 +00:00
Hal Finkel 687b32ee47 Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.
This makes use of the recently-added @llvm.assume intrinsic to implement a
__builtin_assume(bool) intrinsic (to provide additional information to the
optimizer). This hooks up __assume in MS-compatibility mode to mirror
__builtin_assume (the semantics have been intentionally kept compatible), and
implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM
now contains special logic to deal with assumptions of this form.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217349 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 22:58:14 +00:00
Eli Bendersky 5aa7b72ef5 Fix up formatting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216976 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 22:00:06 +00:00
Richard Smith 2a1084ce0e Fix representation of __attribute__((nonnull)) to support correctly modeling
the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B,
C))) attribute, since that does the wrong thing for function templates and
varargs functions.

In passing, fix a grammar error in the diagnostic, a crash if
__attribute__((nonnull(N))) is applied to a varargs function,
a bug where the same null argument could be diagnosed multiple
times if there were multiple nonnull attributes referring to it,
and a bug where nonnull attributes would not be accumulated correctly
across redeclarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216520 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 04:59:42 +00:00
Aaron Ballman 5f2d81841a Highlight the offending function parameter when the format argument refers to an invalid function parameter type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214723 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 15:26:33 +00:00
Aaron Ballman a41cfc7537 Highlight the offending function parameter when the format_arg argument refers to an invalid function parameter type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214722 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 15:17:29 +00:00
Aaron Ballman a09c6cc129 Dropping some else-after-returns. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214526 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 17:02:34 +00:00
Aaron Ballman 502d3d9afc Improving diagnostic source ranges for the nonnull attribute. Now it highlights the attribute and the faulty nonpointer type when possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214507 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 12:58:11 +00:00
Aaron Ballman e3faa8fffe Implemented a diagnostic to handle multiple, distinct ownership_return attributes on the same declaration. This removes a FIXME from the code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214436 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 20:44:26 +00:00
Aaron Ballman 91aa8f05b5 Removing an outdated FIXME. No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214411 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 18:09:13 +00:00
Aaron Ballman 60ec5f80d2 Automate attribute argument count semantic checking when there are variadic or optional arguments present. With this, the only time you should have to manually check attribute argument counts is when HasCustomParsing is set to true, or when you have variadic arguments that aren't really variadic (like ownership_holds and friends).
Updating the diagnostics in the launch_bounds test since they have been improved in that case. Adding a test for nonnull since it has little test coverage, but has truly variadic arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214407 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 16:37:04 +00:00
Aaron Ballman f9bba08955 Improving the "integer constant too large" diagnostics based on post-commit feedback from Richard Smith. Amends r213657.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213865 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 14:51:23 +00:00
Aaron Ballman cd46364930 Improve the checkUInt32Argument() helper function so that it diagnoses integer constants larger than 32-bits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 14:09:34 +00:00
Fariborz Jahanian d818762dc6 Objective-C. Changes per A. Ballman's comment
for my last patch. // rdar://17631257


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213185 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 19:44:34 +00:00
Fariborz Jahanian 29eea29d75 Objective-C. Introducing __attribute__((objc_runtime_name("runtimename"))
to be applied to class or protocols. This will direct IRGen
for Objective-C metadata to use the new name in various places
where class and protocol names are needed.
rdar:// 17631257


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213167 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 16:16:04 +00:00
Alp Toker c7645b9266 Fix typos
Also consolidate 'backward compatibility'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212974 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 19:42:55 +00:00
Aaron Ballman e6d998b1dd The returns_nonnull attribute does not require a function prototype because it affects only the return value, not any arguments. In turn, asking for a function or method result type should not require a function prototype either, so getFunctionOrMethodResultType has been relaxed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212827 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 16:31:29 +00:00
Alp Toker e9a2e9d4e3 Switch over a few uses of param_begin() to parameters()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-07 09:02:20 +00:00
Alp Toker 862a959d36 Make FunctionDecl::getReturnTypeSourceRange() support non-builtin types
Also document that the function is a "best-effort" facility to extract source
ranges from limited AST type location info.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212174 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 12:55:58 +00:00
Hans Wennborg d03ed82c9d MS ABI: Ignore dll attributes on partial template specializations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211648 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 23:57:13 +00:00
Hans Wennborg 2c183aa7d4 Merge handleDLLImportAttr and handleDLLExportAttr into one function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211647 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 23:57:05 +00:00
Fariborz Jahanian 51ccb71920 Objective-C. Diagnose when property access is using declared
property accessor methods which have become deprecated
or available. // rdar://15951801


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211039 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16 17:25:41 +00:00
Fariborz Jahanian 18ce5b3599 Objective-C. Use isObjCRetainableType in my last
patch. NFC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210795 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 16:12:30 +00:00
Fariborz Jahanian e9b1c2f893 Objective-C. Accept '__attribute__((__ns_returns_retained__))'
for function/methods returning block in MRR mode as well.
// rdar://17259812


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210706 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 21:22:53 +00:00
Nikola Smiljanic be481708fb Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 10:55:11 +00:00
Craig Topper 6b8c5857eb [C++11] Use 'nullptr'. Sema edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-26 06:22:03 +00:00
Hans Wennborg 98a84f6794 Don't suppress warning about dllimport on typedefs etc. in MicrosoftExt mode
It's true the MSVC doesn't warn about dllimport when applied to e.g. a typedef,
but that applies to dllexport too. I'd like us to be consistent, and I think
the right thing to do is to warn.

The original test that came with implementing the old behaviour doesn't provide
a good motivation, and it said it was checking that we're not repoting an *error*,
which is still true since this is just a warning.

There are plenty of tests e.g. in Sema/dllimport.c to check that we do warn
about dllimport on non functions or variables.

Differential Revision: http://reviews.llvm.org/D3832

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209546 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-23 20:16:41 +00:00
Peter Collingbourne 7e9a34dfa5 Implement the flatten attribute.
This is a GNU attribute that causes calls within the attributed function
to be inlined where possible. It is implemented by giving such calls the
alwaysinline attribute.

Differential Revision: http://reviews.llvm.org/D3816

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209217 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-20 17:12:51 +00:00
Peter Collingbourne edea169440 Implement the no_split_stack attribute.
This is a GNU attribute that allows split stacks to be turned off on a
per-function basis.

Differential Revision: http://reviews.llvm.org/D3817

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209167 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-19 22:14:34 +00:00
Joey Gouly 5e16ee0632 [OpenCL] Reject reqd_work_group_size(X, Y, Z) where X, Y or Z == 0.
Patch by Pedro Ferreira!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209127 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-19 14:41:38 +00:00
Hans Wennborg 61e1f5cc72 Allow dllimport/dllexport on inline functions and adjust the linkage.
This is a step towards handling these attributes on classes (PR11170).

Differential Revision: http://reviews.llvm.org/D3772

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208925 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 22:07:49 +00:00
Benjamin Kramer 10ffef9f56 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208470 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-10 16:31:55 +00:00
Reid Kleckner 8dda109f62 Add support for __declspec(thread) under -fms-extensions
Reviewers: rsmith

Differential Revision: http://reviews.llvm.org/D3551

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207734 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-01 03:16:47 +00:00
Aaron Ballman 117df18867 In preparation for being able to use simple Boolean logic expressions involving capabilities, the semantics for attributes now looks through the types of the constituent parts of a capability expression instead of at the aggregate expression type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205629 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04 15:13:57 +00:00
Paul Robinson 8c03089bda Implement the 'optnone' attribute, which suppresses most optimizations
on a function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-31 22:29:15 +00:00
Aaron Ballman 3fd557c273 Capability attributes can now be declared on a typedef declaration as well as a structure declaration. This allows for C code to use Boolean expressions on a capability as part of another attribute. Eg) __attribute__((requires_capability(!SomeCapability)))
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204657 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-24 19:29:19 +00:00
Aaron Ballman 18d907edb4 Replacing the exclusive_lock_function, shared_lock_function and unlock_function attributes with the acquire_capability and release_capability attributes. The old spellings will continue to work, but the underlying semantic attributes have been replaced.
Downgraded the capability diagnostics from error to warning to match the desired behavior, and updated the existing test cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204350 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20 16:02:49 +00:00
Aaron Ballman c4430a74cb [C++11] Replacing FunctionProtoType iterators param_type_begin() and param_type_end() with iterator_range param_types(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204045 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 15:23:01 +00:00
Fariborz Jahanian ba42b0bca2 Objective-C. Allow objc_designated_initializer for private
initializers; but only those declared in class extensions
(not in implementations). // rdar://16305347


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203954 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 18:19:46 +00:00
Aaron Ballman 15fd658d17 [C++11] Replacing DeclBase iterators specific_attr_begin() and specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203474 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 17:08:28 +00:00
Argyrios Kyrtzidis 3fcc6f3526 [Sema] Fix assertion hit with #pragma weak.
rdar://16264844

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203372 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-09 05:15:28 +00:00
Aaron Ballman 8328f6462b [C++11] Replacing RecordDecl iterators field_begin() and field_end() with iterator_range fields(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 20:12:42 +00:00
Aaron Ballman 1942032555 Reformatting the style used within the massive attribute semantic handling switch statement, so now there is only one style used in this block of code, instead of three or more styles.
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203120 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 14:02:27 +00:00
Ted Kremenek c5a9f95160 Remove 2 dead 'break' statements. The 'break' usage in this switch is inconsistent, making this hard to see.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203079 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 05:37:35 +00:00
Aaron Ballman 25a7fe7d87 Capabilities are required to pass a name specifying what type of capability is being annotated. There are currently only two supported names: mutex and role. Adding functionality to check for the capability name and diagnose when it's unexpected.
Note that for backwards compatibility, an unnamed capability will default to being a "mutex." This allows the deprecated lockable attribute to continue to function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203012 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 21:47:13 +00:00
Nico Rieck b57e967568 Sema: Definition of dllimport globals is not allowed
Upgrades the warning to an error and clarifies the message by treating the
definition as error instead of the attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202300 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 21:27:13 +00:00
David Majnemer de3be0d8ca Attr: Remove ForceInline
The __forceinline keyword's semantics are now recast as AlwaysInline and
the kw___forceinline token has its language mode set for KEYMS.

This preserves the semantics of the previous implementation but with
less duplication of code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202131 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-25 09:53:29 +00:00
Nico Rieck 4a719afb5b Reorganize and improve semantic tests for dllexport/import
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201947 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-22 19:47:30 +00:00
Aaron Ballman 16381d3390 Exposing the noduplicate attribute within Clang, which marks functions so that the optimizer does not duplicate code.
Patch thanks to Marcello Maggioni!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201941 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-22 16:59:24 +00:00
Ted Kremenek 269a49b49b Per feedback from Aaron Ballman, push cast-to-ObjCProtocolDecl inside handleObjCSuppresProtocolAttr().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201922 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-22 01:06:05 +00:00
Ted Kremenek 78684c078e Add requirement that attribute 'objc_protocol_requires_explicit_implementation' can only be applied to protocol definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201899 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-21 22:49:04 +00:00
Aaron Ballman e81eb42ceb Adding role-based capability attributes that allow you to express role management: asserting a capability is held, acquiring a capability and releasing a capability. Also includes some skeleton documentation for these new attributes.
This functionality should be considered a WIP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201890 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-21 21:05:14 +00:00
Aaron Ballman 0894e59748 DeLesley Hutchins (who wrote the original thread-safety attribute functionality) and I have agreed to start migrating from lock-specific terminology to "capability"-specific terminology. This opens the door for future threading-related analysis passes so that a common nomenclature can be used.
The following attributes have been (silently) deprecated, with their replacements listed:

lockable => capability
exclusive_locks_required => requires_capability
shared_locks_required => requires_shared_capability
locks_excluded => requires_capability

There are no functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201585 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-18 17:36:50 +00:00
David Majnemer 63405b9c46 Sema: Restrict alignment to 2**28.
Allowing alignment past this point causes wrap around within clang.

N.B.  GCC has the same restriction.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201254 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-12 20:36:10 +00:00
Jordan Rose 6bb65c240b 'nonnull(1)' on a block parameter should apply to the block's argument.
Thanks to r199467, __attribute__((nonnull)) (without arguments) can apply
directly to parameters, instead of being applied to the whole function.
However, the old form of nonnull (with an argument index) could also apply
to the arguments of function and block pointers, and both of these can be
passed as parameters.

Now, if 'nonnull' with an argument is found on a parameter, /and/ the
parameter is a function or block pointer, it is handled the old way.

PR18795

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201162 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-11 17:27:59 +00:00
David Majnemer 3fad2414b0 MS ABI: Add support for #pragma pointers_to_members
Introduce a notion of a 'current representation method' for
pointers-to-members.

When starting out, this is set to 'best case' (representation method is
chosen by examining the class, selecting the smallest representation
that would work given the class definition or lack thereof).

This pragma allows the translation unit to dictate exactly what
representation to use, similar to how the inheritance model keywords
operate.

N.B.  PCH support is forthcoming.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201105 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-10 19:50:15 +00:00
David Majnemer 61a09b7d35 MS ABI: Don't be so hasty to judge an inheritance model
If we are in the middle of defining the class, don't attempt to
validate previously annotated declarations.  We may not have seen base
specifiers or virtual method declarations yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200959 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-07 00:43:07 +00:00
David Majnemer 2a0497a99b Sema: Diagnose improper application of inheritance keywords
We would previously allow inappropriate inheritance keywords to appear
on class declarations.  We would also allow inheritance keywords on
templates which were not fully specialized; this was divergent from
MSVC.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200423 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 22:07:36 +00:00
Aaron Ballman c5ab59c89e Relaxing the alignment requirements for fields in a transparent_union. Emits the diagnostic only when subsequent alignments are more strict than the alignment required by the first field.
Fixes PR15134

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200277 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 01:47:34 +00:00
Alp Toker c6ffb1e515 Rename getResultLoc() too
Follow up to r200082.

Spotted by Dmitri

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200105 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 23:51:36 +00:00
Alp Toker 37545f747c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 16:55:45 +00:00
Alp Toker 8e5a73f4d3 Correct various uses of 'argument' that in fact refer to function parameters
Cleanup only.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199773 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 23:35:24 +00:00
Alp Toker c50bf3d128 Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.

Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.

Will keep an eye on the builders and update dependent projects shortly.

No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199686 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 20:26:09 +00:00
Aaron Ballman 6a1431e97f Formatting cleanups; no functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199671 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 16:15:55 +00:00
Aaron Ballman 26b75d3d97 Fixing a typo (turned out to be harmless since the default priority values are the same between the two attributes).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199666 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 15:22:57 +00:00
Aaron Ballman a87fc4e64f Since the diagnostics engine understands Attr objects, this code is no longer required -- we can just pass in the attribute directly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199664 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 15:06:09 +00:00
Aaron Ballman 0f76ae8d75 Making some minor improvements to r199626.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199663 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 14:19:44 +00:00
Ted Kremenek 6ff751e7df Wire up basic parser/sema support for attribute 'returns_nonnull'.
This attribute is supported by GCC.  More generally it should
probably be a type attribute, but this behavior matches 'nonnull'.

This patch does not include warning logic for checking if a null
value is returned from a function annotated with this attribute.
That will come in subsequent patches.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199626 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 05:50:47 +00:00
Ted Kremenek cc118c86a6 These attributes are no longer "checker-specific."
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 05:50:41 +00:00
Ted Kremenek f5a99a4db7 Enhance attribute 'nonnull' to be applicable to parameters directly (infix).
This allows the following syntax:

  void baz(__attribute__((nonnull)) const char *str);

instead of:

  void baz(const char *str) __attribute__((nonnull(1)));

This also extends to Objective-C methods.

The checking logic in Sema is not as clean as I would like.  Effectively
now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters,
so the point of truth is spread in two places, but the logic isn't that
cumbersome.

Implements <rdar://problem/14691443>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199467 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-17 06:24:56 +00:00