@@ -18,11 +18,14 @@ import semmle.code.cpp.controlflow.Dominance
1818
1919class ThreadSpawningFunction extends Function {
2020 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
2325 exists ( FunctionCall fc |
2426 fc .getTarget ( ) instanceof ThreadSpawningFunction and
25- fc .getEnclosingFunction ( ) = this )
27+ fc .getEnclosingFunction ( ) = this
28+ )
2629 }
2730}
2831
@@ -37,21 +40,20 @@ class AtomicInitAddressOfExpr extends FunctionCall {
3740 )
3841 }
3942
40- Expr getAddressedExpr ( ) {
41- result = addressedExpr
42- }
43+ Expr getAddressedExpr ( ) { result = addressedExpr }
4344}
4445
4546ControlFlowNode getARequiredInitializationPoint ( LocalScopeVariable v ) {
4647 result = v .getParentScope ( ) .( BlockStmt ) .getFollowingStmt ( )
4748 or
4849 exists ( DeclStmt decl |
4950 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+ )
5557 )
5658}
5759
6365 not v .isTopLevel ( ) and
6466 not exists ( v .getInitializer ( ) ) and
6567 exists ( ControlFlowNode missingInitPoint |
66- missingInitPoint = getARequiredInitializationPoint ( v )
67- and not exists ( AtomicInitAddressOfExpr initialization |
68+ missingInitPoint = getARequiredInitializationPoint ( v ) and
69+ not exists ( AtomicInitAddressOfExpr initialization |
6870 initialization .getAddressedExpr ( ) .( VariableAccess ) .getTarget ( ) = v and
6971 dominates ( initialization , missingInitPoint )
7072 )
0 commit comments