summaryrefslogtreecommitdiffstats
path: root/lib/Sema/AttributeList.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Automate attribute argument count semantic checking when there are variadic ↵Aaron Ballman2014-07-311-0/+8
| | | | | | | | or optional arguments present. With this, the only time you should have to manually check attribute argument counts is when HasCustomParsing is set to true, or when you have variadic arguments that aren't really variadic (like ownership_holds and friends). Updating the diagnostics in the launch_bounds test since they have been improved in that case. Adding a test for nonnull since it has little test coverage, but has truly variadic arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214407 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove uses of SmallString::equals in favor of SmallVectorImpl<char>'s ↵David Blaikie2014-03-091-1/+1
| | | | | | operator== git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203373 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass llvm::Triple objects by const reference.Benjamin Kramer2014-03-041-2/+2
| | | | | | Copying isn't cheap as it contains a std::string. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202880 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new attribute meta-spelling called "GCC" -- it widens into being a GNU ↵Aaron Ballman2014-01-271-3/+3
| | | | | | | | spelling, and a CXX11 spelling with the namespace "gnu". It also sets a bit on the spelling certifying that it is known to GCC. From this, we can warn about the extension appropriately. As a consequence, the FunctionDefinition functionality is completely removed. Replacing the functionality from r199676, which didn't solve the problem as elegantly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200252 91177308-0d34-0410-b5e6-96231b3b80d8
* Adds a getSemanticSpelling function to semantic attribute subclasses which ↵Aaron Ballman2014-01-241-0/+5
| | | | | | have a meaningful semantic spelling. Adds a sibling function to parsed attribtues (via AttributeList) for getting the semantic spelling, if one were to exist. This can be used for cleaner code that deals directly with the semantic spellings (such as the MSInheritance attribute). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200041 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some hard-coded specialness for thread-safety attributes from the ↵Aaron Ballman2014-01-201-0/+5
| | | | | | parser, and made it more declarative. If an attribute is allowed to appear on a function definition when late parsed, it can now use the FunctionDefinition attribute subject. It's treated as a FunctionDecl for most purposes, except it also gets exposed on the AttributeList so that it can be used while parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199676 91177308-0d34-0410-b5e6-96231b3b80d8
* Removing some attribute magic related to the OpenCL keyword attributes. ↵Aaron Ballman2014-01-141-8/+0
| | | | | | Instead of mapping them to their semantics as a custom part of the parser, they instead map declaratively through the rest of the attribute system. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199175 91177308-0d34-0410-b5e6-96231b3b80d8
* When determining the attribute's parsed kind, pay attention to the syntax ↵Aaron Ballman2014-01-131-1/+1
| | | | | | used. This fixes bugs where an attribute has differing GNU and Declspec spellings, but they are treated as the same. Eg) __declspec(aligned) when it should be __attribute__((aligned)), and __attribute__((align)) when it should be __declspec(align). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199144 91177308-0d34-0410-b5e6-96231b3b80d8
* Removing the notion of TargetAttributesSema and replacing it with one where ↵Aaron Ballman2014-01-091-0/+15
| | | | | | the parsed attributes are responsible for knowing their target-specific nature, instead of letting Sema figure it out. This is necessary so that __has_attribute can eventually determine whether a parsed attribute applies to the given target or not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198896 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-2/+2
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198686 91177308-0d34-0410-b5e6-96231b3b80d8
* No longer accepting attribute spellings with prefix and suffix underscores ↵Aaron Ballman2013-12-111-9/+13
| | | | | | except for GNU attributes, or C++11-style attributes in the GNU namespace. This prevents attributes such as __declspec(__dllexport__) or [[__noreturn__]] from being treated as known attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197082 91177308-0d34-0410-b5e6-96231b3b80d8
* AttributeList: tweak the conditional order to avoid two strcmpsAlp Toker2013-12-051-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196518 91177308-0d34-0410-b5e6-96231b3b80d8
* Automate attribute language option checking by specifying the list of ↵Aaron Ballman2013-12-021-0/+5
| | | | | | options to test in tablegen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196138 91177308-0d34-0410-b5e6-96231b3b80d8
* Laying the basic groundwork for table generating the diagnostics for ↵Aaron Ballman2013-11-271-0/+10
| | | | | | | | | | | | attribute subjects. This makes some modifications to the way subjects are listed in Attr.td, and updates the attr emitter to handle the new constructs. I have disabled some attribute subject lines on purpose in Attr.td; this part is a WIP with the goal being to restore those subjects incrementally. By commenting them out, it leaves the original behavior the same as before for those attributes and so those are not functionality changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195841 91177308-0d34-0410-b5e6-96231b3b80d8
* Make helper function static.Benjamin Kramer2013-09-281-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191615 91177308-0d34-0410-b5e6-96231b3b80d8
* Attribute tablegen now understands that attribute arguments can be optional. ↵Aaron Ballman2013-09-091-0/+25
| | | | | | This allows for automated checking of the number of arguments expected vs number of arguments given for attributes. Greatly reduces the amount of manual checking required. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190368 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out parsing and allocation of IdentifierLoc objects.Richard Smith2013-09-031-0/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189833 91177308-0d34-0410-b5e6-96231b3b80d8
* Consolidating the notion of a GNU attribute parameter with the attribute ↵Aaron Ballman2013-08-311-4/+3
| | | | | | argument list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189711 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+2
| | | | | | | | references thereto. Patch by Tong Shen! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179585 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173358 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
* 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(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162067 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159718 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle C++11 attribute namespaces automatically.Sean 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158661 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156086 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156003 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce the notion of 'ignored' attributes, so that all attributesDouglas Gregor2012-05-021-2/+0
| | | | | | | we accept are not modeled somehow via Attr.td. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155998 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155995 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155991 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert my optimization to AttributeList::getKind() in r155987;Douglas Gregor2012-05-021-31/+19
| | | | | | | Benjamin has suggested a better approach. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155989 91177308-0d34-0410-b5e6-96231b3b80d8
* 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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155987 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152169 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151445 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148842 91177308-0d34-0410-b5e6-96231b3b80d8
* After further discussion, rename attribute ↵Ted Kremenek2012-01-051-1/+1
| | | | | | 'objc_disable_automatic_synthesis' to 'objc_requires_property_definitions'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147622 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename attribute 'objc_suppress_autosynthesis' to ↵Ted Kremenek2012-01-041-1/+1
| | | | | | 'objc_disable_automatic_synthesis'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147567 91177308-0d34-0410-b5e6-96231b3b80d8
* objc: introduce objc_suppress_autosynthesis class Fariborz Jahanian2012-01-031-0/+1
| | | | | | | attributes for later use. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147457 91177308-0d34-0410-b5e6-96231b3b80d8
* Propagate __attribute__((returns_twice)) from C to IL.Rafael Espindola2011-10-031-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141002 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140846 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140779 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136383 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136364 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135764 91177308-0d34-0410-b5e6-96231b3b80d8
* objc-arc: Support objc_arc_weak_unavailable on thoseFariborz Jahanian2011-07-061-0/+1
| | | | | | | | classes which are incompatible with weak references. // rdar://9693477 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134522 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133779 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
* Add ms_struct attribute on record typeeFariborz Jahanian2011-04-261-0/+1
| | | | | | | (and ignore it for now) - wip. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130224 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129534 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128209 91177308-0d34-0410-b5e6-96231b3b80d8