summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Thread Safety Analysis: warnings for attributes without argumentsAaron Puchert2018-09-201-19/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When thread safety annotations are used without capability arguments, they are assumed to apply to `this` instead. So we warn when either `this` doesn't exist, or the class is not a capability type. This is based on earlier work by Josh Gao that was committed in r310403, but reverted in r310698 because it didn't properly work in template classes. See also D36237. The solution is not to go via the QualType of `this`, which is then a template type, hence the attributes are not known because it could be specialized. Instead we look directly at the class in which we are contained. Additionally I grouped two of the warnings together. There are two issues here: the existence of `this`, which requires us to be a non-static member function, and the appropriate annotation on the class we are contained in. So we don't distinguish between not being in a class and being static, because in both cases we don't have `this`. Fixes PR38399. Reviewers: aaron.ballman, delesley, jmgao, rtrieu Reviewed By: delesley Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51901 llvm-svn: 342605
* [ThreadSafetyAnalysis] Fix isCapabilityExprYi Kong2017-12-141-1/+2
| | | | | | | | | | | | There are many more expr types that can be a capability expr, like CXXThisExpr, CallExpr, MemberExpr. Instead of enumerating all of them, just check typeHasCapability for any type given. Also add & and * operators to allowed unary operators. Differential Revision: https://reviews.llvm.org/D41224 llvm-svn: 320753
* Determine the attribute subject for diagnostics based on declarative ↵Aaron Ballman2017-11-261-36/+36
| | | | | | | | | | information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing. This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc). Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute). llvm-svn: 319002
* Revert "Thread Safety Analysis: warn on nonsensical attributes."Josh Gao2017-08-111-34/+21
| | | | | | | This reverts commit rL310403, which caused spurious warnings in libc++, because it didn't properly handle templated scoped lockable types. llvm-svn: 310698
* Thread Safety Analysis: warn on nonsensical attributes.Josh Gao2017-08-081-21/+34
| | | | | | | | | | | | | Add warnings in cases where an implicit `this` argument is expected to attributes because either `this` doesn't exist because the attribute is on a free function, or because `this` is on a type that doesn't have a corresponding capability/lockable/scoped_lockable attribute. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310403
* [NFC] Add original test that triggered crash post r301735 Faisal Vali2017-05-021-1/+13
| | | | | | - this is added just for completeness sake (though the general case should be represented by the test added in the revision to that patch: https://reviews.llvm.org/rL301972 ) llvm-svn: 301973
* [Test] Make Lit tests C++11 compatible #10Charles Li2017-02-241-8/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D21626 llvm-svn: 296193
* None of these attributes require FunctionTemplate to be explicitly listed as ↵Aaron Ballman2014-05-201-50/+50
| | | | | | | | 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
* Capability attributes can now be declared on a typedef declaration as well ↵Aaron Ballman2014-03-241-21/+21
| | | | | | as a structure declaration. This allows for C code to use Boolean expressions on a capability as part of another attribute. Eg) __attribute__((requires_capability(!SomeCapability))) llvm-svn: 204657
* DeLesley Hutchins (who wrote the original thread-safety attribute ↵Aaron Ballman2014-02-181-16/+16
| | | | | | | | | | | | | | | functionality) and I have agreed to start migrating from lock-specific terminology to "capability"-specific terminology. This opens the door for future threading-related analysis passes so that a common nomenclature can be used. The following attributes have been (silently) deprecated, with their replacements listed: lockable => capability exclusive_locks_required => requires_capability shared_locks_required => requires_shared_capability locks_excluded => requires_capability There are no functional changes intended. llvm-svn: 201585
* Removing some more unnecessary manual quotes from attribute diagnostics. ↵Aaron Ballman2014-01-021-3/+3
| | | | | | Updated the associated testcase because QualType pretty printing was an improvement. llvm-svn: 198372
* Updated the wording of two attribute-related diagnostics so that they print ↵Aaron Ballman2014-01-021-9/+9
| | | | | | the offending attribute name. Also updates the associated test cases. llvm-svn: 198355
* Removed a duplicate diagnostic related to attribute subjects for thread ↵Aaron Ballman2013-11-201-12/+12
| | | | | | safety annotations, and replaced it with the more general attribute diagnostic. Updated the test case in the one instance where wording changed. No functional change intended. llvm-svn: 195275
* Guard availability and thread safety attributes against wide strings.Benjamin Kramer2013-09-131-0/+2
| | | | | | Found by inspection. llvm-svn: 190701
* Added the attribute name to the err_attribute_wrong_number_arguments ↵Aaron Ballman2013-07-231-15/+15
| | | | | | | | diagnostic for clarity; updated almost all of the affected test cases. Thanks to Fariborz Jahanian for the suggestion! llvm-svn: 186980
* Consolidate several attribute argument diagnostics into a single, selectable ↵Aaron Ballman2013-07-231-6/+6
| | | | | | diagnostic. This makes the diagnostic more consistent. llvm-svn: 186940
* Thread safety analysis: add two new attributes to the thread safety analysis:DeLesley Hutchins2013-05-171-3/+13
| | | | | | | assert_exclusive_lock and assert_shared_lock. These attributes are used to mark functions that dynamically check (i.e. assert) that a lock is held. llvm-svn: 182170
* Thread safety analysis: Fixed ICE caused by double delete when late parsedDeLesley Hutchins2012-11-021-0/+22
| | | | | | attributes are attached to function declarations nested inside a class method. llvm-svn: 167321
* Thread-safety analysis: fix scoping issues related to 'this', including anDeLesley Hutchins2012-08-201-1/+26
| | | | | | ICE in friend functions. llvm-svn: 162229
* Thread safety analysis: prevent a compiler error in cases where aDeLesley Hutchins2012-08-151-0/+10
| | | | | | late-parsed attribute is attached to an invalid declaration. llvm-svn: 161997
* Thread safety analysis: check for LOCKABLE attribute on base classes.DeLesley Hutchins2012-05-041-1/+36
| | | | llvm-svn: 156175
* Thread safety analysis: additional support for smart pointers in lock ↵DeLesley Hutchins2012-05-021-2/+7
| | | | | | expressions. llvm-svn: 156030
* Thread Safety Analysis: fixed attribute handling for lock_returned attribute.DeLesley Hutchins2012-05-021-1/+3
| | | | llvm-svn: 156005
* Thread safety analysis: refactor test cases so that the style isDeLesley Hutchins2012-04-231-373/+373
| | | | | | consistent. llvm-svn: 155388
* Thread safety analysis: support the use of pt_guarded_by attributesDeLesley Hutchins2012-04-231-0/+30
| | | | | | on smart pointers. Also adds test case for previous commit. llvm-svn: 155379
* Thread-safety analysis: support new "pointer to member" syntax forDeLesley Hutchins2012-04-231-0/+15
| | | | | | existentially quantified lock expressions. llvm-svn: 155357
* Thread safety analysis: split warnings into two groups: attribute warningsDeLesley Hutchins2012-04-191-12/+12
| | | | | | | | | | which are checked in the parser, and analysis warnings that require the full analysis. This allows attribute syntax to be checked independently of the full thread safety analysis. Also introduces a new warning for the case where a string is used as a lock expression; this allows the analysis to gracefully handle expressions that would otherwise cause a parse error. llvm-svn: 155129
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. llvm-svn: 154799
* Thread safety analysis: downgraded requirement that mutex expressions refer ↵DeLesley Hutchins2012-04-061-49/+49
| | | | | | to a lockable type from error to warning. llvm-svn: 154198
* Fixed scoping error for late parsed attributes in nested classes.DeLesley Hutchins2012-04-061-3/+41
| | | | llvm-svn: 154173
* Make late-parsed attributes follow the conventions of ordinaryDeLesley Hutchins2012-03-021-0/+16
| | | | | | | GNU attributes to a better extent, by allowing them in more places on a declator. llvm-svn: 151945
* Allow thread safety attributes on function definitions.DeLesley Hutchins2012-02-161-0/+27
| | | | | | | | For compatibility with gcc, clang will now parse gcc attributes on function definitions, but issue a warning if the attribute is not a thread safety attribute. Warning controlled by -Wgcc-compat. llvm-svn: 150698
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Allow empty argument lists in thread safety attributesDeLesley Hutchins2011-12-141-0/+9
| | | | llvm-svn: 146580
* Thread safety: small formatting change in test commentsCaitlin Sadowski2011-09-081-181/+181
| | | | llvm-svn: 139306
* Thread safety: added support for function scopes in attribute arguments.Caitlin Sadowski2011-09-081-0/+34
| | | | | | This patch was written by DeLesley Hutchins. llvm-svn: 139302
* Thread Safety: Patch to implement delayed parsing of attributes within aCaitlin Sadowski2011-09-081-0/+22
| | | | | | | | class scope. This patch was also written by DeLesley Hutchins. llvm-svn: 139301
* Thread safety: various minor bugfixes, with test casesCaitlin Sadowski2011-08-291-0/+58
| | | | | | This patch is by DeLesley Hutchins. llvm-svn: 138738
* Thread-safety analysis: adding in a basic lockset tracking system. ThisCaitlin Sadowski2011-08-231-0/+1141
system flags an error when unlocking a lock which was not held, locking the same lock twice, having a different lockset on each iteration of a loop, or going out of scope while still holding a lock. In order to successfully use the lockset, this patch also makes sure that attribute arguments are attached correctly for later parsing. This patch was also worked on by DeLesley Hutchins. Note: This patch has been reviewed by Chandler Carruth and Jeffrey Yasskin. Feel free to provide post-commit review comments for a subsequent patch. llvm-svn: 138350
OpenPOWER on IntegriCloud