aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/ThreadSafety.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-08-22[NFC] Test commitAaron Puchert1-2/+2
llvm-svn: 340452
2018-08-13Revert "Allow relockable scopes with thread safety attributes."Haojian Wu1-68/+14
This reverts commit r339456. The change introduces a new crash, see class SCOPED_LOCKABLE FileLock { public: explicit FileLock() EXCLUSIVE_LOCK_FUNCTION(file_); ~FileLock() UNLOCK_FUNCTION(file_); void Lock() EXCLUSIVE_LOCK_FUNCTION(file_); Mutex file_; }; void relockShared2() { FileLock file_lock; file_lock.Lock(); } llvm-svn: 339558
2018-08-10Allow relockable scopes with thread safety attributes.Aaron Ballman1-14/+68
Patch by Aaron Puchert llvm-svn: 339456
2018-08-09Port getLocEnd -> getEndLocStephen Kelly1-1/+1
Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-4/+4
Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
2018-08-03Properly add shared locks to the initial list of locks being tracked, ↵Aaron Ballman1-2/+2
instead of assuming unlock functions always use exclusive locks. Patch by Aaron Puchert. llvm-svn: 338912
2018-07-26Allow thread safety annotation lock upgrading and downgrading.Aaron Ballman1-15/+12
Patch thanks to Aaron Puchert! llvm-svn: 338024
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-23/+23
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-12Fix the try_acquire_capability attribute to behave like the other try-lock ↵Aaron Ballman1-2/+13
functions. Fixes PR32954. llvm-svn: 329930
2018-03-16[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko1-197/+212
other minor fixes (NFC). llvm-svn: 327746
2018-01-11Handle scoped_lockable objects being returned by value in C++17.Richard Smith1-5/+51
In C++17, guaranteed copy elision means that there isn't necessarily a constructor call when a local variable is initialized by a function call that returns a scoped_lockable by value. In order to model the effects of initializing a local variable with a function call returning a scoped_lockable, pretend that the move constructor was invoked within the caller at the point of return. llvm-svn: 322316
2017-09-06[CSA] [NFC] Move AnalysisContext.h to AnalysisDeclContext.hGeorge Karpenkov1-1/+1
The implementation is in AnalysisDeclContext.cpp and the class is called AnalysisDeclContext. Making those match up has numerous benefits, including: - Easier jump from header to/from implementation. - Easily identify filename from class. Differential Revision: https://reviews.llvm.org/D37500 llvm-svn: 312671
2017-08-08Reland "Thread Safety Analysis: fix assert_capability."Josh Gao1-2/+17
Delete the test that was broken by rL309725, and add it back in a follow up commit. Also, improve the tests a bit. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310402
2017-08-01Revert "Thread Safety Analysis: fix assert_capability."Josh Gao1-17/+2
This reverts commit rL309725. Broke test/Sema/attr-capabilities.c. llvm-svn: 309731
2017-08-01Thread Safety Analysis: fix assert_capability.Josh Gao1-2/+17
Summary: Previously, the assert_capability attribute was completely ignored by thread safety analysis. Reviewers: delesley, rnk Reviewed By: delesley Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36122 llvm-svn: 309725
2016-12-03DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith1-1/+1
temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
2016-10-21Remove move constructors that are identical to the generated default move ctor.Benjamin Kramer1-1/+1
llvm-svn: 284856
2016-07-18[NFC] Header cleanupMehdi Amini1-3/+1
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2015-11-20Thread Safety Analysis: Fix DenseMap iterator invalidation UAFReid Kleckner1-39/+36
Rather than storing BeforeInfo in the DenseMap by value, this stores a unique_ptr to it, so that we can keep a pointer to it live across subsequent DenseMap insertions. This change also removes the unique_ptr wrapper around BeforeVect because now we're indirecting at a higher level. llvm-svn: 253694
2015-10-20Roll-back r250822.Angel Garcia Gomez1-2/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+2
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-10-03Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren1-1/+1
SourceLocation.isValid(). llvm-svn: 249228
2015-09-03Thread safety analysis: the NO_THREAD_SAFETY_ANALYSIS attribute will nowDeLesley Hutchins1-25/+33
disable checking of arguments to the function, which is done by -Wthread-safety-reference. llvm-svn: 246806
2015-03-16Take the non-reference type when constructing a dummy expression.Richard Trieu1-2/+2
Otherwise, Expr will assert during construction with a reference type. llvm-svn: 232425
2015-03-09Hide away implementation details of the ThreadSafetyAnalysis in anonymous ↵Benjamin Kramer1-27/+22
namespaces NFC. llvm-svn: 231653
2015-02-04Thread Safety Analysis: support adopting of locks, as implemented inDeLesley Hutchins1-11/+24
std::lock_guard. If EXCLUSIVE_LOCKS_REQUIRED is placed on the constructor of a SCOPED_LOCKABLE class, then that constructor is assumed to adopt the lock; e.g. the lock must be held on construction, and will be released on destruction. llvm-svn: 228194
2015-02-04Thread Safety Analysis: remove minor piece of unused code. No change inDeLesley Hutchins1-4/+0
functionality. llvm-svn: 228176
2015-02-03Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins1-23/+220
These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. This patch also replaces calls to getAttrs() with calls to attrs() throughout ThreadSafety.cpp, which fixes the earlier issue that cause assert failures. llvm-svn: 228051
2015-02-03Revert "Thread Safety Analysis: add support for before/after annotations on ↵Reid Kleckner1-216/+17
mutexes." This reverts r227997, as well as r228009. It does not pass check-clang for me locally on Linux. llvm-svn: 228020
2015-02-03thread safety: Add move ctor to BeforeInfo to fix MSVC buildReid Kleckner1-0/+2
MSVC cannot infer move ctors yet. llvm-svn: 228009
2015-02-03Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins1-17/+214
These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. llvm-svn: 227997
2015-01-14[cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth1-1/+1
Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. llvm-svn: 225979
2014-11-05Thread Safety Analysis: move warnings on range-based for loops out of betaDeLesley Hutchins1-11/+9
and into -Wthread-safety. llvm-svn: 221410
2014-09-18Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, whichDeLesley Hutchins1-16/+68
warns when a guarded variable is passed by reference as a function argument. This is released as a separate warning flag, because it could potentially break existing code that uses thread safety analysis. llvm-svn: 218087
2014-09-03Allow a scoped lockable object to acquire/release multiple locks.Ed Schouten1-125/+162
Scoped lockable objects (mutex guards) are implemented as if it is a lock itself that is acquired upon construction and unlocked upon destruction. As it if course needs to be used to actually lock down something else (a mutex), it keeps track of this knowledge through its underlying mutex field in its FactEntry. The problem with this approach is that this only allows us to lock down a single mutex, so extend the code to use a vector of underlying mutexes. This, however, makes the code a bit more complex than necessary, so subclass FactEntry into LockableFactEntry and ScopedLockableFactEntry and move all the logic that differs between regular locks and scoped lockables into member functions. llvm-svn: 217016
2014-08-15Adding const-qualifiers to auto declarations. NFC.Aaron Ballman1-3/+3
llvm-svn: 215704
2014-08-14Thread safety analysis: add -Wthread-safety-verbose flag, which adds ↵DeLesley Hutchins1-0/+5
additional notes that are helpful when compiling statistics on thread safety warnings. llvm-svn: 215677
2014-08-14Thread Safety Analysis: fix to improve handling of references to guardedDeLesley Hutchins1-20/+34
data members and range based for loops. llvm-svn: 215671
2014-08-04ThreadSafety.cpp: Prune bogus \param(s). [-Wdocumentation]NAKAMURA Takumi1-3/+0
llvm-svn: 214796
2014-08-04ThreadSafetyAnalysis: Fix annotations in class members. [-Wdocumentation]NAKAMURA Takumi1-5/+5
llvm-svn: 214795
2014-08-04Thread Safety Analysis: add a -Wthread-safety-negative flag that warns wheneverDeLesley Hutchins1-32/+70
a mutex is acquired, but corresponding mutex is not provably not-held. This is based on the earlier negative requirements patch. llvm-svn: 214789
2014-08-04Thread safety analysis: Add support for negative requirements, which areDeLesley Hutchins1-268/+232
capability expressions of the form !expr, and denote a capability that must not be held. llvm-svn: 214725
2014-07-28Thread Safety Analysis: Replace the old and broken SExpr with the newDeLesley Hutchins1-723/+168
til::SExpr. This is a large patch, with many small changes to pretty printing and expression lowering to make the new SExpr representation equivalent in functionality to the old. llvm-svn: 214089
2014-05-20[C++11] Use 'nullptr'. Analysis edition.Craig Topper1-38/+39
llvm-svn: 209191
2014-05-14Converting some for loops to use range-based for loops. No functional ↵Aaron Ballman1-23/+14
changes intended. llvm-svn: 208810
2014-05-14Amending r208783 based on a suggestion by David Blaikie.Aaron Ballman1-14/+12
llvm-svn: 208800
2014-05-14Replacing some manual iterations with standard algorithms. No functional ↵Aaron Ballman1-29/+22
changes intended. llvm-svn: 208783
2014-05-14Formatting and style changes; no functional changes intended.Aaron Ballman1-8/+7
llvm-svn: 208774
2014-05-09Amending r208439 to remove buildLExpr; this code isn't strictly required ↵Aaron Ballman1-46/+0
yet, and fixes a dead code warning. llvm-svn: 208440
2014-05-09Add the ability to use logical expressions for capability attributes. This ↵Aaron Ballman1-0/+47
is to allow requirements to be expressed not just in terms of lists, but in terms of logical expressions. Eg) void foo(void) __attribute__((requires_capability((FlightControl || Worker) && !Logger))); This is WIP code. llvm-svn: 208439