summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC; clean up this file based on our coding standards. The impetus was ↵Aaron Ballman2018-02-151-1500/+1467
| | | | | | | | | | considerable use of a type name as an identifier for an object. Changed identifier names (especially function parameters) to not clash with type names and to follow the proper naming conventions. Use of explicit type names changed to use auto where appropriate. Removed unused parameters that should have never been added in the first place. Minor formatting cleanups. The changes were mostly mechanical and should have no functional impact. llvm-svn: 325256
* [CUDA] Allow external variables in separate compilationJonas Hahnfeld2018-02-141-1/+2
| | | | | | | | | | | | According to the CUDA Programming Guide this is prohibited in whole program compilation mode. This makes sense because external references cannot be satisfied in that mode anyway. However, such variables are allowed in separate compilation mode which is a valid use case. Differential Revision: https://reviews.llvm.org/D42923 llvm-svn: 325136
* Implement function attribute artificialErich Keane2018-02-141-0/+3
| | | | | | | | | | | | Added support in clang for GCC function attribute 'artificial'. This attribute is used to control stepping behavior of debugger with respect to inline functions. Patch By: Elizabeth Andrews (eandrews) Differential Revision: https://reviews.llvm.org/D43259 llvm-svn: 325081
* Add support for attribute 'trivial_abi'.Akira Hatanaka2018-02-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The 'trivial_abi' attribute can be applied to a C++ class, struct, or union. It makes special functions of the annotated class (the destructor and copy/move constructors) to be trivial for the purpose of calls and, as a result, enables the annotated class or containing classes to be passed or returned using the C ABI for the underlying type. When a type that is considered trivial for the purpose of calls despite having a non-trivial destructor (which happens only when the class type or one of its subobjects is a 'trivial_abi' class) is passed to a function, the callee is responsible for destroying the object. For more background, see the discussions that took place on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043 rdar://problem/35204524 Differential Revision: https://reviews.llvm.org/D41039 llvm-svn: 324269
* [Refactor] Use enum instead of magic number in ↵Hongbin Zheng2018-01-191-1/+1
| | | | | | | | handleX86ForceAlignArgPointerAttr, NFC Differential revision: https://reviews.llvm.org/D42227 llvm-svn: 322918
* Add support for ObjectFormat to TargetSpecificAttrErich Keane2017-12-201-6/+0
| | | | | | | | | | | | | | | | Looking through the code, I saw a FIXME on IFunc to switch it to a target specific attribute. In looking through it, i saw that the no-longer-appropriately-named TargetArch didn't support ObjectFormat checking. This patch changes the name of TargetArch to TargetSpecific (since it checks much more than just Arch), makes "Arch" optional, adds support for ObjectFormat, better documents the TargetSpecific type, and changes IFunc over to a TargetSpecificAttr. Differential Revision: https://reviews.llvm.org/D41303 llvm-svn: 321201
* [ThreadSafetyAnalysis] Fix isCapabilityExprYi Kong2017-12-141-5/+4
| | | | | | | | | | | | There are many more expr types that can be a capability expr, like CXXThisExpr, CallExpr, MemberExpr. Instead of enumerating all of them, just check typeHasCapability for any type given. Also add & and * operators to allowed unary operators. Differential Revision: https://reviews.llvm.org/D41224 llvm-svn: 320753
* Now that C++17 is official (https://www.iso.org/standard/68564.html), start ↵Aaron Ballman2017-12-041-7/+7
| | | | | | changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. llvm-svn: 319688
* Disallow a cleanup attribute from appertaining to a parameter (the attribute ↵Aaron Ballman2017-12-011-7/+1
| | | | | | only appertains to local variables and is silently a noop on parameters). This repurposes the unused (and syntactically incorrect) NormalVar attribute subject. llvm-svn: 319555
* Convert clang::LangAS to a strongly typed enumAlexander Richardson2017-10-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Convert clang::LangAS to a strongly typed enum Currently both clang AST address spaces and target specific address spaces are represented as unsigned which can lead to subtle errors if the wrong type is passed. It is especially confusing in the CodeGen files as it is not possible to see what kind of address space should be passed to a function without looking at the implementation. I originally made this change for our LLVM fork for the CHERI architecture where we make extensive use of address spaces to differentiate between capabilities and pointers. When merging the upstream changes I usually run into some test failures or runtime crashes because the wrong kind of address space is passed to a function. By converting the LangAS enum to a C++11 we can catch these errors at compile time. Additionally, it is now obvious from the function signature which kind of address space it expects. I found the following errors while writing this patch: - ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address space to TargetInfo::getPointer{Width,Align}() - TypePrinter::printAttributedAfter() prints the numeric value of the clang AST address space instead of the target address space. However, this code is not used so I kept the current behaviour - initializeForBlockHeader() in CGBlocks.cpp was passing LangAS::opencl_generic to TargetInfo::getPointer{Width,Align}() - CodeGenFunction::EmitBlockLiteral() was passing a AST address space to TargetInfo::getPointerWidth() - CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space to Qualifiers::addAddressSpace() - CGOpenMPRuntimeNVPTX::getParameterAddress() was using llvm::Type::getPointerTo() with a AST address space - clang_getAddressSpace() returns either a LangAS or a target address space. As this is exposed to C I have kept the current behaviour and added a comment stating that it is probably not correct. Other than this the patch should not cause any functional changes. Reviewers: yaxunl, pcc, bader Reviewed By: yaxunl, bader Subscribers: jlebar, jholewinski, nhaehnle, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D38816 llvm-svn: 315871
* Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers"Reid Kleckner2017-10-021-20/+1
| | | | | | | | | | | This reverts r314461. It is warning on user code that uses END_COM_MAP(), which expands to declare QueryInterface with conflicting exception specifers. I've spent a while trying to understand why, but haven't been able to extract a reduced test case. Let's revert and I'll keep trying. llvm-svn: 314689
* [Sema] Warn on attribute nothrow conflicting with language specifiersErich Keane2017-09-281-1/+20
| | | | | | | | | | | | | | I discovered it was possible to create a 'nothrow' noexcept(false) function, which is both non-sensical as well as seemingly breaking. This patch warns if attribute nothrow is used with anything besides "noexcept". "noexcept(true)" isn't possible, because the noexcept decl isn't parsed until later. Differential Revision: https://reviews.llvm.org/D38205 llvm-svn: 314461
* Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]Erich Keane2017-09-271-44/+44
| | | | llvm-svn: 314267
* Add support for attribute 'noescape'.Akira Hatanaka2017-09-221-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. This recommits r313722, which was reverted in r313725 because clang couldn't build compiler-rt. It failed to build because there were function declarations that were missing 'noescape'. That has been fixed in r313929. rdar://problem/19886775 Differential Revision: https://reviews.llvm.org/D32210 llvm-svn: 313945
* Revert "Add support for attribute 'noescape'."Akira Hatanaka2017-09-201-19/+0
| | | | | | | | | | This reverts commit r313722. It looks like compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc cannot be compiled because some of the functions declared in the file do not match the ones in the SDK headers (which are annotated with 'noescape'). llvm-svn: 313725
* 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
OpenPOWER on IntegriCloud