summaryrefslogtreecommitdiffstats
path: root/clang/utils/TableGen/ClangAttrEmitter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix Clang-tidy modernize-use-nullptr warnings in headers and generated ↵Hans Wennborg2015-09-291-4/+4
| | | | | | | | | | files; other minor cleanups. By Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13187 llvm-svn: 248828
* [UB] Guard two calls to memcpy in generated attribute code to handleChandler Carruth2015-08-041-2/+4
| | | | | | | | null StringRef objects as inputs. Found by UBSan. llvm-svn: 243949
* Fix -Wextra-semi warnings.Hans Wennborg2015-07-221-1/+1
| | | | | | | | Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D11401 llvm-svn: 242931
* Refactor TableGen backend for ClangAttrEmitter to avoid duplication.Bob Wilson2015-07-201-89/+63
| | | | | | | | GenerateHasAttrSpellingStringSwitch and GenerateTargetRequirements had duplicated code to check the conditions for target-specific attributes. Refactor the duplicated code into a separate function. NFC. llvm-svn: 242731
* Ignore the "novtable" declspec when not using the Microsoft C++ ABI.Bob Wilson2015-07-201-3/+36
| | | | | | | | | | | | | | 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
* [TableGen] Change a couple methods to return an ArrayRef instead of a const ↵Craig Topper2015-07-061-2/+2
| | | | | | std::vector reference. NFC llvm-svn: 241431
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Check for consistent use of nullability type specifiers in a header.Douglas Gregor2015-06-191-1/+2
| | | | | | | | | | | | | | | | | Adds a new warning (under -Wnullability-completeness) that complains about pointer, block pointer, or member pointer declarations that have not been annotated with nullability information (directly or inferred) within a header that contains some nullability annotations. This is intended to be used to help maintain the completeness of nullability information within a header that has already been audited. Note that, for performance reasons, this warning will underrepresent the number of non-annotated pointers in the case where more than one pointer is seen before the first nullability type specifier, because we're only tracking one piece of information per header. Part of rdar://problem/18868820. llvm-svn: 240158
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-4/+3
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* Implement no_sanitize attribute.Peter Collingbourne2015-05-151-0/+14
| | | | | | Differential Revision: http://reviews.llvm.org/D9631 llvm-svn: 237463
* Implement target-specific __attribute__((aligned)) valueUlrich Weigand2015-04-211-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GCC construct __attribute__((aligned)) is defined to set alignment to "the default alignment for the target architecture" according to the GCC documentation: The default alignment is sufficient for all scalar types, but may not be enough for all vector types on a target that supports vector operations. The default alignment is fixed for a particular target ABI. clang currently hard-coded an alignment of 16 bytes for that construct, which is correct on some platforms (including X86), but wrong on others (including SystemZ). Since this value is ABI-relevant, it is important to get correct for compatibility purposes. This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned" that targets can set to the appropriate default __attribute__((aligned)) value. Note that I'm deliberately *not* using the existing "SuitableAlign" value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__, since those two values may not be the same on all platforms. In fact, on X86, __attribute__((aligned)) always uses 16-byte alignment, while __BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported. (This is actually not yet correctly implemented in clang either.) The patch provides a value for DefaultAlignForAttributeAligned only for SystemZ, and leaves the default for all other targets at 16, which means no visible change in behavior on all other targets. (The value is still wrong for some other targets, but I'd prefer to leave it to the target maintainers for those platforms to fix.) llvm-svn: 235397
* [tblgen] Use StringRef::trimBenjamin Kramer2015-04-101-24/+5
| | | | llvm-svn: 234643
* Devirtualize Attr and all subclasses.Benjamin Kramer2015-03-191-12/+39
| | | | | | | | | | | | We know all subclasses in tblgen so just generate a giant switch for the few virtual methods or turn them into a member variable using spare bits. The giant jump tables aren't pretty but still much smaller than a vtable for every attribute, shrinking Release+Asserts clang by ~400k. Also halves the size of the Attr base class. No functional change intended. llvm-svn: 232726
* Make helper functions static. NFC.Benjamin Kramer2015-03-101-1/+4
| | | | llvm-svn: 231811
* The semantic spelling enumeration should retain values to the spelling list ↵Aaron Ballman2015-03-101-1/+5
| | | | | | | | | | indexes used by the attribute. The only attribute affected by this in practice is the OpenCLImageAccessAttr, which has duplicate semantic spellings that are automatically stripped. We do not implicitly create an OpenCLImageAccessAttr, so this change only affects out of tree users. There is no way to test this behavior specifically that I can see, since this only affects implicit creation of attributes. Fixes PR22403. llvm-svn: 231803
* Teach raw_ostream to accept SmallString.Yaron Keren2015-03-101-2/+2
| | | | | | | | | | | | | | Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. llvm-svn: 231763
* Replace size() calls on containers with empty() calls where appropriate. NFCAlexander Kornienko2015-01-231-2/+2
| | | | | | | | http://reviews.llvm.org/D7090 Patch by Gábor Horváth! llvm-svn: 226914
* [cleanup] Re-sort the #include lines using llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+1
| | | | | | | No functionality changed, this is a purely mechanical cleanup to ensure the #include order remains consistent across the project. llvm-svn: 225975
* Attributes accepting an EnumArgument are allowed to pass a string literal, ↵Aaron Ballman2014-12-191-0/+1
| | | | | | | | or an identifier. VariadicEnumArguments now behave consistently instead of only accepting a string literal. This change affects the only attribute accepting a variadic enumeration: callable_when. llvm-svn: 224582
* Modify __has_attribute so that it only looks for GNU-style attributes. ↵Aaron Ballman2014-12-051-3/+0
| | | | | | Removes the ability to look for generic attributes and keywords via this macro, which has the potential to be a breaking change. However, since there is __has_cpp_attribute and __has_declspec_attribute, and given the limited usefulness of querying a generic attribute name regardless of syntax, this seems like the correct path forward. llvm-svn: 223468
* Create a new 'flag_enum' attribute.Alexis Hunt2014-11-281-1/+6
| | | | | | | | | | | This attribute serves as a hint to improve warnings about the ranges of enumerators used as flag types. It currently has no working C++ implementation due to different semantics for enums in C++. For more explanation, see the docs and testcases. Reviewed by Aaron Ballman. llvm-svn: 222906
* Fixing a use of stringstream to use an LLVM helper function. Drive-by fixing ↵Aaron Ballman2014-11-171-7/+3
| | | | | | header include order. NFC. llvm-svn: 222151
* MinGW doesn't implement std::to_string; working around it. NFC.Aaron Ballman2014-11-141-1/+6
| | | | llvm-svn: 222033
* Complete support for the SD-6 standing document (based off N4200) with ↵Aaron Ballman2014-11-141-9/+30
| | | | | | support for __has_cpp_attribute. llvm-svn: 221991
* Refactor tree printing in AST dumping.Richard Smith2014-10-301-26/+4
| | | | | | | | | | | Instead of manually maintaining a flag indicating whether we're about to print out the last child of the parent node (to determine whether we print "`" or "|"), capture a callable to print that child and defer printing it until we either see a next child or finish the parent. No functionality change intended. llvm-svn: 220930
* Allow constant expressions in pragma loop hints.Tyler Nowicki2014-10-121-4/+26
| | | | | | | | Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
* Adding some FIXMEs to the attribute emitter code regarding whether pretty ↵Aaron Ballman2014-09-151-0/+6
| | | | | | printing enumerators should use quoted string literals, or identifiers. NFC. llvm-svn: 217781
* When pretty printing attributes that have enumeration arguments, print the ↵Aaron Ballman2014-09-151-6/+50
| | | | | | enumerator identifier (as a string literal) instead of the internal enumerator integral value. llvm-svn: 217771
* Remove some transient raw pointer ownership in ClangAttrEmitter::createArgumentDavid Blaikie2014-08-081-23/+28
| | | | | | | | This function might be a bit easier if it were split in two with a lot of early returns - and that setOptional bit in the outer function, but anyway. llvm-svn: 215263
* The GNU-style aligned attribute has an optional expression, but the ↵Aaron Ballman2014-08-011-3/+9
| | | | | | | | generated pretty printing logic was unaware of this. Fixed the pretty printing logic, and added a test to ensure it no longer asserts. Added a FIXME to the code about eliding the parenthesis when pretty printing such a construct. llvm-svn: 214513
* Automate attribute argument count semantic checking when there are variadic ↵Aaron Ballman2014-07-311-1/+13
| | | | | | | | 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. llvm-svn: 214407
* Specifying the diagnostic argument through the attribute table generator ↵Aaron Ballman2014-07-161-0/+2
| | | | | | | | 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
* Fixing the position of the supported syntax marker when generating attribute ↵Aaron Ballman2014-06-251-1/+1
| | | | | | documentation. llvm-svn: 211692
* Replace some assert(0)'s with llvm_unreachable.Craig Topper2014-06-181-2/+1
| | | | llvm-svn: 211143
* Adds a Pragma spelling for attributes to tablegen and makes use of it for loopTyler Nowicki2014-06-131-24/+53
| | | | | | | | | hint attributes. Includes tests for pragma printing and for attribute order which is incorrectly reversed by ParsedAttributes. Reviewed by Aaron Ballman llvm-svn: 210925
* Removing an "if (this == nullptr)" check from two print methods. The conditionRichard Trieu2014-06-091-3/+5
| | | | | | | 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
* Make Attr::Clone() also clone the Inherited, IsPackExpansion and Implicit flagsHans Wennborg2014-05-311-2/+6
| | | | | | | | | | 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
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-2/+2
| | | | | | takeAs to getAs. llvm-svn: 209800
* Cleaning up some range-based for loops so that the automatic type deduction ↵Aaron Ballman2014-05-201-74/+75
| | | | | | 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
* None of these attributes require FunctionTemplate to be explicitly listed as ↵Aaron Ballman2014-05-201-6/+3
| | | | | | | | 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
* [C++11] Use 'nullptr'.Craig Topper2014-05-071-4/+4
| | | | llvm-svn: 208163
* Updated the attribute tablegen emitter for variadic arguments to emit a ↵Aaron Ballman2014-05-021-39/+34
| | | | | | range accessor in addition to the iterators. Updated code using iterators to use range-based for loops. llvm-svn: 207837
* Fixing a FIXME -- no longer using std::memcpy, since that would fail for ↵Aaron Ballman2014-05-011-3/+2
| | | | | | 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
* Reapplying r204952 a second time.Aaron Ballman2014-03-311-15/+75
| | | | | | | | | | 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
* Reverting r204968 and r204969; while more build bots are happy with the ↵Aaron Ballman2014-03-271-75/+15
| | | | | | results, some still have link errors. llvm-svn: 204974
* Reapplying r204952 with fixes which should hopefully resolve linking issues ↵Aaron Ballman2014-03-271-15/+75
| | | | | | with non-MSVC compilers. llvm-svn: 204968
* Reverting r204952, while I figure out what's going on with the makefile build.Aaron Ballman2014-03-271-75/+15
| | | | llvm-svn: 204955
* Clean up the __has_attribute implementation without modifying its behavior. Aaron Ballman2014-03-271-15/+75
| | | | | | | | 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
* When generating the Attribute dumper code, do not dead-initialize MoreChildrenArnaud A. de Grandmaison2014-03-211-1/+1
| | | | | | No functional change. This will cleanup a bunch of scan-build warnings. llvm-svn: 204529
OpenPOWER on IntegriCloud