Commit Graph

84 Commits

Author SHA1 Message Date
DeLesley Hutchins d40542213c Thread safety analysis: new test case
llvm-svn: 188571
2013-08-16 18:28:00 +00:00
DeLesley Hutchins 9f5193cf61 Thread Safety Analysis: fix bug when using TryLock with && and || expressions.
llvm-svn: 188505
2013-08-15 23:06:33 +00:00
DeLesley Hutchins b682431775 Thread safety analysis: add two new attributes to the thread safety analysis:
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
2013-05-17 23:02:59 +00:00
DeLesley Hutchins fd374bb3dd Thread safety analysis: turn on checking within lock and unlock functions.
These checks are enabled with the -Wthread-safety-beta flag.

llvm-svn: 179046
2013-04-08 20:11:11 +00:00
DeLesley Hutchins eb849c6bd5 Thread safety analysis: make sure that expressions in attributes are parsed
in an unevaluated context.

llvm-svn: 174644
2013-02-07 19:01:07 +00:00
DeLesley Hutchins 9fa426a666 Thread-safety analysis: ignore edges from throw expressions in CFG.
llvm-svn: 172858
2013-01-18 22:15:45 +00:00
DeLesley Hutchins 0cfa1a5a1d Thread-safety analysis: check member access on guarded non-primitive types.
llvm-svn: 169669
2012-12-08 03:46:30 +00:00
DeLesley Hutchins f489d2b86c Thread-safety analysis: check locks on method calls, operator=, and
copy constructors.

llvm-svn: 169350
2012-12-05 01:20:45 +00:00
DeLesley Hutchins 2d0881b577 Thread-safety analysis: support multiple thread-safety attributes on
declarations.

llvm-svn: 165826
2012-10-12 21:38:12 +00:00
DeLesley Hutchins 1fe885614d Thread-safety analysis: allow attributes on constructors to refer to 'this'.
llvm-svn: 165339
2012-10-05 22:38:19 +00:00
DeLesley Hutchins f39c0c2487 Fix template instantiation of attributes. More specifically, fix the case
where an attribute is attached to a forward declaration of a template function,
and refers to parameters of that declaration, but is then inherited by the
definition of that function.  When the definition is instantiated, the
parameter references need to be remapped.

llvm-svn: 164710
2012-09-26 17:57:31 +00:00
DeLesley Hutchins 10958cae09 Thread-safety analysis: better handling of unreachable blocks. Fixes a bug
where a call to function marked 'noreturn' is followed by unreachable
implicit destructor calls.

llvm-svn: 164394
2012-09-21 17:57:00 +00:00
DeLesley Hutchins fcb0ffa622 Thread-safety analysis: fix bug where shared trylock was treated
as exclusive.

llvm-svn: 164332
2012-09-20 23:14:43 +00:00
DeLesley Hutchins b78aeed26e Thread safety analysis: properly canonicalize calls to virtual methods within
lock expressions.

llvm-svn: 164324
2012-09-20 22:18:02 +00:00
DeLesley Hutchins 132f8f6959 Thread-safety analysis: Fix warning when EXCLUSIVE_LOCKS_REQUIRED
is placed on a function that has no path to the exit block.

llvm-svn: 164244
2012-09-19 19:49:40 +00:00
DeLesley Hutchins a15e1b4f63 Thread-safety analysis: fix ICE when EXCLUSIVE_LOCKS_REQUIRED or
LOCKS_EXCLUDED is used on a method with a name that is is not a simple
identifier.

llvm-svn: 164242
2012-09-19 19:18:29 +00:00
DeLesley Hutchins 138568b60a Thread-safety analysis: fix bug in expression matching code.
llvm-svn: 163656
2012-09-11 23:04:49 +00:00
DeLesley Hutchins 781fe380c3 Thread safety analysis: fix bug related to lock_returned attribute
on templates.

