Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita24fca8

Browse files
committed
Merge branch 'lcartey/final-compiler-compat-issues' of github.com:github/codeql-coding-standards into lcartey/final-compiler-compat-issues
2 parentsf6a9d30 +862c8fe commita24fca8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

‎cpp/common/src/codingstandards/cpp/Concurrency.qll‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ class CPPMutexFunctionCall extends MutexFunctionCall {
114114
/**
115115
* Holds if this `CPPMutexFunctionCall` is a lock.
116116
*/
117-
overridepredicateisLock(){getTarget().getName()="lock"}
117+
overridepredicateisLock(){
118+
notisLockingOperationWithinLockingOperation(this)and
119+
getTarget().getName()="lock"
120+
}
118121

119122
/**
120123
* Holds if this `CPPMutexFunctionCall` is a speculative lock, defined as calling
@@ -172,6 +175,7 @@ class CMutexFunctionCall extends MutexFunctionCall {
172175
* Holds if this `CMutexFunctionCall` is a lock.
173176
*/
174177
overridepredicateisLock(){
178+
notisLockingOperationWithinLockingOperation(this)and
175179
getTarget().getName()=["mtx_lock","mtx_timedlock","mtx_trylock"]
176180
}
177181

@@ -296,6 +300,16 @@ abstract class LockingOperation extends FunctionCall {
296300
* Holds if this is an unlock operation
297301
*/
298302
abstractpredicateisUnlock();
303+
304+
/**
305+
* Holds if this locking operation is really a locking operation within a
306+
* designated locking operation. This library assumes the underlying locking
307+
* operations are implemented correctly in that calling a `LockingOperation`
308+
* results in the creation of a singular lock.
309+
*/
310+
predicateisLockingOperationWithinLockingOperation(LockingOperationinner){
311+
exists(LockingOperationouter|outer.getTarget()=inner.getEnclosingFunction())
312+
}
299313
}
300314

301315
/**
@@ -317,6 +331,7 @@ class RAIIStyleLock extends LockingOperation {
317331
* Holds if this is a lock operation
318332
*/
319333
overridepredicateisLock(){
334+
notisLockingOperationWithinLockingOperation(this)and
320335
thisinstanceofConstructorCalland
321336
lock=getArgument(0).getAChild*()and
322337
// defer_locks don't cause a lock

‎cpp/common/src/codingstandards/cpp/rules/preventdeadlockbylockinginpredefinedorder/PreventDeadlockByLockingInPredefinedOrder.qll‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ predicate getAnOrderedLockPair(
2424
lock1=node.coveredByLock()and
2525
lock2=node.coveredByLock()and
2626
notlock1=lock2and
27-
lock1.getEnclosingFunction()=lock2.getEnclosingFunction()and
27+
exists(Functionf|
28+
lock1.getEnclosingFunction()=fand
29+
lock2.getEnclosingFunction()=fand
30+
node.getBasicBlock().getEnclosingFunction()=f
31+
)and
2832
exists(Locationl1Loc,Locationl2Loc|
2933
l1Loc=lock1.getLocation()and
3034
l2Loc=lock2.getLocation()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp