@@ -18,11 +18,14 @@ import semmle.code.cpp.controlflow.Dominance
18
18
19
19
class ThreadSpawningFunction extends Function {
20
20
ThreadSpawningFunction ( ) {
21
- this .hasName ( "pthread_create" ) or
22
- this .hasName ( "thrd_create" ) or
21
+ this .hasName ( "pthread_create" )
22
+ or
23
+ this .hasName ( "thrd_create" )
24
+ or
23
25
exists ( FunctionCall fc |
24
26
fc .getTarget ( ) instanceof ThreadSpawningFunction and
25
- fc .getEnclosingFunction ( ) = this )
27
+ fc .getEnclosingFunction ( ) = this
28
+ )
26
29
}
27
30
}
28
31
@@ -37,21 +40,20 @@ class AtomicInitAddressOfExpr extends FunctionCall {
37
40
)
38
41
}
39
42
40
- Expr getAddressedExpr ( ) {
41
- result = addressedExpr
42
- }
43
+ Expr getAddressedExpr ( ) { result = addressedExpr }
43
44
}
44
45
45
46
ControlFlowNode getARequiredInitializationPoint ( LocalScopeVariable v ) {
46
47
result = v .getParentScope ( ) .( BlockStmt ) .getFollowingStmt ( )
47
48
or
48
49
exists ( DeclStmt decl |
49
50
decl .getADeclaration ( ) = v and
50
- result = any ( FunctionCall fc
51
- | fc .getTarget ( ) instanceof ThreadSpawningFunction and
52
- fc .getEnclosingBlock ( ) .getEnclosingBlock * ( ) = v .getParentScope ( ) and
53
- fc .getAPredecessor * ( ) = decl
54
- )
51
+ result =
52
+ any ( FunctionCall fc |
53
+ fc .getTarget ( ) instanceof ThreadSpawningFunction and
54
+ fc .getEnclosingBlock ( ) .getEnclosingBlock * ( ) = v .getParentScope ( ) and
55
+ fc .getAPredecessor * ( ) = decl
56
+ )
55
57
)
56
58
}
57
59
63
65
not v .isTopLevel ( ) and
64
66
not exists ( v .getInitializer ( ) ) and
65
67
exists ( ControlFlowNode missingInitPoint |
66
- missingInitPoint = getARequiredInitializationPoint ( v )
67
- and not exists ( AtomicInitAddressOfExpr initialization |
68
+ missingInitPoint = getARequiredInitializationPoint ( v ) and
69
+ not exists ( AtomicInitAddressOfExpr initialization |
68
70
initialization .getAddressedExpr ( ) .( VariableAccess ) .getTarget ( ) = v and
69
71
dominates ( initialization , missingInitPoint )
70
72
)
0 commit comments