llvm-svn: 163642
2012-09-11 18:27:46 +00:00
DeLesley Hutchins 5ff1644e62 Thread-safety analysis: differentiate between two forms of analysis; a precise
analysis that may give false positives because it is confused by aliasing, and
a less precise analysis that has fewer false positives, but may have false
negatives.  The more precise warnings are enabled by -Wthread-safety-precise.
An additional note clarify the warnings in the precise case.

llvm-svn: 163537
2012-09-10 19:58:23 +00:00
Chad Rosier ea3157f1e4 Whitespace.
llvm-svn: 163404
2012-09-07 18:46:57 +00:00
DeLesley Hutchins a5a00e830a Thread-safety analysis: Add support for selectively turning off warnings
within part of a particular method.

llvm-svn: 163397
2012-09-07 17:34:53 +00:00
DeLesley Hutchins 93b1b031c1 Thread-safety analysis: bugfix for case where a trylock occurs in an
expression involving temporaries.

llvm-svn: 163237
2012-09-05 20:01:16 +00:00
DeLesley Hutchins f5cf7903d9 Thread-safety analysis: fix handling of LOCK_RETURNED attribute so that the
latest definition of a function is always used when computing lock expressions.

llvm-svn: 163028
2012-08-31 22:09:53 +00:00
DeLesley Hutchins 3c3d57bc16 Thread-safety analysis: fix handling of string constants in mutex
expressions, which should be ignored right now.

llvm-svn: 163026
2012-08-31 21:57:32 +00:00
DeLesley Hutchins 0c90c2bc4b Thread-safety-analysis: adds existential quantification over lock
expressions.  The syntax &MyClass::mutex is interpreted as a
pattern that matches m->mutex for any object m of type MyClass.

llvm-svn: 161691
2012-08-10 20:29:46 +00:00
DeLesley Hutchins 9b1d72f3e3 Thread safety analysis: refactor to support more sophisticated handling
of expressions, and better error messages.

llvm-svn: 161690
2012-08-10 20:19:55 +00:00
Sylvestre Ledru a5202660fb Fix some minor typos
llvm-svn: 161036
2012-07-31 06:56:50 +00:00
DeLesley Hutchins 868830f727 Thread safety analysis: impove handling of trylock expressions.
llvm-svn: 160018
2012-07-10 21:47:55 +00:00
DeLesley Hutchins 09bcefcb6d Thread-safety analysis: eliminate false positives in case where the definition
duplicates attributes on the declaration.  Also eliminates a false negative in
ReleasableMutexLock.  Fixing this bug required some refactoring.

llvm-svn: 159780
2012-07-05 21:16:29 +00:00
DeLesley Hutchins 3a8d6cff14 Thread safety analysis: improve handling of smart pointers.
llvm-svn: 159679
2012-07-03 19:47:18 +00:00
DeLesley Hutchins 0c1da20bf8 Thread Safety Analysis: handle expressions involving temporaries,
e.g. ExprWithCleanups.

llvm-svn: 159674
2012-07-03 18:25:56 +00:00
DeLesley Hutchins ab0d4e6cd8 Thread safety analysis: fixed bug that occurs when very silly people
use scoped_lockable without putting unlock_function on the
destructor.

llvm-svn: 159609
2012-07-02 22:26:29 +00:00
DeLesley Hutchins 6e6dbb7618 Thread safety analysis: fixed incorrect error message at the end of a locks_required function.
llvm-svn: 159607
2012-07-02 22:16:54 +00:00
DeLesley Hutchins 2a15baf968 Thread safety analysis: don't warn in case of duplicate annotation.
llvm-svn: 159606
2012-07-02 22:12:12 +00:00
DeLesley Hutchins c4a6e51596 Thread Safety Analysis: turn off checking within trylock functions.
llvm-svn: 159601
2012-07-02 21:59:24 +00:00
DeLesley Hutchins d162c91b1a Thread safety analysis: support release() function on scoped
lockable objects.

llvm-svn: 159387
2012-06-28 22:42:48 +00:00
DeLesley Hutchins 49979f2e38 Thread safety analysis: implement lock_returned attribute.
llvm-svn: 159152
2012-06-25 18:33:18 +00:00
DeLesley Hutchins ebbf77016d Thread safety analysis: fixes a bug in which locksets are not handled
properly if there is a join point in the control flow graph that involves
a trylock.  Also changes the source locations of some warnings to be
more consistent.

llvm-svn: 159008
2012-06-22 17:07:28 +00:00
Richard Smith fa139cd3bd Remove -Wc++98-compat warning for an outrageously-rare circumstance of 'this'
being used in an exception specification in a way which isn't otherwise
ill-formed in C++98: this warning also incorrectly triggered on uses of 'this'
inside thread-safety attributes, and the mechanism required to tell these cases
apart is more complex than can be justified by the (minimal) value of this part
of -Wc++98-compat.

llvm-svn: 155857
2012-04-30 23:33:33 +00:00
David Blaikie 09ffc9b473 Enable warn_impcast_literal_float_to_integer by default.
This diagnostic seems to be production ready, it's just an oversight that it
wasn't turned on by default.

The test changes are a bit of a mixed bag. Some tests that seemed like they
clearly didn't need to use this behavior have been modified not to use it.
Others that I couldn't be sure about, I added the necessary expected-warnings
to.

It's possible the diagnostic message could be improved to make it clearer that
this warning can be suppressed by using a value that won't lose precision when
converted to the target type (but can still be a floating point literal, such
as "bool b = 1.0;").

llvm-svn: 154068
2012-04-05 00:16:44 +00:00
DeLesley Hutchins e2a3f75a12 Thread safety analysis: expand set of expressions that can be used to denote locks.
llvm-svn: 151956
2012-03-02 23:36:05 +00:00
DeLesley Hutchins 71d6103295 Issue warning when late-parsed attributes have no declaration.
llvm-svn: 151947
2012-03-02 22:29:50 +00:00
DeLesley Hutchins bd2ee13e78 Make late-parsed attributes follow the conventions of ordinary
GNU attributes to a better extent, by allowing them in more
places on a declator.

llvm-svn: 151945
2012-03-02 22:12:59 +00:00
DeLesley Hutchins a2587ef26d Thread safety analysis: handle CFG blocks which call functions marked as noreturn.
llvm-svn: 151944
2012-03-02 22:02:58 +00:00
DeLesley Hutchins 5b330db270 Bugfix: bogus warning -- "invalid use of non-static data member",
when a class is forward declared, and the reference to the data
member in question does not occur within a method body.

llvm-svn: 151413
2012-02-25 00:11:55 +00:00
DeLesley Hutchins 6f13b09a00 Minor fix to template instantiation, which properly instantiates
dependent attributes on static members of templatized classes.

llvm-svn: 150704
2012-02-16 17:30:51 +00:00
DeLesley Hutchins c2286f6402 Thread-safety analysis: Disable checking inside constructors, destructors, lock, and unlock functions
llvm-svn: 150701
2012-02-16 17:13:43 +00:00
DeLesley Hutchins bc8ffdb68c Thread-Safety: added support for 'this' as a lock expression.
llvm-svn: 150700
2012-02-16 17:03:24 +00:00
DeLesley Hutchins 3fc6e4a7cd Allow thread safety attributes on function definitions.
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
2012-02-16 16:50:43 +00:00
Richard Smith 922866783b Thread safety analysis:
* When we detect that a CFG block has inconsistent lock sets, point the
   diagnostic at the location where we found the inconsistency, and point a note
   at somewhere the inconsistently-locked mutex was locked.
 * Fix the wording of the normal (non-loop, non-end-of-function) case of this
   diagnostic to not suggest that the mutex is going out of scope.
 * Fix the diagnostic emission code to keep a warning and its note together when
   sorting the diagnostics into source location order.

llvm-svn: 149669
2012-02-03 04:45:26 +00:00