summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/AttributeList.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR14922: when printing an attribute, use the real syntax of the attribute ↵Michael Han2013-01-241-0/+11
| | | | | | | | | | | | | (GNU, C++11, MS Declspec) instead of hardcoded GNU syntax. Introduce a spelling index to Attr class, which is an index into the attribute spelling list of an attribute defined in Attr.td. This index will determine the actual spelling used by an attribute, as it incorporates both the syntax and naming of the attribute. When constructing an attribute AST node, the spelling index is computed based on attribute kind, scope (if it's a C++11 attribute), and name, then passed to Attr that will use the index to print itself. Thanks to Richard Smith for the idea and review. llvm-svn: 173358
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Add support for "type safety" attributes that allow checking that 'void *'Dmitri Gribenko2012-08-171-0/+2
| | | | | | | | | | | | | | function arguments and arguments for variadic functions are of a particular type which is determined by some other argument to the same function call. Usecases include: * MPI library implementations, where these attributes enable checking that buffer type matches the passed MPI_Datatype; * for HDF5 library there is a similar usecase as MPI; * checking types of variadic functions' arguments for functions like fcntl() and ioctl(). llvm-svn: 162067
* Drop the ASTContext.h include from Stmt.h and fix up transitive users.Benjamin Kramer2012-07-041-0/+1
| | | | | | | | | | | | | | This required moving the ctors for IntegerLiteral and FloatingLiteral out of line which shouldn't change anything as they are usually called through Create methods that are already out of line. ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector and make it independent from ASTContext.h Pass the StorageAllocator directly to AccessedEntity so it doesn't need to have a definition of ASTContext around. llvm-svn: 159718
* Handle C++11 attribute namespaces automatically.Alexis Hunt2012-06-181-6/+12
| | | | | | | | Now, as long as the 'Namespaces' variable is correct inside Attr.td, the generated code will correctly admit a C++11 attribute only when it has the appropriate namespace(s). llvm-svn: 158661
* Add -Wimplicit-fallthrough warning flag, which warns on fallthrough betweenRichard Smith2012-05-031-1/+8
| | | | | | | | | | | | cases in switch statements. Also add a [[clang::fallthrough]] attribute, which can be used to suppress the warning in the case of intentional fallthrough. Patch by Alexander Kornienko! The handling of C++11 attribute namespaces in this patch is temporary, and will be replaced with a cleaner mechanism in a subsequent patch. llvm-svn: 156086
* Replace the StringSwitch in AttributeList::getKind() with aDouglas Gregor2012-05-021-3/+3
| | | | | | | | TableGen-generated StringMatcher, for a 1.2% speedup in -fparse-only time in <rdar://problem/11004361>. Thanks to Benjamin for pointing me at StringMatcher! llvm-svn: 156003
* Introduce the notion of 'ignored' attributes, so that all attributesDouglas Gregor2012-05-021-2/+0
| | | | | | we accept are not modeled somehow via Attr.td. llvm-svn: 155998
* Introduce the notion of an attribute that has no direct representationDouglas Gregor2012-05-021-11/+0
| | | | | | as an AST node, and fold a number of such attributes into Attr.td. llvm-svn: 155995
* Implement the alternate spellings of attributes aligned (as "align")Douglas Gregor2012-05-021-2/+0
| | | | | | | and const (as "__const") using tblgen, rather than explicitly hacking them in. llvm-svn: 155991
* Revert my optimization to AttributeList::getKind() in r155987;Douglas Gregor2012-05-021-31/+19
| | | | | | Benjamin has suggested a better approach. llvm-svn: 155989
* Replace the StringSwitch in AttributeList::getKind(constDouglas Gregor2012-05-021-19/+31
| | | | | | | IdentifierInfo *) with a static StringMap, improving -fsyntax-only performance by 1% for the example in <rdar://problem/11004361>. llvm-svn: 155987
* Refactor Clang sema attribute handling.Michael Han2012-03-071-122/+10
| | | | | | | | | | | | | | | | | This submission improves Clang sema handling by using Clang tablegen to generate common boilerplate code. As a start, it implements AttributeList enumerator generation and case statements for AttributeList::getKind. A new field "SemaHandler" is introduced in Attr.td and by default set to 1 as most of attributes in Attr.td have semantic checking in Sema. For a small number of attributes that don't appear in Sema, the value is set to 0. Also there are a small number of attributes that only appear in Sema but not in Attr.td. Currently these attributes are still hardcoded in Sema AttributeList. Reviewed by Delesley Hutchins. llvm-svn: 152169
* Accept __has_feature(__feature__) as a synonym for __has_feature(feature) (andRichard Smith2012-02-251-1/+2
| | | | | | likewise for __has_extension). Patch by Jonathan Sauer! llvm-svn: 151445
* The following patch adds __attribute__((no_address_safety_analysis)) which ↵Kostya Serebryany2012-01-241-0/+1
| | | | | | | | | | | | | | | will allow to disable address safety analysis (such as e.g. AddressSanitizer or SAFECode) for a specific function. When building with AddressSanitizer, add AddressSafety function attribute to every generated function except for those that have __attribute__((no_address_safety_analysis)). With this patch we will be able to 1. disable AddressSanitizer for a particular function 2. disable AddressSanitizer-hostile optimizations (such as some cases of load widening) when AddressSanitizer is on. llvm-svn: 148842
* After further discussion, rename attribute ↵Ted Kremenek2012-01-051-1/+1
| | | | | | 'objc_disable_automatic_synthesis' to 'objc_requires_property_definitions'. llvm-svn: 147622
* Rename attribute 'objc_suppress_autosynthesis' to ↵Ted Kremenek2012-01-041-1/+1
| | | | | | 'objc_disable_automatic_synthesis'. llvm-svn: 147567
* objc: introduce objc_suppress_autosynthesis class Fariborz Jahanian2012-01-031-0/+1
| | | | | | attributes for later use. llvm-svn: 147457
* Propagate __attribute__((returns_twice)) from C to IL.Rafael Espindola2011-10-031-1/+1
| | | | llvm-svn: 141002
* Add explicit attributes to mark functions as having had theirJohn McCall2011-09-301-0/+2
| | | | | | | | | | | CoreFoundation object-transfer properties audited, and add a #pragma to cause them to be automatically applied to functions in a particular span of code. This has to be implemented largely in the preprocessor because of the requirement that the region be entirely contained in a single file; that's hard to impose from the parser without registering for a ton of callbacks. llvm-svn: 140846
* Add an ns_bridged attribute, used to specify that a John McCall2011-09-291-0/+1
| | | | | | | | | | | | | | pointer to the annotated struct type can be used as an Objective-C object pointer. If an argument is given, the type is actually "toll-free bridged" to the specific type named there, rather than just to 'id'. For now, we cannot rely on all types being so annotated, and we'll always have to have exceptions for things like CFTypeRef (aka const void*), but this is clearly a good foundation for improving toolage in this area. llvm-svn: 140779
* Added basic parsing for all remaining attributes, thread safetyCaitlin Sadowski2011-07-281-0/+13
| | | | | | | analysis. This includes checking that the attributes are applied in the correct contexts and with the correct number of arguments. llvm-svn: 136383
* Added parsing for guarded_var, pt_guarded_var, lockable,Caitlin Sadowski2011-07-281-0/+5
| | | | | | scoped_lockable, and no_thread_safety_analysis attributes, all for thread safety analysis llvm-svn: 136364
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Document the existing objc_precise_lifetime attribute.John McCall2011-07-221-0/+1
| | | | | | | | | Introduce and document a new objc_returns_inner_pointer attribute, and consume it by performing a retain+autorelease on message receivers when they're not immediately loaded from an object with precise lifetime. llvm-svn: 135764
* objc-arc: Support objc_arc_weak_unavailable on thoseFariborz Jahanian2011-07-061-0/+1
| | | | | | | classes which are incompatible with weak references. // rdar://9693477 llvm-svn: 134522
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Automatic Reference Counting.John McCall2011-06-151-0/+5
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Add ms_struct attribute on record typeeFariborz Jahanian2011-04-261-0/+1
| | | | | | (and ignore it for now) - wip. llvm-svn: 130224
* Implement ARM pcs attribute. Basically it's another way of calling ↵Anton Korobeynikov2011-04-141-0/+1
| | | | | | | | | | convention selection (AAPCS or AAPCS+VFP), similar to fastcall / stdcall / whatevercall seen on x86. In particular, all library functions should always be AAPCS regardless of floating point ABI used. llvm-svn: 129534
* Insomniac refactoring: change how the parser allocates attributes so thatJohn McCall2011-03-241-33/+76
| | | | | | | | | AttributeLists do not accumulate over the lifetime of parsing, but are instead reused. Also make the arguments array not require a separate allocation, and make availability attributes store their stuff in augmented memory, too. llvm-svn: 128209
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Add support for language-specific address spaces. On top of that,Peter Collingbourne2011-03-181-0/+1
| | | | | | | | | add support for the OpenCL __private, __local, __constant and __global address spaces, as well as the __read_only, _read_write and __write_only image access specifiers. Patch originally by ARM; language-specific address space support by myself. llvm-svn: 127915
* Provide an attribute, objc_method_family, to allow the inferred familyJohn McCall2011-03-021-0/+1
| | | | | | | | | | of an Objective-C method to be overridden on a case-by-case basis. This is a higher-level tool than ns_returns_retained &c.; it lets users specify that not only does a method have different retain/release semantics, but that it semantically acts differently than one might assume from its name. This in turn is quite useful to static analysis. llvm-svn: 126839
* accept and ignore a few things for better OpenBSD compatibility,Chris Lattner2011-02-181-0/+1
| | | | | | patch by Amit Kulkarni! llvm-svn: 125944
* OpenCL: add support for __kernel, kernel keywords and EXTENSION,Peter Collingbourne2011-02-141-0/+1
| | | | | | FP_CONTRACT pragmas. Patch originally by ARM. llvm-svn: 125475
* Revert r124217 because it didn't catch the actual error case it was trying toJeffrey Yasskin2011-01-271-1/+0
| | | | | | | | | | catch: lock_guard(my_mutex); declares a variable instead of creating a temporary. llvm-svn: 124398
* Add an attribute to forbid temporary instances of a type. This allows classJeffrey Yasskin2011-01-251-0/+1
| | | | | | | | | | | | | | | authors to write class __attribute__((forbid_temporaries)) Name { ... }; when they want to force users to name all variables of the type. This protects people from doing things like creating a scoped_lock that only lives for a single statement instead of an entire scope. The warning produced by this attribute can be disabled by -Wno-forbid-temporaries. llvm-svn: 124217
* Add the ns_consumes_self, ns_consumed, cf_consumed, and ns_returns_autoreleasedJohn McCall2011-01-251-0/+4
| | | | | | attributes for the benefit of the static analyzer. llvm-svn: 124174
* Get rid of [[hiding]], [[override]] and [[base_check]].Anders Carlsson2011-01-231-2/+0
| | | | llvm-svn: 124087
* Get rid of the [[final]] C++0x attribute.Anders Carlsson2011-01-231-1/+0
| | | | llvm-svn: 124083
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-2/+2
| | | | | | | on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. llvm-svn: 122535
* Add support for the Microsoft uuid attribute:Francois Pichet2010-12-191-0/+1
| | | | | | | | example: struct __declspec(uuid("6d5140c1-7436-11ce-8034-00aa006009fa")) test { }; llvm-svn: 122173
* Basic, Sema: add support for CUDA launch_bounds attributePeter Collingbourne2010-12-121-0/+1
| | | | llvm-svn: 121654
* Add support for the common and nocommon attributes.Eric Christopher2010-12-021-0/+2
| | | | | | rdar://8560647 llvm-svn: 120650
* Basic, Sema: add support for CUDA location attributesPeter Collingbourne2010-12-011-0/+5
| | | | llvm-svn: 120545
* Front-end support for __attribute__((may_alias)). This is notDan Gohman2010-11-171-1/+1
| | | | | | yet hooked up to anything yet. llvm-svn: 119407
* Add support for "neon_vector_type" and "neon_polyvector_type" attributesBob Wilson2010-11-161-0/+2
| | | | | | | | to create the special Neon vector types. These are intended to be used in Clang's version of <arm_neon.h> to define special Neon vector types that will be mangled according to ARM's ABI. llvm-svn: 119301
* Region-allocate all AttributeList objects from a factory object instead of ↵Ted Kremenek2010-11-101-17/+6
| | | | | | | | | | | | | | | | | | | | | | | | manually managing them using new/delete and OwningPtrs. After memory profiling Clang, I witnessed periodic leaks of these objects; digging deeper into the code, it was clear that our management of these objects was a mess. The ownership rules were murky at best, and not always followed. Worse, there are plenty of error paths where we could screw up. This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList objects and then blows them away all at once. While conceptually simple, most of the changes in this patch just have to do with migrating over to the new interface. Most of the changes have resulted in some nice simplifications. This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser object. This is easily tunable. If we desire to have more bound the lifetime of AttributeList objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its underlying allocator as we enter/leave key methods in the Parser. This means that we get simple memory management while still having the ability to finely control memory use if necessary. Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic in many large files with attributes. This fixes the leak reported in: <rdar://problem/8650003> llvm-svn: 118675
* fix http://llvm.org/PR8371 in the straightforward way, also adding a commentGabor Greif2010-10-151-0/+1
| | | | llvm-svn: 116570
OpenPOWER on IntegriCloud