Commit Graph

1031 Commits

Author SHA1 Message Date
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
Aaron Ballman 0e00e32712 Factored some function-like type reasoning out of SemaDeclAttr and onto Decl itself. This allows for more declarative subjects in attribute tablegen where the attribute appertains to something function-like, but not strictly a FunctionDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199387 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 13:55:42 +00:00
Aaron Ballman 591427889e Distinguish between attributes explicitly written at the request of the user, and attributes implicitly generated to assist in bookkeeping by the compiler. This is done so by table generating a CreateImplicit method for each attribute.
Additionally, remove the optional nature of the spelling list index when creating attributes. This is supported by table generating a Spelling enumeration when the spellings for an attribute are distinct enough to warrant it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199378 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 13:03:14 +00:00
Reid Kleckner cc6bd540ca Remove unused function to fix clang -Werror build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199230 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 18:10:42 +00:00
Aaron Ballman 3e520c2902 Simplifying the OpenCL image attribute. It does not need a semantic integer parameter because the required information is encoded in the spelling. Added an appropriate subject to the attribute, and simplified the semantic checking (which will likely be expanded upon in a future patch). Also, removed the GNU spelling since it was unsupported in the first place.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199229 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 17:41:53 +00:00
DeLesley Hutchins 95c2c29065 Consumed analysis: add two new attributes which fine-tune the behavior of
consumable objects.  These are useful for implementing error codes that
must be checked.  Patch also includes some significant refactoring, which was
necesary to implement the new behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199169 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 00:36:53 +00:00
Nick Lewycky c8cd634957 Add a new attribute 'enable_if' which can be used to control overload resolution based on the values of the function arguments at the call site.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198996 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 02:50:57 +00:00
Aaron Ballman f78f966d30 Removing the notion of TargetAttributesSema and replacing it with one where the parsed attributes are responsible for knowing their target-specific nature, instead of letting Sema figure it out. This is necessary so that __has_attribute can eventually determine whether a parsed attribute applies to the given target or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198896 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 22:48:32 +00:00
Aaron Ballman 03748d2395 Treating the RegParmAttr as a TypeAttr because that is what it is.
Patch reviewed by Rafael Espindola.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198765 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-08 13:23:01 +00:00
Aaron Ballman ee6c0cade6 Simplifying the mutual exclusion check now that the diagnostics engine knows how to handle Attr objects directly. Updates an associated test case due to the attribute name being properly quoted again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198424 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-03 16:23:46 +00:00
Aaron Ballman a84ef36847 Removed an unnecessary %select from the alignas diagnostics. The attribute already knows how it was spelled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198375 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 23:39:11 +00:00
Aaron Ballman 4d297c3719 Removing some more unnecessary manual quotes from attribute diagnostics. Updated the associated testcase because QualType pretty printing was an improvement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198372 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 23:15:58 +00:00
Aaron Ballman 4418a4ea2b Removing some more unnecessary manual quotes from attribute diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198371 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 23:02:01 +00:00
Aaron Ballman 9a2e6eb4d4 Updated the wording of two attribute-related diagnostics so that they print the offending attribute name. Also updates the associated test cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 21:26:14 +00:00
Aaron Ballman 1d967489ed Removed a string literal for a diagnostic, and updated the diagnostic to not manually quote. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198076 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-27 16:30:46 +00:00
Aaron Ballman 574efb02fa Teach the diagnostics engine about the Attr type to make reporting on semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198055 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 18:30:57 +00:00
Aaron Ballman 1cb27131cc Removed a string literal for an attribute name, which means the attribute name will be quoted in the diagnostic. Manually added some quotes to a diagnostic for consistency. Updated the test cases as appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198054 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 17:30:44 +00:00
Aaron Ballman 2528169585 This diagnostic did not accept arguments, and did not have any test coverage. Parameterized the diagnostic, and made it more consistent with other attribute diagnostic wordings. Added test coverage.
Since this warning was generalized, it was also given a sensible warning group flag and the corresponding test was updated to reflect this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198053 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 17:07:49 +00:00
Aaron Ballman 324ec1a9d4 Simplifying some diagnostics so that they don't need to work with StringRefs. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198051 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 16:30:30 +00:00
Aaron Ballman d8cadcbc55 Getting rid of a string literal in favor of the generalized diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198050 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 16:13:50 +00:00
Aaron Ballman 3fdbcee182 No need for the manual quotes and extra getName() call. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198047 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 15:06:01 +00:00
Aaron Ballman 7853e320e2 Removing some unneeded code, and a diagnostic that was obsoleted. The type has already been determined to be a ValueDecl by virtue of the attribute subjects.
Added some test case coverage as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198046 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-26 14:54:11 +00:00
Aaron Ballman f2f628a1db Consolidating some mode attribute diagnostics. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197911 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-23 15:23:11 +00:00
Aaron Ballman c047507a9a Removing the alloc_size attribute. The attribute was semantically handled, but silently ignored. Most of this feature was already reverted in June 2012 (r159016), this just cleans up the pieces left over.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197866 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-21 17:15:13 +00:00
Aaron Ballman c45cdf724d The const and nothrow attributes can be handled by the simple attribute handler. This removes a silent dropping of the attributes when they are duplicated on a Decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-21 16:49:29 +00:00
Ted Kremenek 45e0c0d87d Remove dead code identified by Aaron Ballman.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197730 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 22:23:12 +00:00
Aaron Ballman 531dac19f5 After discussing with John McCall, removing the ns_bridged attribute as it is unused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197729 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 22:12:51 +00:00
Aaron Ballman 97915e5a02 Replacing calls to getAttr with calls to hasAttr for clarity. No functional change intended -- this only replaces Boolean uses of getAttr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197648 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 02:39:40 +00:00
Aaron Ballman 9be81e1543 Added a comment about the launch_bounds attribute's AST node being required. Since there were no test cases for the attribute, some have been added. This promptly demonstrated a bug with the semantic handling, which is also fixed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197637 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 00:41:31 +00:00
Aaron Ballman 6adb540cf8 Refactor the Microsoft inheritance attribute handling so that it no longer has special treatment. Also fixes a minor bug where the attributes were being parsed as though they were GNU-style attributes when they were in fact keyword attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197629 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 23:44:18 +00:00
Ted Kremenek 00374d1830 Implemented delayed processing of 'unavailable' checking, just like with 'deprecated'.
Fixes <rdar://problem/15584219> and <rdar://problem/12241361>.

