summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[Attr] Add support for the `ms_hook_prologue` attribute."Charles Davis2016-08-081-8/+11
| | | | | | | This reverts commit r278050. It depends on r278048, which will be reverted. llvm-svn: 278052
* [Attr] Add support for the `ms_hook_prologue` attribute.Charles Davis2016-08-081-11/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: Based on a patch by Michael Mueller. This attribute specifies that a function can be hooked or patched. This mechanism was originally devised by Microsoft for hotpatching their binaries (which they're constantly updating to stay ahead of crackers, script kiddies, and other ne'er-do-wells on the Internet), but it's now commonly abused by Windows programs that want to hook API functions. It is for this reason that this attribute was added to GCC--hence the name, `ms_hook_prologue`. Depends on D19908. Reviewers: rnk, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D19909 llvm-svn: 278050
* [NFC][ObjC Availability] Refactor DiagnoseAvailabilityOfDeclErik Pilkington2016-08-051-14/+18
| | | | | | Differential revision: https://reviews.llvm.org/D23221 llvm-svn: 277887
* [ObjC Availability] Fix partial-availability false positive introduced in ↵Erik Pilkington2016-08-011-1/+1
| | | | | | | | | | r277058 Thanks to Nico Weber for pointing this out! Differential revision: https://reviews.llvm.org/D23024 llvm-svn: 277378
* Reapply r277058: "[ObjC] Consider availability of context when emitting ↵Erik Pilkington2016-07-291-0/+23
| | | | | | availability warnings" llvm-svn: 277175
* Revert "[ObjC] Consider availability of context when emitting availability ↵Erik Pilkington2016-07-281-23/+0
| | | | | | | | | | warnings" Reverting r277058, while I fugure out why it broke internal bots. This reverts commit e514ffa8b657416c6784bbe6da9f5de19365103d. llvm-svn: 277070
* [ObjC] Consider availability of context when emitting availability warningsErik Pilkington2016-07-281-0/+23
| | | | | | | | | | This means that a function marked with an availability attribute can safely refer to a declaration that is greater than the deployment target, but less then or equal to the context availability without -Wpartial-availability firing. Differential revision: https://reviews.llvm.org/D22697 llvm-svn: 277058
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+2
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Add XRay flags to Clang. We implement two flags to control the XRay behaviour:Aaron Ballman2016-07-131-1/+4
| | | | | | | | | | | -fxray-instrument: enables XRay annotation of IR -fxray-instruction-threshold: configures the threshold for function size (looking at IR instructions), and allow LLVM to decide whether to add the nop sleds later on in the process. Also implements the related xray_always_instrument and xray_never_instrument function attributes. Patch by Dean Michael Berris. llvm-svn: 275330
* [GCC] PR23529 Mangler part of attrbute abi_tag supportDmitry Polukhin2016-06-301-4/+0
| | | | | | | | | | | | | | | | | Original patch by Stefan Bühler http://reviews.llvm.org/D12834 Difference between original and this one: - fixed all failing tests - fixed mangling for global variable outside namespace - emit ABI tags for guards and local names - clang-format + other stylistic changes - significantly reworked patch according to Richard's suggestions Sema part, committed before http://reviews.llvm.org/D17567 Differential revision: http://reviews.llvm.org/D18035 llvm-svn: 274222
* Revise RenderScript attribute declarationPirama Arumuga Nainar2016-06-101-13/+2
| | | | | | | | | | | | | | | | Summary: Address post-patch comments to r272342. - Rename the 'kernel' attribute's name - Idiomatically restrict the attribute to the 'RenderScript' LangOpt. Reviewers: aaron.ballman, rsmith Subscribers: cfe-commits, srhines Differential Revision: http://reviews.llvm.org/D21240 llvm-svn: 272438
* Remove a few gendered pronouns.Nico Weber2016-06-101-4/+3
| | | | llvm-svn: 272415
* RenderScript support in the FrontendPirama Arumuga Nainar2016-06-091-0/+15
| | | | | | | | | | | | | | | | | | | | | Summary: Create a new Frontend LangOpt to specify the renderscript language. It is enabled by the "-x renderscript" option from the driver. Add a "kernel" function attribute only for RenderScript (an "ignored attribute" warning is generated otherwise). Make the NativeHalfType and NativeHalfArgsAndReturns LangOpts be implied by the RenderScript LangOpt. Reviewers: rsmith Subscribers: cfe-commits, srhines Differential Revision: http://reviews.llvm.org/D21198 llvm-svn: 272342
* [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.Artem Belevich2016-06-061-14/+27
| | | | | | | | Fixes clang crash reported in PR27778. Differential Revision: http://reviews.llvm.org/D20985 llvm-svn: 271951
* [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version)David Majnemer2016-05-231-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The layout_version attribute is pretty straightforward: use the layout rules from version XYZ of MSVC when used like struct __declspec(layout_version(XYZ)) S {}; The empty_bases attribute is more interesting. It tries to get the C++ empty base optimization to fire more often by tweaking the MSVC ABI rules in subtle ways: 1. Disable the leading and trailing zero-sized object flags if a class is marked __declspec(empty_bases) and is empty. This means that given: struct __declspec(empty_bases) A {}; struct __declspec(empty_bases) B {}; struct C : A, B {}; 'C' will have size 1 and nvsize 0 despite not being annotated __declspec(empty_bases). 2. When laying out virtual or non-virtual bases, disable the injection of padding between classes if the most derived class is marked __declspec(empty_bases). This means that given: struct A {}; struct B {}; struct __declspec(empty_bases) C : A, B {}; 'C' will have size 1 and nvsize 0. 3. When calculating the offset of a non-virtual base, choose offset zero if the most derived class is marked __declspec(empty_bases) and the base is empty _and_ has an nvsize of 0. Because of the ABI rules, this does not mean that empty bases reliably get placed at offset 0! For example: struct A {}; struct B {}; struct __declspec(empty_bases) C : A, B { virtual ~C(); }; 'C' will be pointer sized to account for the vfptr at offset 0. 'A' and 'B' will _not_ be at offset 0 despite being empty! Instead, they will be located right after the vfptr. This occurs due to the interaction betweeen non-virtual base layout and virtual function pointer injection: injection occurs after the nv-bases and shifts them down by the size of a pointer. llvm-svn: 270457
* Support for MSVS default calling convention options (/Gd, /Gz, /Gv,Alexey Bataev2016-05-181-5/+6
| | | | | | | | | /Gr), by Alexander Makarov Patch for bug #27711 Differential Revision: http://reviews.llvm.org/D20171 llvm-svn: 269891
* Availability: set location when creating attribute for tvos, watchos.Manman Ren2016-05-061-5/+11
| | | | | | | | | | | | When inferring availability attributes for tvos, watchos from ios, we use the same source location and set the implicit bit to true. So when emitting diagnostics on inferred attributes, we have a source location. rdar://25893544 llvm-svn: 268793
* Availability: attach the note to the declaration with the attributes.Manman Ren2016-05-061-3/+50
| | | | | | | | | | | | | Sometimes, the declaration we found has inherited availability attributes, attaching the note to it does not tell us where the availability attributes are in the source. Go through the redecl chain to find the declaration with actual availability attributes. rdar://25221771 llvm-svn: 268786
* Add a Subjects line to NoDebugAttr [NFC].Paul Robinson2016-04-291-12/+0
| | | | | | | | | | | The 'nodebug' attribute had hand-coded constraints; replace those with a Subjects line in Attr.td. Also add a missing test to verify the attribute is okay on an Objective-C method. Differential Revision: http://reviews.llvm.org/D19689 llvm-svn: 268065
* Re-apply r267784, r267824 and r267830.Peter Collingbourne2016-04-281-0/+3
| | | | | | I have updated the compiler-rt tests. llvm-svn: 267903
* Revert r267784, r267824 and r267830.Benjamin Kramer2016-04-281-3/+0
| | | | | | | | | | It makes compiler-rt tests fail if the gold plugin is enabled. Revert "Rework interface for bitset-using features to use a notion of LTO visibility." Revert "Driver: only produce CFI -fvisibility= error when compiling." Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi." llvm-svn: 267871
* Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne2016-04-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bitsets, and the compiler features they rely on (vtable opt, CFI), only have visibility within the LTO'd part of the linkage unit. Therefore, only enable these features for classes with hidden LTO visibility. This notion is based on object file visibility or (on Windows) dllimport/dllexport attributes. We provide the [[clang::lto_visibility_public]] attribute to override the compiler's LTO visibility inference in cases where the class is defined in the non-LTO'd part of the linkage unit, or where the ABI supports calling classes derived from abstract base classes with hidden visibility in other linkage units (e.g. COM on Windows). If the cross-DSO CFI mode is enabled, bitset checks are emitted even for classes with public LTO visibility, as that mode uses a separate mechanism to cause bitsets to be exported. This mechanism replaces the whole-program-vtables blacklist, so remove the -fwhole-program-vtables-blacklist flag. Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the support for the special attr:uuid blacklist entry is removed. Differential Revision: http://reviews.llvm.org/D18635 llvm-svn: 267784
* [GCC] Attribute ifunc support in clangDmitry Polukhin2016-04-111-2/+27
| | | | | | | | | | | This patch add support for GCC attribute((ifunc("resolver"))) for targets that use ELF as object file format. In general ifunc is a special kind of function alias with type @gnu_indirect_function. LLVM patch http://reviews.llvm.org/D15525 Differential Revision: http://reviews.llvm.org/D15524 llvm-svn: 265917
* [Objective-C] Introduce objc_runtime_visible attribute.Douglas Gregor2016-04-011-0/+3
| | | | | | | | | | | | | | | | | | | | The objc_runtime_visible attribute deals with an odd corner case where a particular Objective-C class is known to the Objective-C runtime (and, therefore, accessible by name) but its symbol has been hidden for some reason. For such classes, teach CodeGen to use objc_lookUpClass to retrieve the Class object, rather than referencing the class symbol directly. Classes annotated with objc_runtime_visible have two major limitations that fall out from places where Objective-C metadata needs to refer to the class (or metaclass) symbol directly: * One cannot implement a subclass of an objc_runtime_visible class. * One cannot implement a category on an objc_runtime_visible class. Implements rdar://problem/25494092. llvm-svn: 265201
* [OpenCL] Moved nosvm attribute handling in Sema to other OpenCL attrsAnastasia Stulova2016-04-011-3/+3
| | | | llvm-svn: 265146
* [OpenCL] Added nosvm attribute for OpenCL v2.0.Anastasia Stulova2016-03-311-0/+12
| | | | | | | | | | | | | It is not widely used and removed from OpenCL v2.1. This change modifies Clang to parse the attribute for OpenCL but ignores it afterwards. Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D17861 llvm-svn: 265006
* Add replacement = "xxx" to AvailabilityAttr.Manman Ren2016-03-211-2/+12
| | | | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This was commited in r263687 and reverted in 263752 due to misaligned access. rdar://20588929 llvm-svn: 263958
* Revert r263687 for ubsan bot failure.Manman Ren2016-03-171-12/+2
| | | | llvm-svn: 263752
* Add an optional named argument (replacement = "xxx") to AvailabilityAttr.Manman Ren2016-03-171-2/+12
| | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This enables the compiler to provide Fix-Its for deprecated declarations. rdar://20588929 llvm-svn: 263687
* Add an optional string argument to DeprecatedAttr for Fix-It.Manman Ren2016-03-161-4/+36
| | | | | | | | We only add this to __attribute__((deprecated)). Differential Revision: http://reviews.llvm.org/D17865 llvm-svn: 263652
* Add attributes for preserve_mostcc/preserve_allcc calling conventions to the ↵Roman Levenstein2016-03-161-1/+12
| | | | | | | | | | | | | | | C/C++ front-end Till now, preserve_mostcc/preserve_allcc calling convention attributes were only available at the LLVM IR level. This patch adds attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end. The code was mostly written by Juergen Ributzka. I just added support for the AArch64 target and tests. Differential Revision: http://reviews.llvm.org/D18025 llvm-svn: 263647
* Implement support for [[maybe_unused]] in C++1z that is based off existing ↵Aaron Ballman2016-03-091-1/+23
| | | | | | support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects. llvm-svn: 263025
* [GCC] PR23529 Sema part of attrbute abi_tag supportDmitry Polukhin2016-03-091-0/+39
| | | | | | | | | | | | | | | | | Original patch by Stefan Bühler http://reviews.llvm.org/D12834 Difference between original and this one: - fixed all comments in original code review - added more tests, all new diagnostics now covered by tests - moved abi_tag on re-declaration checks to Sema::mergeDeclAttributes where they actually may work as designed - clang-format + other stylistic changes Mangle part will be sent for review as a separate patch. Differential Revision: http://reviews.llvm.org/D17567 llvm-svn: 263015
* P0188R1: add support for standard [[fallthrough]] attribute. This is almostRichard Smith2016-03-081-4/+9
| | | | | | | | | | | | | | exactly the same as clang's existing [[clang::fallthrough]] attribute, which has been updated to have the same semantics. The one significant difference is that [[fallthrough]] is ill-formed if it's not used immediately before a switch label (even when -Wimplicit-fallthrough is disabled). To support that, we now build a CFG of any function that uses a '[[fallthrough]];' statement to check. In passing, fix some bugs with our support for statement attributes -- in particular, diagnose their use on declarations, rather than asserting. llvm-svn: 262881
* Implement support for [[nodiscard]] in C++1z that is based off existing ↵Aaron Ballman2016-03-071-0/+6
| | | | | | support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class. llvm-svn: 262872
* Semantic analysis for the swiftcall calling convention.John McCall2016-03-031-0/+106
| | | | | | | I've tried to keep the infrastructure behind parameter ABI treatments fairly general. llvm-svn: 262587
* Improve some infrastructure for extended parameter infos andJohn McCall2016-03-031-18/+38
| | | | | | | fix a bug with the instantiation of ns_consumed parameter attributes in ARC. llvm-svn: 262551
* [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttrXiuli Pan2016-02-261-2/+36
| | | | | | | | | | | | | | | Summary: OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading, Add semacheck for OpenCL access qualifier as well as test caees. Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D16040 llvm-svn: 261961
* Addressing review comments for r261163.Manman Ren2016-02-221-30/+10
| | | | | | | | | Use "strict" instead of "nopartial". Also make strictly not-introduced share the same diagnostics as Obsolete and Unavailable. rdar://23791325 llvm-svn: 261512
* Sema: provide an extension warning for enable_ifSaleem Abdulrasool2016-02-181-0/+2
| | | | | | | Clang implements an enable_if attribute as an extension. Hook up `-Wpedantic` to issue an extension usage warning when __enable_if__ is used. llvm-svn: 261192
* Add 'nopartial' qualifier for availability attributes.Manman Ren2016-02-171-5/+30
| | | | | | | | | | | | | | | | | | | | | | An optional nopartial can be placed after the platform name. int bar() __attribute__((availability(macosx,nopartial,introduced=10.12)) When deploying back to a platform version prior to when the declaration was introduced, with 'nopartial', Clang emits an error specifying that the function is not introduced yet; without 'nopartial', the behavior stays the same: the declaration is `weakly linked`. A member is added to the end of AttributeList to save the location of the 'nopartial' keyword. A bool member is added to AvailabilityAttr. The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as we handle unavailable cases. Reviewed by Doug Gregor and Jordan Rose. rdar://23791325 llvm-svn: 261163
* Fix a leak in the generated code for attributes with strings.Benjamin Kramer2016-02-131-3/+3
| | | | | | | | Storing std::strings in attributes simply doesn't work, we never call the destructor. Use an array of StringRefs instead of std::strings and copy the data into memory taken from the ASTContext. llvm-svn: 260831
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-121-26/+4
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
* Fix for PR8901: attribute "mode" rejected for enums and dependent types.Denis Zobnin2016-02-021-35/+70
| | | | | | | | | Allow "mode" attribute for enum types, except for vector modes, for compatibility with GCC. Support "mode" attribute with dependent types. Differential Revision: http://reviews.llvm.org/D16219 llvm-svn: 259497
* Fix attribute((mode([word|unwind_word]))) for x32Reid Kleckner2016-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by H.J. Lu ``` typedef unsigned int gcc_word __attribute__((mode(word))); ``` and ``` typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word))); ``` define the largest unsigned integer types which can be stored in a general purpose register, which may not be the pointer type. For x32, they aren't pointer nor unsigned long. We should 1. Make getUnwindWordWidth and getRegisterWidth virtual, 2. Override them for x32, similar to hasInt128Type. 3. Use getRegisterWidth for __attribute__((mode(word))); This fixes PR 24706. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D16779 llvm-svn: 259383
* [MS ABI] Allow a member pointers' converted type to changeDavid Majnemer2016-01-261-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | Member pointers in the MS ABI are tricky for a variety of reasons. The size of a member pointer is indeterminate until the program reaches a point where the representation is required to be known. However, *pointers* to member pointers may exist without knowing the pointee type's representation. In these cases, we synthesize an opaque LLVM type for the pointee type. However, we can be in a situation where the underlying member pointer's representation became known mid-way through the program. To account for this, we attempted to manicure CodeGen's type-cache so that we can replace the opaque member pointer type with the real deal while leaving the pointer types unperturbed. This, unfortunately, is a problematic approach to take as we will violate CodeGen's invariants. These violations are mostly harmless but let's do the right thing instead: invalidate the type-cache if a member pointer's LLVM representation changes. This fixes PR26313. llvm-svn: 258839
* [CUDA] Reject the alias attribute in CUDA device code.Justin Lebar2016-01-231-0/+3
| | | | | | | | | | | | Summary: CUDA (well, strictly speaking, NVPTX) doesn't support aliases. Reviewers: echristo Subscribers: cfe-commits, jhen, tra Differential Revision: http://reviews.llvm.org/D16502 llvm-svn: 258641
* [CUDA] Only allow __global__ on free functions and static member functions.Justin Lebar2016-01-201-1/+11
| | | | | | | | | | | | | | Summary: Warn for NVCC compatibility if you declare a static member function or inline function as __global__. Reviewers: tra Subscribers: jhen, echristo, cfe-commits Differential Revision: http://reviews.llvm.org/D16261 llvm-svn: 258263
* Allow __attribute__((mode)) to appertain to field declarations again. ↵Aaron Ballman2016-01-191-2/+2
| | | | | | | | Corrects compile issues with LibreOffice. Patch by Stephan Bergmann llvm-svn: 258213
* PR26111: segmentation fault with __attribute__((mode(QI))) on function ↵Alexey Bataev2016-01-151-8/+3
| | | | | | | | | declaration, by Denis Zobnin Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which includes FunctionDecl and EnumConstantDecl), emit an error if this attribute is used with function declarations and enum constants. Differential Revision: http://reviews.llvm.org/D16112 llvm-svn: 257868
OpenPOWER on IntegriCloud