summaryrefslogtreecommitdiffstats
path: root/clang/utils/TableGen/ClangAttrEmitter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add -f[no-]double-square-bracket-attributes as new driver options to control ↵Aaron Ballman2017-10-151-28/+50
| | | | | | use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a proposal to add [[]] attributes to C2x, but also allows you to enable these attributes in C++98, or disable them in C++11 or later. llvm-svn: 315856
* Do not look through pack expansions when looking for unexpanded parameter packs.Richard Smith2017-08-151-0/+21
| | | | | | | Fixes a selection of rejects-valids when pack-expanding a lambda that itself contains a pack expansion. llvm-svn: 310972
* [TableGen] Clang changes to support Record::getValueAsString and ↵Craig Topper2017-05-311-22/+28
| | | | | | | | | | getValueAsListOfStrings returning StringRef instead of std::string This is the clang version of D33710. Differential Revision: https://reviews.llvm.org/D33711 llvm-svn: 304326
* Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods ↵Argyrios Kyrtzidis2017-05-241-1/+5
| | | | | | | | and properties as well This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods. llvm-svn: 303712
* utils: Silence -Wpedantic warningSaleem Abdulrasool2017-05-011-2/+2
| | | | | | | | | | llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp:1673:67: warning: default argument specified for lambda parameter [-Wpedantic] const Record *Constraint = nullptr) { ^~~~~~~ Found by gcc 5.4.0. llvm-svn: 301783
* Add #pragma clang attribute support to the external_source_symbol attributeAlex Lorenz2017-04-191-24/+113
| | | | | | | | | | | | | | | | | | | Prior to this commit the external_source_symbol attribute wasn't supported by #pragma clang attribute for the following two reasons: - The Named attribute subject hasn't been supported by TableGen. - There was no way to specify a subject match rule for #pragma clang attribute that could operate on a set of attribute subjects (e.g. the ones that derive from NamedDecl). This commit fixes the two issues and thus adds external_source_symbol support to #pragma clang attribute. rdar://31169028 Differential Revision: https://reviews.llvm.org/D32176 llvm-svn: 300712
* Add #pragma clang attributeAlex Lorenz2017-04-181-7/+438
| | | | | | | | | | | | | | | | | This is a recommit of r300539 that was reverted in r300543 due to test failures. The original commit message is displayed below: The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300556
* Revert r300539 - Add #pragma clang attributeAlex Lorenz2017-04-181-438/+7
| | | | | | | Some tests fail on the Windows buildbots. I will have to investigate more. This commit reverts r300539, r300540 and r300542. llvm-svn: 300543
* Fix one more 'not all control paths return a value' MSVC warningAlex Lorenz2017-04-181-1/+1
| | | | | | The warning was caused by r300539. llvm-svn: 300542
* [TableGen] Fix MSVC warning that occurs in TableGen generated functionAlex Lorenz2017-04-181-1/+3
| | | | | | This should fix the Windows buildbot failure that happened after r300539. llvm-svn: 300540
* Add #pragma clang attributeAlex Lorenz2017-04-181-7/+436
| | | | | | | | | | | | | | The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300539
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-2/+2
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* Correct class-template deprecation behavior-REDUXErich Keane2017-03-231-16/+28
| | | | | | | | | | | | | | | | | | Correct class-template deprecation behavior Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case: template<typename T> [[deprecated]] class Foo{}; Foo<int> f; This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute. Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute. Previous DiffRev: https://reviews.llvm.org/D27486, was reverted. This patch fixes the issues brought up here by the reverter: https://reviews.llvm.org/rL298410 Differential Revision: https://reviews.llvm.org/D31245 llvm-svn: 298634
* Revert "Correct class-template deprecation behavior"Martin Bohme2017-03-221-28/+16
| | | | | | | This reverts commit r298410 (which produces incorrect warnings, see comments on https://reviews.llvm.org/rL298410). llvm-svn: 298504
* Correct class-template deprecation behaviorErich Keane2017-03-211-16/+28
| | | | | | | | | | | | | Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case: template<typename T> [[deprecated]] class Foo{}; Foo<int> f; This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute. Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute. Differential Revision: https://reviews.llvm.org/D27486 llvm-svn: 298410
* Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.David L. Jones2017-01-241-19/+19
| | | | | | | | | | | | | | | Summary: This patch changes TableGen-generated code in AttrPCHRead to call functions on ASTRecordReader, instead of passing separate parameters to ASTReader. This is a follow-up to r290217. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28007 llvm-svn: 292868
* [TableGen] Only normalize the spelling of GNU-style attributes.Justin Lebar2017-01-051-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When Sema looks up an attribute name, it strips off leading and trailing "__" if the attribute is GNU-style. That is, __attribute__((foo)) and __attribute__((__foo__)) are equivalent. This is only true for GNU-style attributes. In particular, __declspec(__foo__) is not equivalent to __declspec(foo), and Sema respects this difference. This patch fixes TableGen to match Sema's behavior. The spelling 'GNU<"__foo__">' should be normalized to 'GNU<"foo">', but 'Declspec<"__foo__">' should not be changed. This is necessary to make CUDA compilation work on Windows, because e.g. the __device__ attribute is spelled __declspec(__device__). Attr.td does not contain any Declspec spellings that start or end with "__", so this change should not affect any other attributes. Reviewers: rnk Subscribers: cfe-commits, tra Differential Revision: https://reviews.llvm.org/D28318 llvm-svn: 291129
* TableGen: Adapt to llvm r288612Matthias Braun2016-12-041-3/+3
| | | | llvm-svn: 288614
* [TableGen] Ignore fake args for parsing-related arg counts.George Burgess IV2016-12-011-0/+4
| | | | | | | | | | | | | | | | | | We should complain about the following: ``` void foo() __attribute__((unavailable("a", "b"))); ``` Instead, we currently just ignore "b". (...We also end up ignoring "a", because we assume elsewhere that this attribute can only have 1 or 0 args.) This happens because `unavailable` has a fake enum arg, and `AttributeList::{getMinArgs,getMaxArgs}` include fake args in their counts. llvm-svn: 288388
* [TableGen] Minor clean-ups. NFC.George Burgess IV2016-12-011-52/+42
| | | | | | | | | Primarily: try to use DenseSet<StringRef> instead of std::set<std::string>, and use pretty range algos where we can. Small sizes were arbitrarily chosen. llvm-svn: 288297
* [tablegen] Check that an optional IdentifierArgument of an attribute isAkira Hatanaka2016-09-101-1/+7
| | | | | | | | | | | | provided before trying to print it. This fixes a segfault that occurs when function printPretty generated by tablegen tries to print an optional argument of attribute objc_bridge_related. rdar://problem/28155469 llvm-svn: 281132
* Add plumbing for new attribute type "Microsoft".Nico Weber2016-09-031-6/+22
| | | | | | | | This is for attributes in []-delimited lists preceding a class, like e.g. `[uuid("...")] class Foo {};` Not used by anything yet, so no behavior change. Part of https://reviews.llvm.org/D23895 llvm-svn: 280575
* Implement __attribute__((require_constant_initialization)) for safe static ↵Eric Fiselier2016-09-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialization. Summary: This attribute specifies expectations about the initialization of static and thread local variables. Specifically that the variable has a [constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization) according to the rules of [basic.start.static]. Failure to meet this expectation will result in an error. Static objects with constant initializers avoid hard-to-find bugs caused by the indeterminate order of dynamic initialization. They can also be safely used by other static constructors across translation units. This attribute acts as a compile time assertion that the requirements for constant initialization have been met. Since these requirements change between dialects and have subtle pitfalls it's important to fail fast instead of silently falling back on dynamic initialization. ```c++ // -std=c++14 #define SAFE_STATIC __attribute__((require_constant_initialization)) static struct T { constexpr T(int) {} ~T(); }; SAFE_STATIC T x = {42}; // OK. SAFE_STATIC T y = 42; // error: variable does not have a constant initializer // copy initialization is not a constant expression on a non-literal type. ``` This attribute can only be applied to objects with static or thread-local storage duration. Reviewers: majnemer, rsmith, aaron.ballman Subscribers: jroelofs, cfe-commits Differential Revision: https://reviews.llvm.org/D23385 llvm-svn: 280525
* Revert r280516 since it contained accidental changes.Eric Fiselier2016-09-021-3/+1
| | | | llvm-svn: 280521
* Implement __attribute__((require_constant_initialization)) for safe static ↵Eric Fiselier2016-09-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialization. Summary: This attribute specifies expectations about the initialization of static and thread local variables. Specifically that the variable has a [constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization) according to the rules of [basic.start.static]. Failure to meet this expectation will result in an error. Static objects with constant initializers avoid hard-to-find bugs caused by the indeterminate order of dynamic initialization. They can also be safely used by other static constructors across translation units. This attribute acts as a compile time assertion that the requirements for constant initialization have been met. Since these requirements change between dialects and have subtle pitfalls it's important to fail fast instead of silently falling back on dynamic initialization. ```c++ // -std=c++14 #define SAFE_STATIC __attribute__((require_constant_initialization)) static struct T { constexpr T(int) {} ~T(); }; SAFE_STATIC T x = {42}; // OK. SAFE_STATIC T y = 42; // error: variable does not have a constant initializer // copy initialization is not a constant expression on a non-literal type. ``` This attribute can only be applied to objects with static or thread-local storage duration. Reviewers: majnemer, rsmith, aaron.ballman Subscribers: jroelofs, cfe-commits Differential Revision: https://reviews.llvm.org/D23385 llvm-svn: 280516
* Sema: support __declspec(dll*) on ObjC interfacesSaleem Abdulrasool2016-07-151-0/+9
| | | | | | | | | | | Extend the __declspec(dll*) attribute to cover ObjC interfaces. This was requested by Microsoft for their ObjC support. Cover both import and export. This only adds the semantic analysis portion of the support, code-generation still remains outstanding. Add some basic initial documentation on the attributes that were previously empty. Tweak the previous tests to use the relative expected-warnings to make the tests easier to read. llvm-svn: 275610
* Use ranges to concisely express iterationDavid Majnemer2016-06-231-2/+2
| | | | | | | No functional change is intended, this should just clean things up a little. llvm-svn: 273522
* Work around MinGW's macro definition of 'interface' to 'struct'Reid Kleckner2016-05-311-0/+5
| | | | | | | | | | | Previous attempts to rename the IBOutletCollection argument to something other than "Interface" were undone (r127127 and r139620). Instead of renaming it, work around this in tablegen, so the public facing getter can have the usual name of 'getInterface'. Fixes PR26682 llvm-svn: 271305
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-4/+4
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
* Turn copies into references as suggested by clang-tidy's ↵Benjamin Kramer2016-05-271-6/+7
| | | | | | performance-unnecessary-copy-initialization. llvm-svn: 270994
* Fix use-after-free ASan failures for modules / PCH files that deserialize ↵Richard Smith2016-05-181-7/+33
| | | | | | abi_tag or no_sanitize attributes. llvm-svn: 269869
* Fix Clang-tidy modernize-use-bool-literals in generated code.Eugene Zelenko2016-05-121-16/+118
| | | | | | | | | | Reduce space in empty constructors and between data members and first public section. Fix some Include What You Use warnings. Differential revision: http://reviews.llvm.org/D20213 llvm-svn: 269371
* Revert unnecessary tblgen change.Peter Collingbourne2016-04-271-1/+0
| | | | llvm-svn: 267788
* Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne2016-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bitsets, and the compiler features they rely on (vtable opt, CFI), only have visibility within the LTO'd part of the linkage unit. Therefore, only enable these features for classes with hidden LTO visibility. This notion is based on object file visibility or (on Windows) dllimport/dllexport attributes. We provide the [[clang::lto_visibility_public]] attribute to override the compiler's LTO visibility inference in cases where the class is defined in the non-LTO'd part of the linkage unit, or where the ABI supports calling classes derived from abstract base classes with hidden visibility in other linkage units (e.g. COM on Windows). If the cross-DSO CFI mode is enabled, bitset checks are emitted even for classes with public LTO visibility, as that mode uses a separate mechanism to cause bitsets to be exported. This mechanism replaces the whole-program-vtables blacklist, so remove the -fwhole-program-vtables-blacklist flag. Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the support for the special attr:uuid blacklist entry is removed. Differential Revision: http://reviews.llvm.org/D18635 llvm-svn: 267784
* Re-commit r265518 ("[modules] Continue factoring encoding of AST records out ofRichard Smith2016-04-061-14/+11
| | | | | | | ASTWriter."), reverted in r265526, with a fix for an iterator invalidation bug (thanks, MSan!). llvm-svn: 265564
* Revert "[modules] Continue factoring encoding of AST records out of ASTWriter."Dmitry Polukhin2016-04-061-11/+14
| | | | | | This reverts commit r265518. llvm-svn: 265526
* [modules] Continue factoring encoding of AST records out of ASTWriter.Richard Smith2016-04-061-14/+11
| | | | llvm-svn: 265518
* Add an optional string argument to DeprecatedAttr for Fix-It.Manman Ren2016-03-161-0/+11
| | | | | | | | We only add this to __attribute__((deprecated)). Differential Revision: http://reviews.llvm.org/D17865 llvm-svn: 263652
* Print strict in Availability attribute when it is on.Manman Ren2016-03-101-0/+1
| | | | llvm-svn: 263172
* P0188R1: add support for standard [[fallthrough]] attribute. This is almostRichard Smith2016-03-081-0/+2
| | | | | | | | | | | | | | exactly the same as clang's existing [[clang::fallthrough]] attribute, which has been updated to have the same semantics. The one significant difference is that [[fallthrough]] is ill-formed if it's not used immediately before a switch label (even when -Wimplicit-fallthrough is disabled). To support that, we now build a CFG of any function that uses a '[[fallthrough]];' statement to check. In passing, fix some bugs with our support for statement attributes -- in particular, diagnose their use on declarations, rather than asserting. llvm-svn: 262881
* Semantic analysis for the swiftcall calling convention.John McCall2016-03-031-1/+2
| | | | | | | I've tried to keep the infrastructure behind parameter ABI treatments fairly general. llvm-svn: 262587
* Add an llvm_unreachable back to the autogeneration of this covered switch.John McCall2016-03-011-1/+2
| | | | llvm-svn: 262288
* Infrastructure improvements to Clang attribute TableGen.John McCall2016-03-011-82/+198
| | | | | | This should make it easier to add new Attr subclasses. llvm-svn: 262275
* Fix a leak in the generated code for attributes with strings.Benjamin Kramer2016-02-131-4/+17
| | | | | | | | Storing std::strings in attributes simply doesn't work, we never call the destructor. Use an array of StringRefs instead of std::strings and copy the data into memory taken from the ASTContext. llvm-svn: 260831
* [TableGen] Merge the SuperClass Record and SMRange vector a single vector. ↵Craig Topper2016-01-181-10/+10
| | | | | | This removes the state needed to manage the extract vector. NFC llvm-svn: 258066
* Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp and ↵Eugene Zelenko2015-12-081-21/+17
| | | | | | | | generated code. Differential revision: http://reviews.llvm.org/D15313 llvm-svn: 255042
* Do not crash when dumping the objc_bridge_related attribute when its ↵Aaron Ballman2015-11-301-0/+2
| | | | | | | | optional arguments are not supplied. Patch thanks to Joe Ranieri! llvm-svn: 254303
* Add the ability to define "fake" arguments on attributes.John McCall2015-10-281-67/+98
| | | | | | | | | | | | | | 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
* [ATTR] Automatic line feed after pragma-like attribute.Alexey Bataev2015-10-121-0/+1
| | | | | | | Automatically insert line feed after pretty printing of all pragma-like attributes + fix printing of pragma-like pragmas on declarations. Differential Revision: http://reviews.llvm.org/D13546 llvm-svn: 250017
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-061-4/+5
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
OpenPOWER on IntegriCloud