This change looks large, but all it does is reuse and consolidate
the delayed diagnostic logic for deprecation warnings with unavailability
warnings.  By doing so, it showed various inconsistencies between the
diagnostics, which were close, but not consistent.  It also revealed
some missing "note:"'s in the deprecated diagnostics that were showing
up in the unavailable diagnostics, etc.

This change also changes the wording of the core deprecation diagnostics.
Instead of saying "function has been explicitly marked deprecated"
we now saw "'X' has been been explicitly marked deprecated".  It
turns out providing a bit more context is useful, and often we
got the actual term wrong or it was not very precise
 (e.g., "function" instead of "destructor").  By just saying the name
of the thing that is deprecated/deleted/unavailable we define
this issue away.  This diagnostic can likely be further wordsmithed
to be shorter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197627 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 23:30:06 +00:00
Joey Gouly 1366f26a78 [OpenCL] Produce an error when the work group and vec type hint attributes
are used on non-kernel functions.

Reviewed by Aaron over IRC!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197243 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 16:15:28 +00:00
Aaron Ballman 7825d70d22 Added a Subjects clause to the section attribute and made its diagnostics more consistent with other attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197104 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 01:34:39 +00:00
Ted Kremenek d40c63b168 Rename attribute 'objc_suppress_protocol_methods' to 'objc_protocol_requires_explicit_implementation'.
That's a mouthful, and not necessarily the final name.  This also
reflects a semantic change where this attribute is now on the
protocol itself instead of a class.  This attribute will require
that a protocol, when adopted by a class, is explicitly implemented
by the class itself (instead of walking the super class chain).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196955 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 19:43:48 +00:00
Argyrios Kyrtzidis c1905867bf Add a SubsetSubject in Attr.td to automate checking of where the objc_designated_initializer
attribute is acceptable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196644 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-07 06:08:04 +00:00
Aaron Ballman 328b3ffb15 Turning the __w64 attribute into an ignored attribute to match other Microsoft extensions we do not currently support. Note that __w64 has been deprecated in MSVC since 2008.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196592 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-06 18:56:03 +00:00
Fariborz Jahanian db5d8792d4 ObjectiveC - Introducing objc_bridge_related attribute
which specifies couple of (optional) method selectors
for bridging a CFobject to or from an ObjectiveC 
object. This is wip. // rdsr://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196408 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-04 20:32:50 +00:00
Argyrios Kyrtzidis 5a02446ef6 [objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get the
designated initializers of an interface.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196315 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 21:11:30 +00:00
Argyrios Kyrtzidis 31d5d5d6f0 [objc] Introduce attribute 'objc_designated_initializer'.
It only applies to methods of init family in an interface declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196314 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 21:11:25 +00:00
Aaron Ballman 2e1373febc Refactored the work group-related attributes to use a template, which reduces the amount of duplicate code in the handler. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196165 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 22:38:33 +00:00
Aaron Ballman 27df2e81c8 Simplifying a test for duplicate vec_type_hint attributes. The assert and attribute kind test were superfluous. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196162 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 22:16:55 +00:00
Aaron Ballman 0fe98d1453 The CUDA device attribute doesn't need custom logic to check the number of attribute arguments (the common attribute handler already does this). Switching to use the simple attribute handler. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196155 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 21:09:08 +00:00
Aaron Ballman 694680f7c4 Automate attribute language option checking by specifying the list of options to test in tablegen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196138 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 19:30:36 +00:00
Aaron Ballman bdc243a320 Factored attribute mutual exclusion code into a helper function; split the cf_audited_transfer and cf_unknown_transfer attributes into separate helper methods for simplicity. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196126 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 18:05:46 +00:00
Aaron Ballman 8443a448fc Re-enabled support for the Subjects for the weak attribute. This changes the diagnostic involved to be more accurate -- for C++ code, it will now report that weak applies to variables, functions or classes. Added additional test case for this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196120 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 17:07:07 +00:00
Aaron Ballman fc0d1b536b The __w64 attribute handler was more generically named, but only applied to __w64 specifically. Renamed and removed some unused code. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196116 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 16:17:55 +00:00
Aaron Ballman 9ecbe1b29a The FieldDecl is already covered by the ValueDecl case, so it is being removed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196110 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 15:31:50 +00:00
Aaron Ballman ad6ee4b599 Switching the ibaction attribute handler to the generalized handler. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196107 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 15:13:14 +00:00
Aaron Ballman b382003f3a Replacing custom subject application logic with table-generated logic. Affects: guarded_var, pt_guarded_var, guarded_by, pt_guarded_by, acquired_after and acquired_before. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196105 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 15:02:49 +00:00
Aaron Ballman 7e6ab6dedc Refactored the tls_model attribute to use a custom subset subject. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195964 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-29 16:20:30 +00:00
Aaron Ballman 3e794b3813 Using a custom subject to reenable the Subjects line for the ns_bridged attribute. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195963 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-29 16:13:12 +00:00
Aaron Ballman 1361a6ffcc Enables support for custom subject lists for attributes. As a testbed, uses the custom subject for the ibaction attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195960 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-29 14:57:58 +00:00
Aaron Ballman f6ddb09a86 Converts the lockable attributes to use the simple attribute handler because the semantic checking was already automated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195866 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 19:35:27 +00:00
Aaron Ballman c29b4f145e Automated checking for C++ when determining what argument to send to the diagnostic for attribute subjects. In turn, this allows the Subjects to be enabled for some more attributes and improves diagnostics. Updated a test case based on the improved diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 19:16:55 +00:00
Aaron Ballman 5c024c8f72 Adding the Subjects entry back for the noreturn attributes. This caused some test cases to be updated because the original diagnostic was about applying to methods as well as functions, but the semantic checking disallowed methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195862 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 18:53:58 +00:00
Aaron Ballman 74e3700e2a Enabling the subject list for the warn_unused attribute, and adding a test case. Previously, would issue a "warning ignored" diagnostic instead of the more specific "only applies to."
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195851 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 16:59:17 +00:00
Aaron Ballman cab9f092e2 Adding in the subject for the init_priority attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195850 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 16:34:09 +00:00
Aaron Ballman 311dd5a8f9 Refactored semantic handlers that would unilaterally apply the attribute to a Decl so they all go through a common interface. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195848 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 15:24:06 +00:00
Alexander Kornienko febf22bf91 Trivial fix: remove unused variable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195846 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 15:02:03 +00:00
Aaron Ballman d2f68321b5 Laying the basic groundwork for table generating the diagnostics for attribute subjects. This makes some modifications to the way subjects are listed in Attr.td, and updates the attr emitter to handle the new constructs.
I have disabled some attribute subject lines on purpose in Attr.td;
this part is a WIP with the goal being to restore those subjects
incrementally. By commenting them out, it leaves the original behavior
the same as before for those attributes and so those are not
functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195841 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 13:27:02 +00:00
Richard Smith 6f39952adb Remove 'DistinctSpellings' support from Attr.td and change its only user to
look at the attribute spelling instead. The 'ownership_*' attributes should
probably be split into separate *Attr classes, but that's more than I wanted to
do here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195805 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 01:46:48 +00:00
Aaron Ballman e89849f12f Replacing a custom diagnostic with a more standard one. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195770 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-26 16:14:15 +00:00
Aaron Ballman 6199e12689 Making type_tag_for_datatype consistent with its declared subject from Attr.td. Also updated the related testcase.
Reviewed by Dmitri Gribenko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195675 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25 18:50:49 +00:00
NAKAMURA Takumi 26f998ce03 SemaDeclAttr.cpp: Try to fix a warning [-Wunnamed-type-template-args]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195589 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25 00:52:29 +00:00
Aaron Ballman 0765cbb56a Switching the common attribute over to using the generic diagnostic, and removing the now-unused diagnostic. Updates a test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195581 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-24 21:48:06 +00:00
Aaron Ballman aa244b4c5d __declspec(uuid) is only supported for C++ code according to MSDN (as well as behaviorally in MSVC). This adds a generic diagnostic that we use for uuid, and can use for some other attributes as well, and adds a testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195580 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-24 21:35:16 +00:00
Aaron Ballman 81e6d92127 __declspec(uuid) is only allowed on a class according to MSDN; this makes the semantic checking consistent with what the attribute specifies in Attr.td. Also adds a test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195579 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-24 20:58:02 +00:00
Aaron Ballman 3ea479818d Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.
Reviewed by Fariborz Jahanian

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195578 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-24 20:36:50 +00:00
Ted Kremenek 34ee86d749 Remove optional parameter bit from attribute ObjCSuppressProtocol.
This refines some diagnostics and reduces some boilerplate checking logic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195560 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23 22:29:11 +00:00
Ted Kremenek 6af631235e Add back experimental attribute objc_suppress_protocol_methods (slightly renamed).
This is still an experimental attribute, but I wanted it in tree
for review.  It may still get yanked.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195533 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23 01:01:34 +00:00
Aaron Ballman 836be9ad77 Whitespace. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195503 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 21:49:04 +00:00
Fariborz Jahanian 8f27871ff0 ObjectiveC migrator. Improve on definition, use
and testing of objc_bridgmutable attribute per
Aaron Ballman's comments.
// rdar://15498044


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195396 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 00:02:22 +00:00
Fariborz Jahanian 51935f33d6 ObjectiveC. Implement attribute 'objc_bridge_mutable'
whose semantic is currently identical to objc_bridge,
but their differences may manifest down the road with
further enhancements. // rdar://15498044


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195376 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 20:50:32 +00:00
Ted Kremenek 6a8fba738b Revert "Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class."
After implementing this patch, a few concerns about the language
feature itself emerged in my head that I had previously not considered.
I want to resolve those design concerns first before having
a half-designed language feature in the tree.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195328 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 07:57:53 +00:00
Ted Kremenek 996665816b Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class.
The idea is to allow a class to stipulate that its methods (and those
of its parents) cannot be used for protocol conformance in a subclass.
A subclass is then explicitly required to re-implement those methods
of they are present in the class marked with this attribute.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195323 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 07:20:42 +00:00
Ted Kremenek 80379e7ac0 Refactor some of handleObjCBridgeAttr to make it more concise and the diagnostic reusable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195322 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 07:20:34 +00:00
Aaron Ballman b2dbde5962 Refactored integer argument checking code into a helper method. Removes a considerable amount of duplicated code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195302 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 01:50:40 +00:00
Aaron Ballman 6e40f59ed4 Implemented DefaultIntArgument in the table generator and start using it in semantic analysis. Removes some magic numbers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195287 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 00:28:23 +00:00
Aaron Ballman 0879e06e8a There is no such thing as __declspec(ms_struct), this is a GNU attribute. Switched the attribute to have the proper spelling, gave it a subject, updated the warning to be more accurate, and updated the test case as appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195277 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 22:22:04 +00:00
Aaron Ballman 6ec3b68006 Removed a duplicate diagnostic related to attribute subjects for thread safety annotations, and replaced it with the more general attribute diagnostic. Updated the test case in the one instance where wording changed. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195275 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 21:41:42 +00:00
Aaron Ballman 898413e5f2 Removing a custom error diagnostic and replacing it with a stock one. Added a test case to ensure the diagnostic was firing properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195188 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 01:35:23 +00:00
Aaron Ballman d46c8e0d67 Switching some string literals to be generated by the AttributeList object itself.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195160 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 22:18:24 +00:00
Fariborz Jahanian 60c3c05556 bjectiveC. Use a uniform diagnostic for
'objc_bridge' attribute. // rdar://15454846.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195135 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 17:42:25 +00:00
Fariborz Jahanian 3daade9020 ObjectiveC 'objc_bridging'. Assorment of improvements
per Doug/Jordan comments. // rdar://15454846.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195066 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 01:23:07 +00:00
Fariborz Jahanian 0f3bb9eb07 ObjectiveC ARC. Adopt objc_bridge attribute
on struct/union/class instead of typedef of
such types. // rdar://15454846


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195061 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 00:09:48 +00:00
Fariborz Jahanian 4b777c05fc ObjectiveC ARC. Only briding of pointer to struct CF object is allowed.
Improve on wording on illegal objc_bridge argumment.
// rdar://15454846


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194881 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15 23:14:45 +00:00
Fariborz Jahanian 7f82297e3f ObjectiveC ARC. objc_bridge attribute should be applied to
toll-free bridging cf types only. // rdar//15454846 wip.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194640 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14 00:43:05 +00:00
Fariborz Jahanian 933a8948fc ObjectiveC ARC. Introduce a new attribute, 'objc_bridge'
that teaches the compiler about a subset of toll-free 
bridging semantics. This is wip. // rdar://15454846


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194633 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13 23:59:17 +00:00
Richard Smith ddc2a53584 Store a TypeArgument on an attribute as a TypeSourceInfo*, rather than as a
QualType with a SourceLocation stashed alongside.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193803 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 21:23:20 +00:00
Richard Smith d386fef64f Factor out custom parsing for iboutletcollection and vec_type_hint attributes
into a separate "parse an attribute that takes a type argument" codepath. This
results in both codepaths being a lot cleaner and simpler, and fixes some bugs
where the type argument handling bled into the expression argument handling and
caused us to both accept invalid and reject valid attribute arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193731 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 01:56:18 +00:00
Chris Wailes 0e429f1f48 Changed tests_typestate to test_typestate for consistency.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193648 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-29 20:28:41 +00:00
Rafael Espindola 87017a781f Revert "This patch causes clang to reject alias attributes that point to undefined names. For example, with this patch we now reject"
This reverts commit r193161.

It broke

void foo() __attribute__((alias("bar")));
void bar() {}
void zed() __attribute__((alias("foo")));

Looks like we have to fix pr17639 first :-(

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193162 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-22 14:23:09 +00:00
Rafael Espindola e37bf44c80 This patch causes clang to reject alias attributes that point to undefined
names. For example, with this patch we now reject

void f1(void) __attribute__((alias("g1")));

This patch is implemented in CodeGen. It is quiet a bit simpler and more
compatible with gcc than implementing it in Sema. The downside is that the
errors only fire during -emit-llvm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193161 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-22 13:51:06 +00:00
Alp Toker 8b407727ae Fix crash in cleanup attr handling
ResolveSingleFunctionTemplateSpecialization() returns 0 and doesn't emit diags
unless the expression has template-ids, so we must null check the result.

Also add a better diag noting which overloads are causing the problem.

Reviewed by Aaron Ballman.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193055 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-20 18:48:56 +00:00
DeLesley Hutchins d4f0e1991f Consumed analysis: Add param_typestate attribute, which specifies that
function parameters must be in a particular state.  Patch by
chris.wailes@gmail.com.  Reviewed by delesley@google.com.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192934 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 23:23:53 +00:00
DeLesley Hutchins cd0f6d7600 Consumed Analysis: Allow parameters that are passed by non-const reference
to be treated as return values, and marked with the "returned_typestate"
attribute.  Patch by chris.wailes@gmail.com; reviewed by delesley@google.com.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192932 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 22:53:04 +00:00
Aaron Ballman 9aa926143b Trivial formatting changes; no functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192640 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-14 23:26:04 +00:00
Aaron Ballman 2b1599c3a0 Switching some custom logic to using table-generated helper methods. This also removes an unnecessary diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192639 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-14 23:22:37 +00:00
DeLesley Hutchins f30e194f9d Consumed analysis: replace the consumes attribute with a set_typestate
attribute.  Patch by chris.wailes@gmail.com; reviewed and edited by delesley.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192515 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-11 23:03:26 +00:00
DeLesley Hutchins 1bf6343612 Consumed analysis: switch from tests_consumed/unconsumed to a general
tests_typestate attribute.  Patch by chris.wailes@gmail.com.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-11 22:30:48 +00:00
Aaron Ballman 9025a18c36 Switching the CallableWhen attribute over to using the string literal helper function instead of custom logic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192050 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-05 22:45:34 +00:00
DeLesley Hutchins 66540857c0 Consumed Analysis: Change callable_when so that it can take a list of states
that a function can be called in.  This reduced the total number of annotations
needed and makes writing more complicated behaviour less burdensome.
Patch by chriswails@gmail.com.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191983 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-04 21:28:06 +00:00
Tim Northover 64eac850a0 Implement ARM GNU-style interrupt attribute
This attribute allows users to use a modified C or C++ function as an ARM
exception-handling function and, with care, to successfully return control to
user-space after the issue has been dealt with.

rdar://problem/14207019

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191769 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 14:34:25 +00:00
Tim Northover f8aebef454 Move checkStringLiteralArgument into Sema class
It's a useful function to have around for target-specific attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191768 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 14:34:18 +00:00
Fariborz Jahanian af1d28f3fd Fixes a buildbot failure (was using local
type in template instantiation).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191022 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19 17:52:50 +00:00
Fariborz Jahanian f35a356878 Refinement to my previous patch for
objc_returns_inner_pointer on properties. // rdar://14990439


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191016 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19 17:18:55 +00:00
Fariborz Jahanian 937ec1d957 ObjectiveC: Allow NS_RETURNS_INNER_POINTER annotation
of ObjectiveC properties to mean annotation of 
NS_RETURNS_INNER_POINTER on its synthesized getter.
This also facilitates more migration to properties when 
methods are annotated with NS_RETURNS_INNER_POINTER. 
// rdar://14990439


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191009 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19 16:37:20 +00:00
Stepan Dyatkovskiy d569295156 Recommited:
Fix for PR16752. Second commit.

PR16752: '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 methods. Methods asks target for proper type for given bit width.
2. Fix handleModeAttr according to new methods in TargetInfo.

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

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

Also test/Sema/attr-mode.c was fixed. 'XC' mode test was disabled for PPC64 machines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190926 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-18 09:08:52 +00:00
Aaron Ballman e1668a3a07 Updated the way the ownership attributes are semantically diagnosed. Added test cases for the semantics checks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190802 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-16 18:11:41 +00:00
Aaron Ballman 422ac9ee19 Switching the WeakRef attribute to using the new checkStringLiteralArgument helper function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190719 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 19:35:18 +00:00
Aaron Ballman fbf6f5c8ac Updated the PCS calling convention to use the new checkStringLiteralArgument helper function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190710 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 17:48:25 +00:00
Benjamin Kramer c561714647 As Aaron pointed out it's simpler to reject wide string availability attr messages in the parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190706 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 17:31:48 +00:00
Benjamin Kramer f37e4f24c3 Guard availability and thread safety attributes against wide strings.
Found by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190701 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 16:30:12 +00:00
Benjamin Kramer 1a343e26c7 Unify handling of string literal arguments for attributes and add fixits.
This fixes a couple of latent crashes for invalid attributes and also adds a
fixit hint to turn identifiers into string literals if one was expected. It then
proceeds recovery as if the identifier was a literal. Diagnostic locations are
also changed to point at the literal instead of the attribute if the error
concerns the argument. PR17175.

For example:
hidden.c:1:40: error: 'visibility' attribute requires a string
extern int x __attribute__((visibility(hidden)));
                                       ^
                                       "     "
hidden.c:2:29: error: visibility does not match previous declaration
extern int x __attribute__((visibility("default")));
                            ^
hidden.c:1:29: note: previous attribute is here
extern int x __attribute__((visibility(hidden)));
                            ^

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190699 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 15:35:43 +00:00
Aaron Ballman d068607c13 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190545 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 19:47:58 +00:00
Aaron Ballman ebaee6b74e The cleanup attribute no longer uses an unresolved, simple identifier as its argument. Instead, it takes an expression that is fully resolved.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190476 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 01:37:41 +00:00
Stepan Dyatkovskiy 8e366f090b Rejected 190391, due to failures on clang-x86_64-darwin11-nobootstrap-RAincremental.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190393 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 08:37:22 +00:00
Stepan Dyatkovskiy 9fd1379694 Fix for PR16752. Second commit.
PR16752: '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 methods. Methods asks target for proper type for given bit width.
2. Fix handleModeAttr according to new methods in TargetInfo.

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

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190391 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 08:18:44 +00:00
Aaron Ballman be116e2aab Adding a FIXME based on feedback from Richard Smith.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190369 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 23:40:31 +00:00
Aaron Ballman bbb3b3237d Attribute tablegen now understands that attribute arguments can be optional. This allows for automated checking of the number of arguments expected vs number of arguments given for attributes. Greatly reduces the amount of manual checking required.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190368 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 23:33:17 +00:00
Benjamin Kramer ae3a83f578 Sema: Don't crash on visibility attributes with an identifier argument.
PR17105.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190312 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 15:08:57 +00:00
Aaron Ballman e5934897fb Removing the endian attribute and updating associated test cases. This functionality was never completely implemented, and this is an improvement over silently eating the attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190303 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 12:57:20 +00:00
David Blaikie a33ab6074a Consumed Analysis: The 'consumable' attribute now takes a identifier specifying the default assumed state for objects of this class
This information is used for return states and pass-by-value parameter
states.

Patch by Chris Wailes.

Review by DeLesley Hutchins and Aaron Ballman.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190116 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-06 01:28:43 +00:00
Aaron Ballman caa5ab264d Switched FormatAttr to using an IdentifierArgument instead of a StringArgument since that is a more accurate modeling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189851 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03 21:02:22 +00:00
DeLesley Hutchins 0e8534efc3 Consumed analysis: add return_typestate attribute.
Patch by chris.wailes@gmail.com

Functions can now declare what state the consumable type the are returning will
be in. This is then used on the caller side and checked on the callee side.
Constructors now use this attribute instead of the 'consumes' attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189843 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03 20:11:38 +00:00
Aaron Ballman 624421f98d Consolidating the notion of a GNU attribute parameter with the attribute argument list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189711 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-31 01:11:41 +00:00
DeLesley Hutchins c55bee6e27 Consumed analysis: add 'consumable' class attribute.
Patch by chris.wailes@gmail.com

Adds the 'consumable' attribute that can be attached to classes.  This replaces
the previous method of scanning a class's methods to see if any of them have
consumed analysis attributes attached to them.  If consumed analysis attributes
are attached to methods of a class that isn't marked 'consumable' a warning
is generated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189702 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30 22:56:34 +00:00
Charles Davis e8519c31a6 Add ms_abi and sysv_abi attribute handling.
Based on a patch by Benno Rice!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189644 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30 04:39:01 +00:00
Richard Smith 4a97b8e75f Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don't
do anything useful.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189548 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-29 00:47:48 +00:00
Aaron Ballman 19513232c6 Mode is now handled as a non-inheritable attribute, and CUDADevice & CUDAHost are now handled as inheritable attributes. In all three cases, this makes the processing behavior more consistent with the declared behavior in Attr.td.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189532 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-28 23:13:26 +00:00
Aaron Ballman 60c444d3f4 Since r179585, __declspec(property) has gotten special treatment as an attribute where it is not processed as part of the typical Sema attribute functionality. Specifying this attribute as being "ignored" because there is no sema handler for it as a Decl attribute, and no AST node generated for it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189284 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-26 22:49:09 +00:00
Aaron Ballman 34776d4294 Updated the consumed analysis warnings to use a more standardized diagnostic.
Patch thanks to Christian Wailes!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188940 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 22:07:20 +00:00
Aaron Ballman 0d28fdfeaa Removed unnecessary asserts.
Patch thanks to Christian Wailes!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188934 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 21:38:46 +00:00
Rafael Espindola 29535baf2a Don't reject attribute used in an "extern const" variable definition.
Before this patch we would warn and drop the attribute in
extern const char test3[] __attribute__((used)) = "";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188588 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16 23:18:50 +00:00
DeLesley Hutchins df7bef07ee Patch by Chris Wailes <chris.wailes@gmail.com>.
Reviewed by delesley, dblaikie.

Add the annotations and code needed to support a basic 'consumed' analysis.

Summary:
This new analysis is based on academic literature on linear types.  It tracks
the state of a value, either as unconsumed, consumed, or unknown.  Methods are
then annotated as CallableWhenUnconsumed, and when an annotated method is
called while the value is in the 'consumed' state a warning is issued.  A value
may be tested in the conditional statement of an if-statement; when this occurs
we know the state of the value in the different branches, and this information
is added to our analysis.  The code is still highly experimental, and the names
of annotations or the algorithm may be subject to change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188206 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 21:20:55 +00:00
David Majnemer bb0ed29042 Sema: Assertion failure during CodeGen in CodeGenModule::EmitUuidofInitializer
Make sure we can properly generate code when the UUID has curly braces
on it, strip the curly braces at the sema layer.

This fixes PR16813.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188061 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-09 08:56:20 +00:00
Aaron Ballman 750f73aadc err_attribute_missing_parameter_name has been replaced by err_attribute_argument_type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187420 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-30 14:29:12 +00:00