summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for attribute 'noescape'.Akira Hatanaka2017-09-201-0/+19
| | | | | | | | | | | | | | | The attribute informs the compiler that the annotated pointer parameter of a function cannot escape and enables IRGen to attach attribute 'nocapture' to parameters that are annotated with the attribute. That is the only optimization that currently takes advantage of 'noescape', but there are other optimizations that will be added later that improves IRGen for ObjC blocks. rdar://problem/19886775 Differential Revision: https://reviews.llvm.org/D32210 llvm-svn: 313722
* Revert "Add support for attribute 'noescape'."Akira Hatanaka2017-09-201-19/+0
| | | | | | | | This reverts r313717. I closed the wrong phabricator review. llvm-svn: 313721
* Add support for attribute 'noescape'.Akira Hatanaka2017-09-201-0/+19
| | | | | | | | | | | | | | | The attribute informs the compiler that the annotated pointer parameter of a function cannot escape and enables IRGen to attach attribute 'nocapture' to parameters that are annotated with the attribute. That is the only optimization that currently takes advantage of 'noescape', but there are other optimizations that will be added later that improves IRGen for ObjC blocks. rdar://problem/19886775 Differential Revision: https://reviews.llvm.org/D32520 llvm-svn: 313720
* [Sema] Don't emit -Wunguarded-availability for switch casesErik Pilkington2017-08-181-0/+4
| | | | | | | | | This made it awkward to switch over an enum where some entries are partial and is unlikley to catch any bugs. Differential revision: https://reviews.llvm.org/D36777 llvm-svn: 311191
* Unguarded availability diagnoser should use TraverseStmt instead ofAlex Lorenz2017-08-171-2/+1
| | | | | | | | | Base::TraverseStmt when visiting the then/else branches of if statements This ensures that the statement stack is correctly tracked and correct multi-statement fixit is generated inside of an if (@available) llvm-svn: 311088
* [Sema] Improve some -Wunguarded-availability diagnosticsErik Pilkington2017-08-141-75/+78
| | | | | | | rdar://33543523 Differential revision: https://reviews.llvm.org/D36200 llvm-svn: 310874
* Rename cxx1z -> cxx17 across all diagnostic IDs.Richard Smith2017-08-131-2/+2
| | | | llvm-svn: 310805
* Revert "Thread Safety Analysis: warn on nonsensical attributes."Josh Gao2017-08-111-46/+11
| | | | | | | This reverts commit rL310403, which caused spurious warnings in libc++, because it didn't properly handle templated scoped lockable types. llvm-svn: 310698
* Thread Safety Analysis: warn on nonsensical attributes.Josh Gao2017-08-081-11/+46
| | | | | | | | | | | | | Add warnings in cases where an implicit `this` argument is expected to attributes because either `this` doesn't exist because the attribute is on a free function, or because `this` is on a type that doesn't have a corresponding capability/lockable/scoped_lockable attribute. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310403
* Reland "Thread Safety Analysis: fix assert_capability."Josh Gao2017-08-081-1/+5
| | | | | | | | | | | Delete the test that was broken by rL309725, and add it back in a follow up commit. Also, improve the tests a bit. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310402
* Restore previous structure ABI behavior for bit-fields with the packed ↵Aaron Ballman2017-08-081-7/+21
| | | | | | | | | | attribute for PS4 targets. An ABI change was introduced in r254596 that modified structure layouts when the 'packed' attribute was used on one-byte bitfields. Since the PS4 target needs to maintain backwards compatibility for all structure layouts, this change reintroduces the old behavior for PS4 targets only. It also introduces PS4 specific cases to the relevant test. Patch by Matthew Voss. llvm-svn: 310388
* Revert "Thread Safety Analysis: fix assert_capability."Josh Gao2017-08-011-5/+1
| | | | | | | | This reverts commit rL309725. Broke test/Sema/attr-capabilities.c. llvm-svn: 309731
* Thread Safety Analysis: fix assert_capability.Josh Gao2017-08-011-1/+5
| | | | | | | | | | | | | | | | Summary: Previously, the assert_capability attribute was completely ignored by thread safety analysis. Reviewers: delesley, rnk Reviewed By: delesley Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36122 llvm-svn: 309725
* unguarded availability: add a fixit for the "annotate '...'Alex Lorenz2017-07-261-2/+66
| | | | | | | | | | with an availability attribute to silence" note rdar://33539233 Differential Revision: https://reviews.llvm.org/D35726 llvm-svn: 309116
* [CodeGen][mips] Support `long_call/far/near` attributesSimon Atanasyan2017-07-201-0/+8
| | | | | | | | | | | This patch adds support for the `long_call`, `far`, and `near` attributes for MIPS targets. The `long_call` and `far` attributes are synonyms. All these attributes override `-mlong-calls` / `-mno-long-calls` command line options for particular function. Differential revision: https://reviews.llvm.org/D35479 llvm-svn: 308667
* Improve SEMA for attribute-targetErich Keane2017-07-191-8/+29
| | | | | | | | Add more diagnosis for the non-multiversioning case. Differential Revision: https://reviews.llvm.org/D35573 llvm-svn: 308539
* [Sema] NFC: Move all availability checking code to SemaDeclAttr.cppErik Pilkington2017-07-181-12/+97
| | | | | | Previously, this was awkwardly split up between SemaExpr.cpp. llvm-svn: 308356
* [AArch64] Add support for __builtin_ms_va_list on aarch64Martin Storsjo2017-07-171-1/+1
| | | | | | | | | | | Move builtins from the x86 specific scope into the global scope. Their use is still limited to x86_64 and aarch64 though. This allows wine on aarch64 to properly handle variadic functions. Differential Revision: https://reviews.llvm.org/D34475 llvm-svn: 308218
* Use ARC parsing rules for ns_returns_retained in MRC so that code canJohn McCall2017-07-151-0/+15
| | | | | | | | be shared without warnings. Build AttributedTypes to leave breadcrumbs for tools like the static analyzer. Warn about attempting to use the attribute with incompatible return types. llvm-svn: 308092
* [Sema] Don't allow -Wunguarded-availability to be silenced with redeclsErik Pilkington2017-07-051-36/+79
| | | | | | Differential revision: https://reviews.llvm.org/D33816 llvm-svn: 307175
* fix trivial typos, NFCHiroshi Inoue2017-06-301-1/+1
| | | | llvm-svn: 306789
* [Sema] Add -Wunguarded-availability-newAlex Lorenz2017-06-221-5/+55
| | | | | | | | | | | | | | | The new compiler warning -Wunguarded-availability-new is a subset of -Wunguarded-availability. It is on by default. It only warns about uses of APIs that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and tvOS >= 11. We decided to use this kind of solution as we didn't want to turn on -Wunguarded-availability by default, because we didn't want our users to get warnings about uses of old APIs in their existing projects. rdar://31054725 Differential Revision: https://reviews.llvm.org/D34264 llvm-svn: 306033
* [XRay][clang] Support capturing the implicit `this` argument to C++ class ↵Dean Michael Berris2017-06-161-6/+8
| | | | | | | | | | | | | | | | | | member functions Summary: Before this change, we couldn't capture the `this` pointer that's implicitly the first argument of class member functions. There are some interesting things we can do with capturing even just this single argument for zero-argument member functions. Reviewers: rnk, pelikan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34052 llvm-svn: 305544
* Make helper functions static. NFC.Benjamin Kramer2017-05-261-1/+1
| | | | llvm-svn: 304028
* Address follow-up feedback for r303712Argyrios Kyrtzidis2017-05-241-1/+1
| | | | llvm-svn: 303789
* Warn about uses of `@available` that can't suppress theAlex Lorenz2017-05-241-0/+6
| | | | | | | | | | -Wunguarded-availability warnings rdar://32306520 Differential Revision: https://reviews.llvm.org/D33450 llvm-svn: 303761
* Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods ↵Argyrios Kyrtzidis2017-05-241-4/+5
| | | | | | | | and properties as well This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods. llvm-svn: 303712
* [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the ↵Erik Pilkington2017-05-221-0/+9
| | | | | | | | wrong location Differential revision: https://reviews.llvm.org/D33250 llvm-svn: 303562
* [mips] Support `micromips` attributeSimon Atanasyan2017-05-221-2/+8
| | | | | | | | | This patch adds support for the `micromips` and `nomicromips` attributes for MIPS targets. Differential revision: https://reviews.llvm.org/D33363 llvm-svn: 303546
* [Sema] Avoid duplicate -Wunguarded-availability warnings in nested functionsAlex Lorenz2017-05-161-0/+9
| | | | | | rdar://31862310 llvm-svn: 303170
* Add support for pretty platform names to `@available`/Alex Lorenz2017-05-091-1/+3
| | | | | | | | | | | | | `__builtin_available` This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in `@available`/`__builtin_available`. rdar://32067795 Differential Revision: https://reviews.llvm.org/D33000 llvm-svn: 302540
* ANSIfy. No behavior change.Nico Weber2017-05-051-1/+1
| | | | llvm-svn: 302258
* Warn that the [] spelling of uuid(...) is deprecated.Nico Weber2017-05-051-0/+9
| | | | | | https://reviews.llvm.org/D32879 llvm-svn: 302255
* Add a fix-it for -Wunguarded-availabilityAlex Lorenz2017-05-051-3/+140
| | | | | | | | | | | | | This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it is similar to the Swift one: it suggests that you wrap the statement in an `if (@available)` check. The produced fixits are indented (just like the Swift ones) to make them look nice in Xcode's fix-it preview. rdar://31680358 Differential Revision: https://reviews.llvm.org/D32424 llvm-svn: 302253
* [OpenCL] Add intel_reqd_sub_group_size attribute supportXiuli Pan2017-05-041-0/+28
| | | | | | | | | | | | | | | | Summary: Add intel_reqd_sub_group_size attribute support as intel extension cl_intel_required_subgroup_size from https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt Reviewers: Anastasia, bader, hfinkel, pxli168 Reviewed By: Anastasia, bader, pxli168 Subscribers: cfe-commits, yaxunl Differential Revision: https://reviews.llvm.org/D30805 llvm-svn: 302125
* [X86] Support of no_caller_saved_registers attributeOren Ben Simhon2017-04-271-5/+33
| | | | | | | | | Implements the Clang part for no_caller_saved_registers attribute as appears here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be. Differential Revision: https://reviews.llvm.org/D31871 llvm-svn: 301535
* -Wunguarded-availability should support if (@available) checks in top-levelAlex Lorenz2017-04-261-0/+2
| | | | | | | | | | | | | blocks and lambdas Prior to this commit Clang emitted the old "partial availability" warning for expressions that referred to declarations that were not yet introduced in blocks and lambdas that were not in a function/method. This commit ensures that top-level blocks and lambdas use the new unguarded availability checks. rdar://31835952 llvm-svn: 301409
* Add #pragma clang attribute support to the availability attributeAlex Lorenz2017-04-201-3/+1
| | | | | | rdar://31707804 llvm-svn: 300826
* Add #pragma clang attribute support to the external_source_symbol attributeAlex Lorenz2017-04-191-14/+7
| | | | | | | | | | | | | | | | | | | Prior to this commit the external_source_symbol attribute wasn't supported by #pragma clang attribute for the following two reasons: - The Named attribute subject hasn't been supported by TableGen. - There was no way to specify a subject match rule for #pragma clang attribute that could operate on a set of attribute subjects (e.g. the ones that derive from NamedDecl). This commit fixes the two issues and thus adds external_source_symbol support to #pragma clang attribute. rdar://31169028 Differential Revision: https://reviews.llvm.org/D32176 llvm-svn: 300712
* Add #pragma clang attributeAlex Lorenz2017-04-181-0/+3
| | | | | | | | | | | | | | | | | This is a recommit of r300539 that was reverted in r300543 due to test failures. The original commit message is displayed below: The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300556
* Revert r300539 - Add #pragma clang attributeAlex Lorenz2017-04-181-3/+0
| | | | | | | Some tests fail on the Windows buildbots. I will have to investigate more. This commit reverts r300539, r300540 and r300542. llvm-svn: 300543
* Add #pragma clang attributeAlex Lorenz2017-04-181-0/+3
| | | | | | | | | | | | | | The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300539
* Sema: prevent __declspec(naked) use on x64Saleem Abdulrasool2017-04-071-0/+11
| | | | | | | | | MSDN (https://msdn.microsoft.com/en-us/library/h5w10wxs.aspx) indicates that `__declspec(naked)` is only permitted on x86 and ARM targets. Testing with cl does confirm this behaviour. Provide a warning for use of `__declspec(naked)` on x64. llvm-svn: 299774
* Clang changes for alloc_align attribute Erich Keane2017-03-301-30/+117
| | | | | | | | GCC has the alloc_align attribute, which is similar to assume_aligned, except the attribute's parameter is the index of the integer parameter that needs aligning to. Differential Revision: https://reviews.llvm.org/D29599 llvm-svn: 299117
* Add [[clang::suppress(rule, ...)]] attributeMatthias Gehre2017-03-271-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements parsing of [[clang::suppress(rule, ...)]] and [[gsl::suppress(rule, ...)]] attributes. C++ Core Guidelines depend heavily on tool support for rule enforcement. They also propose a way to suppress warnings [1] which is by annotating any ancestor in AST with the C++11 attribute [[gsl::suppress(rule1,...)]]. To have a mechanism to suppress non-C++ Core Guidelines specific, an additional spelling of [[clang::suppress]] is defined. For example, to suppress the warning cppcoreguidelines-slicing, one could do ``` [[clang::suppress("cppcoreguidelines-slicing")]] void f() { ... code that does slicing ... } ``` or ``` void g() { Derived b; [[clang::suppress("cppcoreguidelines-slicing")]] Base a{b}; [[clang::suppress("cppcoreguidelines-slicing")]] { doSomething(); Base a2{b}; } } ``` This parsing can then be used by clang-tidy, which includes multiple C++ Core Guidelines rules, to suppress warnings (see https://reviews.llvm.org/D24888). For the exact naming of the rule in the attribute, there are different possibilities, which will be defined in the corresponding clang-tidy patch. Currently, clang-tidy supports suppressing of warnings through "// NOLINT" comments. There are some advantages that the attribute has: - Suppressing specific warnings instead of all warnings - Suppressing warnings in a block (namespace, function, compound statement) - Code formatting may split a statement into multiple lines, thus a "// NOLINT" comment may be on the wrong line I'm looking forward to your comments! [1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement Reviewers: alexfh, aaron.ballman, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24886 llvm-svn: 298880
* Correct class-template deprecation behavior-REDUXErich Keane2017-03-231-1/+4
| | | | | | | | | | | | | | | | | | Correct class-template deprecation behavior Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case: template<typename T> [[deprecated]] class Foo{}; Foo<int> f; This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute. Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute. Previous DiffRev: https://reviews.llvm.org/D27486, was reverted. This patch fixes the issues brought up here by the reverter: https://reviews.llvm.org/rL298410 Differential Revision: https://reviews.llvm.org/D31245 llvm-svn: 298634
* Revert "Correct class-template deprecation behavior"Martin Bohme2017-03-221-4/+1
| | | | | | | This reverts commit r298410 (which produces incorrect warnings, see comments on https://reviews.llvm.org/rL298410). llvm-svn: 298504
* Correct class-template deprecation behaviorErich Keane2017-03-211-1/+4
| | | | | | | | | | | | | Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case: template<typename T> [[deprecated]] class Foo{}; Foo<int> f; This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute. Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute. Differential Revision: https://reviews.llvm.org/D27486 llvm-svn: 298410
* Add support for attribute enum_extensibility.Akira Hatanaka2017-03-211-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds support for a new attribute that will be used to distinguish between extensible and inextensible enums. There are three main purposes of this attribute: 1. Give better control over when enum-related warnings are issued. For example, in the code below, clang will not issue a -Wassign-enum warning if the enum is marked "open": enum __attribute__((enum_extensibility(closed))) EnumClosed { B0 = 1, B1 = 10 }; enum __attribute__((enum_extensibility(open))) EnumOpen { C0 = 1, C1 = 10 }; enum EnumClosed ec = 100; // warning issued enum EnumOpen eo = 100; // no warning 2. Enable code-completion and debugging tools to offer better suggestions. 3. Make it easier for swift's clang importer to determine which swift type an enum should be mapped to. For more details, see the discussion I started on cfe-dev: http://lists.llvm.org/pipermail/cfe-dev/2017-February/052748.html rdar://problem/12764379 rdar://problem/23145650 Differential Revision: https://reviews.llvm.org/D30766 llvm-svn: 298332
* [XRay] [clang] Allow logging the first argument of a function call.Dean Michael Berris2017-03-061-0/+16
| | | | | | | | | | | | | | | | Summary: Functions with the "xray_log_args" attribute will tell LLVM to emit a special XRay sled for compiler-rt to copy any call arguments to your logging handler. Reviewers: dberris Reviewed By: dberris Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29704 llvm-svn: 296999
OpenPOWER on IntegriCloud