summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [X86] Support 'interrupt' attribute for x86Alexey Bataev2016-01-151-6/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This attribute may be attached to a function definition and instructs the backend to generate appropriate function entry/exit code so that it can be used directly as an interrupt handler. The IRET instruction, instead of the RET instruction, is used to return from interrupt or exception handlers. All registers, except for the EFLAGS register which is restored by the IRET instruction, are preserved by the compiler. Any interruptible-without-stack-switch code must be compiled with -mno-red-zone since interrupt handlers can and will, because of the hardware design, touch the red zone. interrupt handler must be declared with a mandatory pointer argument: struct interrupt_frame; __attribute__ ((interrupt)) void f (struct interrupt_frame *frame) { ... } and user must properly define the structure the pointer pointing to. exception handler: The exception handler is very similar to the interrupt handler with a different mandatory function signature: #ifdef __x86_64__ typedef unsigned long long int uword_t; #else typedef unsigned int uword_t; #endif struct interrupt_frame; __attribute__ ((interrupt)) void f (struct interrupt_frame *frame, uword_t error_code) { ... } and compiler pops the error code off stack before the IRET instruction. The exception handler should only be used for exceptions which push an error code and all other exceptions must use the interrupt handler. The system will crash if the wrong handler is used. Differential Revision: http://reviews.llvm.org/D15709 llvm-svn: 257867
* [CUDA] Report an error if code tries to mix incompatible CUDA attributes.Justin Lebar2016-01-131-13/+35
| | | | | | | | | | | | Summary: Thanks to jhen for helping me figure this out. Reviewers: tra, echristo Subscribers: jhen Differential Revision: http://reviews.llvm.org/D16129 llvm-svn: 257554
* Revert "Fix for merging decls in pragma weak Calling ↵Alexander Kornienko2015-12-031-13/+8
| | | | | | | | | | | | CheckFunctionDeclaration so that 2 decls for the 'weak' are merged. Differential Revision: http://reviews.llvm.org/D13048" This reverts commit r254143 which introduces a crash on the following input: f(char *); g(char *); #pragma weak f = g int g(char *p) {} llvm-svn: 254605
* PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type, ↵Alexey Bataev2015-12-031-9/+6
| | | | | | | | | patch by D. Polukhin This CL is for discussion how to better fix bit-filed layout compatibility issue with GCC (see PR25575 for test case and more details). Current clang behavior is compatible with GCC 4.1-4.3 series but it was fixed in 4.4+. Ignoring packed attribute looks very odd and because it was also fixed in GCC 4.4+, it makes sense also fix it in clang. Differential Revision: http://reviews.llvm.org/D14872 llvm-svn: 254596
* Add the `pass_object_size` attribute to clang.George Burgess IV2015-12-021-6/+48
| | | | | | | | | | | | | `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
* [mips] Interrupt attribute support.Daniel Sanders2015-11-271-1/+73
| | | | | | | | | | | | | | Summary: This patch adds support for the interrupt attribute for mips32r2+. Patch by Simon Dardis. Reviewers: dsanders, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D10802 llvm-svn: 254205
* Revert r254203: [mips] Interrupt attribute support.Daniel Sanders2015-11-271-73/+1
| | | | | | I forgot to credit the author. llvm-svn: 254204
* [mips] Interrupt attribute support.Daniel Sanders2015-11-271-1/+73
| | | | | | | | | | | | Summary: This patch adds support for the interrupt attribute for mips32r2+. Reviewers: dsanders, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D10802 llvm-svn: 254203
* Fix for merging decls in pragma weakAlexander Musman2015-11-261-8/+13
| | | | | | | Calling CheckFunctionDeclaration so that 2 decls for the 'weak' are merged. Differential Revision: http://reviews.llvm.org/D13048 llvm-svn: 254143
* PR10235: support for vector mode attributes + warning, by Dmitry Polukhin.Alexey Bataev2015-11-191-30/+72
| | | | | | | Add support for vector mode attributes like "attribute((mode(V4SF)))". Also add warning about deprecated vector modes like GCC does. Differential Revision: http://reviews.llvm.org/D14744 llvm-svn: 253551
* [Sema] Minor formatting fixes. NFCCraig Topper2015-11-171-1/+1
| | | | llvm-svn: 253314
* Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFCCraig Topper2015-11-151-1/+1
| | | | llvm-svn: 253155
* Add support for function attribute 'disable_tail_calls'.Akira Hatanaka2015-11-131-1/+23
| | | | | | | | | | | | | | | | | | | | | | The ``disable_tail_calls`` attribute instructs the backend to not perform tail call optimization inside the marked function. For example, int callee(int); int foo(int a) __attribute__((disable_tail_calls)) { return callee(a); // This call is not tail-call optimized. } Note that this attribute is different from 'not_tail_called', which prevents tail-call optimization to the marked function. rdar://problem/8973573 Differential Revision: http://reviews.llvm.org/D12547 llvm-svn: 252986
* Implement __attribute__((internal_linkage)).Evgeniy Stepanov2015-11-101-13/+66
| | | | | | | | | | | | | | The attrubite is applicable to functions and variables and changes the linkage of the subject to internal. This is the same functionality as C-style "static", but applicable to class methods; and the same as anonymouns namespaces, but can apply to individual methods of a class. Following the proposal in http://lists.llvm.org/pipermail/cfe-dev/2015-October/045580.html llvm-svn: 252648
* Add support for function attribute 'not_tail_called'.Akira Hatanaka2015-11-061-0/+15
| | | | | | | | | | | | | | | | | | | | | | This attribute is used to prevent tail-call optimizations to the marked function. For example, in the following piece of code, foo1 will not be tail-call optimized: int __attribute__((not_tail_called)) foo1(int); int foo2(int a) { return foo1(a); // Tail-call optimization is not performed. } The attribute has effect only on statically bound calls. It has no effect on indirect calls. Also, virtual functions and objective-c methods cannot be marked as 'not_tail_called'. rdar://problem/22667622 Differential Revision: http://reviews.llvm.org/D12922 llvm-svn: 252369
* Support tvOS and watchOS availability attributesTim Northover2015-10-301-0/+84
| | | | llvm-svn: 251711
* Refine r251469 to give better (and more localizable) diagnosticsJohn McCall2015-10-281-30/+63
| | | | | | for all the reasons that ARC makes things implicitly unavailable. llvm-svn: 251496
* Add the ability to define "fake" arguments on attributes.John McCall2015-10-281-2/+3
| | | | | | | | | | | | | | Fake arguments are automatically handled for serialization, cloning, and other representational tasks, but aren't included in pretty-printing or parsing (should we eventually ever automate that). This is chiefly useful for attributes that can be written by the user, but which are also frequently synthesized by the compiler, and which we'd like to remember details of the synthesis for. As a simple example, use this to narrow the cases in which we were generating a specialized note for implicitly unavailable declarations. llvm-svn: 251469
* Be more conservative about diagnosing "incorrect" uses of __weak:John McCall2015-10-271-9/+44
| | | | | | | | | | | | allow them to be written in certain kinds of user declaration and diagnose on the use-site instead. Also, improve and fix some diagnostics relating to __weak and properties. rdar://23228631 llvm-svn: 251384
* Amending r249721 to properly handle pathological attribute-related names ↵Aaron Ballman2015-10-091-2/+2
| | | | | | | | like __ and ____. Patch by Adrian Zgorzalek! llvm-svn: 249833
* When mapping no_sanitize_* attributes to no_sanitize attributes, handle ↵Aaron Ballman2015-10-081-11/+17
| | | | | | | | GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality. Patch by Adrian Zgorzalek! llvm-svn: 249721
* Don't inherit availability information when implementing a protocol requirement.Douglas Gregor2015-09-301-15/+32
| | | | | | | | | | When an Objective-C method implements a protocol requirement, do not inherit any availability information from the protocol requirement. Rather, check that the implementation is not less available than the protocol requirement, as we do when overriding a method that has availability. Fixes rdar://problem/22734745. llvm-svn: 248949
* Thread Safety Analysis: allow capability attribute on unions.DeLesley Hutchins2015-09-291-7/+4
| | | | llvm-svn: 248805
* [CUDA] __global__ functions should always be visible externally.Artem Belevich2015-09-231-3/+0
| | | | | | | | | Adjust __global__ functions with DiscardableODR linkage to use StrongODR linkage instead, so they are visible externally. Differential Revision: http://reviews.llvm.org/D13067 llvm-svn: 248400
* [CUDA] Add implicit __attribute__((used)) to all __global__ functions.Artem Belevich2015-09-221-0/+4
| | | | | | | | | | This makes sure that we emit kernels that were instantiated from the host code and which would never be explicitly referenced by anything else on device side. Differential Revision: http://reviews.llvm.org/D11666 llvm-svn: 248293
* MS ABI: Don't allow dllexport/import on lambdasHans Wennborg2015-09-151-0/+8
| | | | | | | This is to follow up on David's comment in http://reviews.llvm.org/D12422#235509 llvm-svn: 247718
* Fix some coding standard issues and delete a dead conditional.Eric Christopher2015-08-131-6/+6
| | | | llvm-svn: 244959
* Revert "[CUDA] Add implicit __attribute__((used)) to all __global__ functions."Daniel Jasper2015-08-111-4/+0
| | | | | | This is breaking internal test. I'll provide a reproduction. llvm-svn: 244583
* [CUDA] Add implicit __attribute__((used)) to all __global__ functions.Artem Belevich2015-08-101-0/+4
| | | | | | | | | This allows emitting kernels that were instantiated from the host code and which would never be explicitly referenced otherwise. Differential Revision: http://reviews.llvm.org/D11666 llvm-svn: 244501
* [Sema] Refactor AddAlignedAttr to reduce indentationDavid Majnemer2015-07-261-19/+19
| | | | | | No functionality change intended, just a tidy-up. llvm-svn: 243242
* [Sema] The alignment of an object has an upper bound from the object file formatDavid Majnemer2015-07-261-2/+4
| | | | | | | Don't use the spelling of the alignment attribute to determine whether or not an alignment amount makes sense. llvm-svn: 243233
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-5/+4
| | | | | | | | | This lets us pass functors (and lambdas) without void * tricks. On the downside we can't pass CXXRecordDecl's Find* members (which are now type safe) to lookupInBases directly, but a lambda trampoline is a small price to pay. No functionality change intended. llvm-svn: 243217
* Ignore the "novtable" declspec when not using the Microsoft C++ ABI.Bob Wilson2015-07-201-1/+1
| | | | | | | | | | | | | | Clang used to silently ignore __declspec(novtable). It is implemented now, but leaving the vtable uninitialized does not work when using the Itanium ABI, where the class layout for complex class hierarchies is stored in the vtable. It might be possible to honor the novtable attribute in some simple cases and either report an error or ignore it in more complex situations, but it’s not clear if that would be worthwhile. There is also value in having a simple and predictable behavior, so this changes clang to simply ignore novtable when not using the Microsoft C++ ABI. llvm-svn: 242730
* [MS Compat] Add support for __declspec(noalias)David Majnemer2015-07-201-0/+3
| | | | | | | The attribute '__declspec(noalias)' communicates that the function only accesses memory pointed to by its pointer-typed arguments. llvm-svn: 242728
* Add a "maximum TLS alignment" characteristic to the target info, so itPaul Robinson2015-07-141-5/+21
| | | | | | | | | | can be different from the normal variable maximum. Add an error diagnostic for when TLS variables exceed maximum TLS alignment. Currenty only PS4 sets an explicit maximum TLS alignment. Patch by Charles Li! llvm-svn: 242198
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-261-0/+33
| | | | | | | | | | | | | Patch extends ObjCBoxedExpr to accept records (structs and unions): typedef struct __attribute__((objc_boxable)) _Color { int r, g, b; } Color; Color color; NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)]; llvm-svn: 240761
* Allow the cf_returns_[not_]retained attributes to appear on out-parameters.Douglas Gregor2015-06-191-5/+43
| | | | | | | | | | | | | | | | Includes a simple static analyzer check and not much else, but we'll also be able to take advantage of this in Swift. This feature can be tested for using __has_feature(cf_returns_on_parameters). This commit also contains two fixes: - Look through non-typedef sugar when deciding whether something is a CF type. - When (cf|ns)_returns(_not)?_retained is applied to invalid properties, refer to "property" instead of "method" in the error message. rdar://problem/18742441 llvm-svn: 240185
* [ATTRIBUTE] Support base vector types of __attribute__((mode)), patch by ↵Alexey Bataev2015-06-191-10/+35
| | | | | | | | | | | | Alexey Frolov Base type of attribute((mode)) can actually be a vector type. The patch is to distinguish between base type and base element type. This fixes http://llvm.org/PR17453. Differential Revision: http://reviews.llvm.org/D10058 llvm-svn: 240125
* Add a warning for unsupported elements of the target attribute.Eric Christopher2015-06-121-3/+11
| | | | | | | | | Since we're ignoring the tune= and fpmath= attributes go ahead and add a warning alerting people to the fact that we're going to ignore that part of it during code generation and tie it to the attribute warning set. llvm-svn: 239583
* Add support for the the target attribute.Eric Christopher2015-06-121-0/+17
| | | | | | | | | | | | | | | Modeled after the gcc attribute of the same name, this feature allows source level annotations to correspond to backend code generation. In llvm particular parlance, this allows the adding of subtarget features and changing the cpu for a particular function based on source level hints. This has been added into the existing support for function level attributes without particular verification for any target outside of whether or not the backend will support the features/cpu given (similar to section, etc). llvm-svn: 239579
* Remove dead code.Richard Smith2015-05-281-2/+1
| | | | llvm-svn: 238526
* Use llvm::StringSwitch<std::string> to take advantage of implicit asserting ↵Peter Collingbourne2015-05-151-4/+2
| | | | | | conversion to std::string. llvm-svn: 237475
* Implement no_sanitize attribute.Peter Collingbourne2015-05-151-8/+44
| | | | | | Differential Revision: http://reviews.llvm.org/D9631 llvm-svn: 237463
* Don't warn about use of deprecated API when the containing context is ↵Jordan Rose2015-04-301-1/+1
| | | | | | | | | | unavailable. This probably won't come up much, but it seems tidier. Related to rdar://problem/20713550 llvm-svn: 236242
* [cuda] Allow using integral non-type template parameters as launch_bounds ↵Artem Belevich2015-04-211-10/+53
| | | | | | | | | | | | | | | | attribute arguments. - Changed CUDALaunchBounds arguments from integers to Expr* so they can be saved in AST for instantiation. - Added support for template instantiation of launch_bounds attrubute. - Moved evaluation of launch_bounds arguments to NVPTXTargetCodeGenInfo:: SetTargetAttributes() where it can be done after template instantiation. - Added a warning on negative launch_bounds arguments. - Amended test cases. Differential Revision: http://reviews.llvm.org/D8985 llvm-svn: 235452
* [Objective-C Sema] patch to introduce IndependentClassFariborz Jahanian2015-04-161-0/+19
| | | | | | | | | attribute to be placed on Objective-C pointer typedef to make them strong enough so on their "new" method family no attempt is made to override these types. rdar://20255473 llvm-svn: 235128
* [Sema] Don't crash when __attribute__((nonnull)) is applied to blocksDavid Majnemer2015-04-071-2/+7
| | | | | | | | | A simple case of asserting isFunctionOrMethod when we should have asserted isFunctionOrMethodOrBlock. This fixes PR23117. llvm-svn: 234297
* [Sema] Don't permit dependent alignments on non-dependent typedef-namesDavid Majnemer2015-04-071-0/+10
| | | | | | | | | | | | | | | | | A dependent alignment attribute (like __attribute__((aligned(...))) or __declspec(align(...))) on a non-dependent typedef or using declaration poses a considerable challenge: the type is _not_ dependent, the size _may_ be dependent if the type is used as an array type, the alignment _is_ dependent. It is reasonable for a compiler to be able to query the size and alignment of a complete type. Let's help that become an invariant. This fixes PR22042. Differential Revision: http://reviews.llvm.org/D8693 llvm-svn: 234280
* [Modules] Make "#pragma weak" undeclared identifiers be trackedChandler Carruth2015-03-261-2/+1
| | | | | | | | | | | | | | | | deterministically. This fixes a latent issue where even Clang's Sema (and diagnostics) were non-deterministic in the face of this pragma. The fix is super simple -- just use a MapVector so we track the order in which these are parsed (or imported). Especially considering how rare they are, this seems like the perfect tradeoff. I've also simplified the client code with judicious use of auto and range based for loops. I've added some pretty hilarious code to my stress test which now survives the binary diff without issue. llvm-svn: 233261
* Add -Wpartial-availability.Nico Weber2015-03-191-22/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | This warns when using decls that are not available on all deployment targets. For example, a call to - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8))); will warn if -mmacosx-version-min is set to less than 10.8. To silence the warning, one has to explicitly redeclare the method like so: @interface Whatever(MountainLionAPI) - (void)ppartialMethod; @end This way, one cannot accidentally call a function that isn't available everywhere. Having to add the redeclaration will hopefully remind the user to add an explicit respondsToSelector: call as well. Some projects build against old SDKs to get this effect, but building against old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples. The hope is that SDK headers are annotated well enough with availability attributes that new SDK + this warning offers the same amount of protection as using an old SDK. llvm-svn: 232750
OpenPOWER on IntegriCloud