Commit Graph

753 Commits

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