Commit Graph

676 Commits

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