Commit Graph

131 Commits

Author SHA1 Message Date
Aaron Ballman 173361e7e0 Specifying the diagnostic argument through the attribute table generator instead of having to enter it manually as part of the attribute subject list. This only affects attributes appertaining to ObjC interfaces and protocols.
No new tests required as this is covered by existing tests.

llvm-svn: 213193
2014-07-16 20:28:10 +00:00
Aaron Ballman 120c79f231 Fixing the position of the supported syntax marker when generating attribute documentation.
llvm-svn: 211692
2014-06-25 12:48:06 +00:00
Craig Topper d8d43191d8 Replace some assert(0)'s with llvm_unreachable.
llvm-svn: 211143
2014-06-18 05:13:13 +00:00
Tyler Nowicki e8b07ed080 Adds a Pragma spelling for attributes to tablegen and makes use of it for loop
hint attributes. Includes tests for pragma printing and for attribute order
which is incorrectly reversed by ParsedAttributes.

Reviewed by Aaron Ballman

llvm-svn: 210925
2014-06-13 17:57:25 +00:00
Richard Trieu ddd01cec0e Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context.  The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.

llvm-svn: 210498
2014-06-09 22:53:25 +00:00
Hans Wennborg 613807b4d0 Make Attr::Clone() also clone the Inherited, IsPackExpansion and Implicit flags
I was bitten by this when working with the dll attributes: when a dll
attribute was cloned from a class template declaration to its
specialization, the Inherited flag didn't get cloned.

Differential Revision: http://reviews.llvm.org/D3972

llvm-svn: 209950
2014-05-31 01:30:30 +00:00
Nikola Smiljanic 01a7598561 Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
llvm-svn: 209800
2014-05-29 10:55:11 +00:00
Aaron Ballman 2f22b94201 Cleaning up some range-based for loops so that the automatic type deduction is more explicit about pointers and const. Did some minor drive-by const correctness fixes and identifier updates as well. No functional changes.
llvm-svn: 209233
2014-05-20 19:47:14 +00:00
Aaron Ballman 981ba24156 None of these attributes require FunctionTemplate to be explicitly listed as part of their subject definition. FunctionTemplateDecls are not what the attribute appertains to in the first place -- it attaches to the underlying FunctionDecl.
The attribute emitter was using FunctionTemplate to map the diagnostic to "functions or methods", but that isn't a particularly clear diagnostic in these cases anyway (since they do not apply to ObjC methods). Updated the attribute emitter to remove custom logic for FunctionTemplateDecl, and updated the test cases for the change in diagnostic wording.

llvm-svn: 209209
2014-05-20 14:10:53 +00:00
Craig Topper 8ae1203992 [C++11] Use 'nullptr'.
llvm-svn: 208163
2014-05-07 06:21:57 +00:00
Aaron Ballman a82eaa70f1 Updated the attribute tablegen emitter for variadic arguments to emit a range accessor in addition to the iterators. Updated code using iterators to use range-based for loops.
llvm-svn: 207837
2014-05-02 13:35:42 +00:00
Aaron Ballman d6459e5c43 Fixing a FIXME -- no longer using std::memcpy, since that would fail for non-trivial types. Replaced with std::copy. No functional changes intended since all uses of this functionality either use pointers or integers.
llvm-svn: 207766
2014-05-01 15:21:03 +00:00
Aaron Ballman 2fbf99429a Reapplying r204952 a second time.
Clean up the __has_attribute implementation without modifying its behavior. 

Replaces the tablegen-driven AttrSpellings.inc, which lived in the lexing layer with AttrHasAttributeImpl.inc, which lives in the basic layer. Updates the preprocessor to call through to this new functionality which can take additional information into account (such as scopes and syntaxes).

Expose the ability for parts of the compiler to ask whether an attribute is supported for a given spelling (including scope), syntax, triple and language options.

llvm-svn: 205181
2014-03-31 13:14:44 +00:00
Aaron Ballman 0efd167f81 Reverting r204968 and r204969; while more build bots are happy with the results, some still have link errors.
llvm-svn: 204974
2014-03-27 22:37:56 +00:00
Aaron Ballman c9ad1ca715 Reapplying r204952 with fixes which should hopefully resolve linking issues with non-MSVC compilers.
llvm-svn: 204968
2014-03-27 22:12:09 +00:00
Aaron Ballman 0702d02b31 Reverting r204952, while I figure out what's going on with the makefile build.
llvm-svn: 204955
2014-03-27 20:36:32 +00:00
Aaron Ballman 9cac6f5f04 Clean up the __has_attribute implementation without modifying its behavior.
Replaces the tablegen-driven AttrSpellings.inc, which lived in the lexing layer with AttrHasAttributeImpl.inc, which lives in the basic layer. Updates the preprocessor to call through to this new functionality which can take additional information into account (such as scopes and syntaxes).

