summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/ThreadSafety.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-15/+15
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* [CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *.Artem Dergachev2019-05-241-4/+4
| | | | | | | | | | | Turn it into a variant class instead. This conversion does indeed save some code but there's a plan to add support for more kinds of terminators that aren't necessarily based on statements, and with those in mind it becomes more and more confusing to have CFGTerminators implicitly convertible to a Stmt *. Differential Revision: https://reviews.llvm.org/D61814 llvm-svn: 361586
* Thread safety analysis: Add note for unlock kind mismatchAaron Puchert2019-03-181-2/+2
| | | | | | | | | | | | | | | | | | Summary: Similar to D56967, we add the existing diag::note_locked_here to tell the user where we saw the locking that isn't matched correctly. Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59455 llvm-svn: 356427
* Thread safety analysis: Improve diagnostics for double lockingAaron Puchert2019-01-291-4/+5
| | | | | | | | | | | | | | | | Summary: We use the existing diag::note_locked_here to tell the user where we saw the first locking. Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56967 llvm-svn: 352549
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.Bruno Ricci2018-12-211-3/+5
| | | | | | | | | All of the other constructors already take a reference to the AST context. This avoids calling Decl::getASTContext in most cases. Additionally move the definition of the constructor from Expr.h to Expr.cpp since it is calling DeclRefExpr::computeDependence. NFC. llvm-svn: 349901
* Thread safety analysis: Avoid intermediate copies [NFC]Aaron Puchert2018-12-161-21/+31
| | | | | | | The main reason is to reduce the number of constructor arguments though, especially since many of them had the same type. llvm-svn: 349308
* Thread safety analysis: Allow scoped releasing of capabilitiesAaron Puchert2018-12-161-39/+73
| | | | | | | | | | | | | | | | | | | | | | Summary: The pattern is problematic with C++ exceptions, and not as widespread as scoped locks, but it's still used by some, for example Chromium. We are a bit stricter here at join points, patterns that are allowed for scoped locks aren't allowed here. That could still be changed in the future, but I'd argue we should only relax this if people ask for it. Fixes PR36162. Reviewers: aaron.ballman, delesley, pwnall Reviewed By: delesley, pwnall Subscribers: pwnall, cfe-commits Differential Revision: https://reviews.llvm.org/D52578 llvm-svn: 349300
* Create ConstantExpr classBill Wendling2018-10-311-2/+2
| | | | | | | | | | | | | | | | A ConstantExpr class represents a full expression that's in a context where a constant expression is required. This class reflects the path the evaluator took to reach the expression rather than the syntactic context in which the expression occurs. In the future, the class will be expanded to cache the result of the evaluated expression so that it's not needlessly re-evaluated Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D53475 llvm-svn: 345692
* Thread safety analysis: Handle conditional expression in getTrylockCallExprAaron Puchert2018-10-061-1/+13
| | | | | | | | | | | | | | | | | | | | | Summary: We unwrap conditional expressions containing try-lock functions. Additionally we don't acquire on conditional expression branches, since that is usually not helpful. When joining the branches we would almost certainly get a warning then. Hopefully fixes an issue that was raised in D52398. Reviewers: aaron.ballman, delesley, hokein Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52888 llvm-svn: 343902
* Thread safety analysis: Examine constructor argumentsAaron Puchert2018-10-041-51/+49
| | | | | | | | | | | | | | | | | | | | Summary: Instead of only examining call arguments, we also examine constructor arguments applying the same rules. That was an opportunity for refactoring the examination procedure to work with iterators instead of integer indices. For the case of CallExprs no functional change is intended. Reviewers: aaron.ballman, delesley Reviewed By: delesley Subscribers: JonasToth, cfe-commits Differential Revision: https://reviews.llvm.org/D52443 llvm-svn: 343831
* Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExprAaron Puchert2018-10-031-1/+5
| | | | | | | | | | | | | | | | | | Summary: When people are really sure they'll get the lock they sometimes use __builtin_expect. It's also used by some assertion implementations. Asserting that try-lock succeeded is basically the same as asserting that the lock is not held by anyone else (and acquiring it). Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D52398 llvm-svn: 343681
* Eliminate some unneeded signed/unsigned conversionsAaron Puchert2018-09-221-5/+5
| | | | | | | No functional change is intended, but generally this should be a bit more safe. llvm-svn: 342823
* Thread safety analysis: Make printSCFG compile again [NFC]Aaron Puchert2018-09-211-7/+0
| | | | | | | | | Not used productively, so no observable functional change. Note that printSCFG doesn't yet work reliably, it seems to crash sometimes. llvm-svn: 342790
* Thread safety analysis: Make sure FactEntrys stored in FactManager are ↵Aaron Puchert2018-09-211-12/+12
| | | | | | | | | immutable [NFC] Since FactEntrys are stored in the FactManager, we can't manipulate them anymore when they are stored there. llvm-svn: 342787
* Thread safety analysis no longer hands when analyzing a self-referencing ↵Aaron Ballman2018-08-241-0/+3
| | | | | | | | initializer. This fixes PR38640. llvm-svn: 340636
* Remove more const_casts by using ConstStmtVisitor [NFC]Aaron Puchert2018-08-231-32/+32
| | | | | | Again, this required adding some const specifiers. llvm-svn: 340580
* Remove unnecessary const_cast [NFC]Aaron Puchert2018-08-231-7/+7
| | | | | | | | This required adding a few const specifiers on functions. Also a minor formatting fix suggested in D49885. llvm-svn: 340575
* Thread safety analysis: Allow relockable scopesAaron Puchert2018-08-221-2/+28
| | | | | | | | | | | | | | | | | | | Summary: It's already allowed to prematurely release a scoped lock, now we also allow relocking it again, possibly even in another mode. This is the second attempt, the first had been merged as r339456 and reverted in r339558 because it caused a crash. Reviewers: delesley, aaron.ballman Reviewed By: delesley, aaron.ballman Subscribers: hokein, cfe-commits Differential Revision: https://reviews.llvm.org/D49885 llvm-svn: 340459
* [NFC] Test commitAaron Puchert2018-08-221-2/+2
| | | | llvm-svn: 340452
* Revert "Allow relockable scopes with thread safety attributes."Haojian Wu2018-08-131-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
* Allow relockable scopes with thread safety attributes.Aaron Ballman2018-08-101-14/+68
| | | | | | Patch by Aaron Puchert llvm-svn: 339456
* Port getLocEnd -> getEndLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-4/+4
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Properly add shared locks to the initial list of locks being tracked, ↵Aaron Ballman2018-08-031-2/+2
| | | | | | | | instead of assuming unlock functions always use exclusive locks. Patch by Aaron Puchert. llvm-svn: 338912
* Allow thread safety annotation lock upgrading and downgrading.Aaron Ballman2018-07-261-15/+12
| | | | | | Patch thanks to Aaron Puchert! llvm-svn: 338024
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-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
* Fix the try_acquire_capability attribute to behave like the other try-lock ↵Aaron Ballman2018-04-121-2/+13
| | | | | | functions. Fixes PR32954. llvm-svn: 329930
* [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-03-161-197/+212
| | | | | | other minor fixes (NFC). llvm-svn: 327746
* Handle scoped_lockable objects being returned by value in C++17.Richard Smith2018-01-111-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
* [CSA] [NFC] Move AnalysisContext.h to AnalysisDeclContext.hGeorge Karpenkov2017-09-061-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
* Reland "Thread Safety Analysis: fix assert_capability."Josh Gao2017-08-081-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
* Revert "Thread Safety Analysis: fix assert_capability."Josh Gao2017-08-011-17/+2
| | | | | | | | This reverts commit rL309725. Broke test/Sema/attr-capabilities.c. llvm-svn: 309731
* Thread Safety Analysis: fix assert_capability.Josh Gao2017-08-011-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
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-1/+1
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* Remove move constructors that are identical to the generated default move ctor.Benjamin Kramer2016-10-211-1/+1
| | | | llvm-svn: 284856
* [NFC] Header cleanupMehdi Amini2016-07-181-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
* Thread Safety Analysis: Fix DenseMap iterator invalidation UAFReid Kleckner2015-11-201-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
* Roll-back r250822.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-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
* Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren2015-10-031-1/+1
| | | | | | SourceLocation.isValid(). llvm-svn: 249228
* Thread safety analysis: the NO_THREAD_SAFETY_ANALYSIS attribute will nowDeLesley Hutchins2015-09-031-25/+33
| | | | | | | disable checking of arguments to the function, which is done by -Wthread-safety-reference. llvm-svn: 246806
* Take the non-reference type when constructing a dummy expression.Richard Trieu2015-03-161-2/+2
| | | | | | Otherwise, Expr will assert during construction with a reference type. llvm-svn: 232425
* Hide away implementation details of the ThreadSafetyAnalysis in anonymous ↵Benjamin Kramer2015-03-091-27/+22
| | | | | | | | namespaces NFC. llvm-svn: 231653
* Thread Safety Analysis: support adopting of locks, as implemented inDeLesley Hutchins2015-02-041-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
* Thread Safety Analysis: remove minor piece of unused code. No change inDeLesley Hutchins2015-02-041-4/+0
| | | | | | functionality. llvm-svn: 228176
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-031-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
* Revert "Thread Safety Analysis: add support for before/after annotations on ↵Reid Kleckner2015-02-031-216/+17
| | | | | | | | | mutexes." This reverts r227997, as well as r228009. It does not pass check-clang for me locally on Linux. llvm-svn: 228020
* thread safety: Add move ctor to BeforeInfo to fix MSVC buildReid Kleckner2015-02-031-0/+2
| | | | | | MSVC cannot infer move ctors yet. llvm-svn: 228009
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-031-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
OpenPOWER on IntegriCloud