Expose the ability for parts of the compiler to ask whether an attribute is supported for a given spelling (including scope), syntax, triple and language options.

llvm-svn: 204952
2014-03-27 20:19:24 +00:00
Arnaud A. de Grandmaison c6b4045d65 When generating the Attribute dumper code, do not dead-initialize MoreChildren
No functional change. This will cleanup a bunch of scan-build warnings.

llvm-svn: 204529
2014-03-21 22:35:34 +00:00
Craig Topper cbce6e9e63 [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203543
2014-03-11 06:22:39 +00:00
Craig Topper 3164f33f8f [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203537
2014-03-11 03:39:26 +00:00
Aaron Ballman 8cbf633715 [C++11] Adding override specifiers where appropriate, and removing virtual specifiers where not needed.
No functional changes intended.

llvm-svn: 203122
2014-03-06 15:09:50 +00:00
Aaron Ballman 8f1439bd0c [C++11] Using std::unique_ptr to ensure that Argument objects do not leak (since clang-tblgen isn't long-lived, the old leak is probably acceptable, but it offended my senses nonetheless).
llvm-svn: 202989
2014-03-05 16:49:55 +00:00
Benjamin Kramer 9299637dc0 Pass llvm::Triple objects by const reference.
Copying isn't cheap as it contains a std::string.

llvm-svn: 202880
2014-03-04 19:31:42 +00:00
Chandler Carruth 757fcd6d1f [cleanup] Re-sort includes with llvm/utils/sort_includes.py and fix
a missing include from CLog.h.

CLog.h referenced most of the core libclang types but never directly
included Index.h that provides them. Previously it got lucky and other
headers were always included first but with the sorting it ended up
first in one case and stopped compiling. Adding the Index.h include
fixes it right up.

llvm-svn: 202810
2014-03-04 10:05:20 +00:00
Aaron Ballman b097f7fe9a Simplifying attribute generation with range-based for loops. No functional changes intended.
llvm-svn: 202654
2014-03-02 17:38:37 +00:00
Benjamin Kramer 167e999be9 [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.
llvm-svn: 202635
2014-03-02 12:20:24 +00:00
Aaron Ballman ea6668c4e8 Moving the documentation for the type safety checking attributes into AttrDocs. If a custom heading is provided, do not automatically generate the alternate spelling list. This is necessary because some attributes have distinct semantic spellings and meanings, but use the same semantic attribute internally. Such attributes should have multiple elements in their documentation list, but not show all spellings. At some point, it would be nice to have a way to attach the documentation element to a specific spelling for these cases.
llvm-svn: 201851
2014-02-21 14:14:04 +00:00
Aaron Ballman 4de1b584cd Refactored the way attribute category headers are handled so that it is possible to use custom categories. This allows for moving the consumable attributes (consumable, callable_when, return_typestate, etc) to be grouped together, with a content heading, like they were in the language extensions documentation. Moved the consumable attribute documentation from the language extensions into the attribute documentation table.
llvm-svn: 201732
2014-02-19 22:59:32 +00:00
Aaron Ballman c7962868a2 Added a documentation category for statement attributes so that things like clang::fallthrough can be documented.
llvm-svn: 201714
2014-02-19 20:55:42 +00:00
Aaron Ballman 06bd44b3e8 Forcing it to be an error when there is no Documentation list specified for an attribute. This is a bit of a (harmless) hack, but the FIXME explains why and when this hack can be removed. It's a justified hack because this prevents attribute authors from forgetting to add documentation when they add a new attribute.
llvm-svn: 201524
2014-02-17 18:23:02 +00:00
Aaron Ballman 1a3e5858b9 The default assignment operator could not be generated by all of the bots, but it's required by std::vector to operate properly.
llvm-svn: 201518
2014-02-17 16:18:32 +00:00
Aaron Ballman 51d40111b4 Removing a C++11'ism to also fix the build bots.
llvm-svn: 201517
2014-02-17 15:59:37 +00:00
Aaron Ballman a66b574b28 Fixing build bot breakage due to using a local type as a template argument.
llvm-svn: 201516
2014-02-17 15:36:08 +00:00
Aaron Ballman 97dba048a3 Implements a declarative approach to documenting individual attributes in Clang via a Documentation tablegen class. Also updates the internals manual with information about how to use this new, required, documentation feature.
This patch adds some very, very sparse initial documentation for some attributes. Additional effort from attribute authors is greatly appreciated.

llvm-svn: 201515
2014-02-17 15:27:10 +00:00
Reid Kleckner f06b266bfa Attributes: Avoid a big useless copy in the emitter
llvm-svn: 201251
2014-02-12 19:26:24 +00:00
Reid Kleckner f526b94858 Attributes: Emit enumerators in td file declaration order
llvm-svn: 201246
2014-02-12 18:22:18 +00:00
David Majnemer 4bb0980d96 MS ABI: Add support for #pragma pointers_to_members
Introduce a notion of a 'current representation method' for
pointers-to-members.

When starting out, this is set to 'best case' (representation method is
chosen by examining the class, selecting the smallest representation
that would work given the class definition or lack thereof).

This pragma allows the translation unit to dictate exactly what
representation to use, similar to how the inheritance model keywords
operate.

N.B.  PCH support is forthcoming.

Differential Revision: http://llvm-reviews.chandlerc.com/D2723

llvm-svn: 201105
2014-02-10 19:50:15 +00:00
Aaron Ballman 35db2b3d4c Consolidating several table-generated files containing parser-related string switches into a single file. This reduces build-related complexity by replacing four separate projects (and table-gen instantiations) with a single one.
No functional changes intended.

llvm-svn: 200424
2014-01-29 22:13:45 +00:00
Aaron Ballman c669cc0d77 Add a new attribute meta-spelling called "GCC" -- it widens into being a GNU 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.

llvm-svn: 200252
2014-01-27 22:10:04 +00:00
Aaron Ballman 81cb8cbfa6 Adds a getSemanticSpelling function to semantic attribute subclasses which 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).
llvm-svn: 200041
2014-01-24 21:32:49 +00:00
Aaron Ballman bc909618f2 If an attribute has a semantically meaningful spelling (such as ArgumentWithTypeTagAttr or MSInheritanceAttr), display the spelling used for the attribute as part of the AST dump. This should ease debugging the AST for these attributes. Attributes without semantically meaningful spelling variations are not affected.
llvm-svn: 199834
2014-01-22 21:51:20 +00:00
Aaron Ballman b9023ed0f6 Exposed a declarative way to specify that an attribute can be duplicated when merging attributes on a declaration. This replaces some hard-coded functionality from Sema.
llvm-svn: 199677
2014-01-20 18:07:09 +00:00
Aaron Ballman 9a99e0da5a Remove some hard-coded specialness for thread-safety attributes from the 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.
llvm-svn: 199676
2014-01-20 17:18:35 +00:00
Alp Toker 96cf758d3a Fix comment typos
llvm-svn: 199563
2014-01-18 21:49:37 +00:00
Aaron Ballman 07c3d53c88 When generating Spelling enumeration values, do not generate identifiers in the reserved namespace. Strip underscores as appropriate, taking care to not create duplicate identifiers.
llvm-svn: 199414
2014-01-16 19:44:01 +00:00
Aaron Ballman 4755304fd1 Fixing a warning that causes the sanitizer build disliked about mixing && and ||. Since this is generated code, the && has been removed from the expression entirely.
llvm-svn: 199392
2014-01-16 14:32:03 +00:00
Aaron Ballman 12b9f6535b Factored some function-like type reasoning out of SemaDeclAttr and onto Decl itself. This allows for more declarative subjects in attribute tablegen where the attribute appertains to something function-like, but not strictly a FunctionDecl.
llvm-svn: 199387
2014-01-16 13:55:42 +00:00
Aaron Ballman 36a5350e51 Distinguish between attributes explicitly written at the request of the user, and attributes implicitly generated to assist in bookkeeping by the compiler. This is done so by table generating a CreateImplicit method for each attribute.
Additionally, remove the optional nature of the spelling list index when creating attributes. This is supported by table generating a Spelling enumeration when the spellings for an attribute are distinct enough to warrant it.

llvm-svn: 199378
2014-01-16 13:03:14 +00:00
Aaron Ballman 09e98ffa5b When determining the attribute's parsed kind, pay attention to the syntax 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).
llvm-svn: 199144
2014-01-13 21:42:39 +00:00
Aaron Ballman 0fa06d879a __has_attribute now understands target-specific attributes. So when you ask whether an ARM target has the "interrupt" attribute, it will return true for ARM and MSP430 targets, and false for others.
llvm-svn: 198897
2014-01-09 22:57:44 +00:00