File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
src/semmle/code/cpp/dataflow/internal
test/library-tests/dataflow/partialdefinitions Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,12 @@ private module PartialDefinitions {
113113 )
114114 )
115115 } or
116- TExplicitCallQualifier ( Expr qualifier , Call call ) { qualifier = call .getQualifier ( ) } or
116+ TExplicitCallQualifier ( Expr qualifier ) {
117+ exists ( Call call |
118+ qualifier = call .getQualifier ( ) and
119+ not call .getTarget ( ) .hasSpecifier ( "const" )
120+ )
121+ } or
117122 TReferenceArgument ( Expr arg , VariableAccess va ) { referenceArgument ( va , arg ) }
118123
119124 private predicate isInstanceFieldWrite ( FieldAccess fa , ControlFlowNode node ) {
@@ -128,7 +133,7 @@ private module PartialDefinitions {
128133 PartialDefinition ( ) {
129134 this = TExplicitFieldStoreQualifier ( definedExpr , node )
130135 or
131- this = TExplicitCallQualifier ( definedExpr , _ ) and node = definedExpr
136+ this = TExplicitCallQualifier ( definedExpr ) and node = definedExpr
132137 or
133138 this = TReferenceArgument ( definedExpr , node )
134139 }
Original file line number Diff line number Diff line change @@ -14,3 +14,18 @@ void test()
1414 s.x = 1 ;
1515 s.y .z = 1 ;
1616}
17+
18+ struct Int {
19+ int data;
20+ Int (int value) : data(value) { } // Not a partial definition but a `PostUpdateNode`
21+ int getData () const { return data; }
22+ void setData (int value) { data = value; }
23+ };
24+
25+ int getSet () {
26+ Int myInt (1 );
27+ myInt.setData (
28+ myInt.getData () + 1 // should not be a partial def
29+ );
30+ return myInt.getData (); // should not be a partial def
31+ }
Original file line number Diff line number Diff line change 11| partialdefinitions.cpp:14:2:14:2 | partial def of s | partialdefinitions.cpp:14:2:14:2 | s | partialdefinitions.cpp:14:2:14:8 | ... = ... |
22| partialdefinitions.cpp:15:2:15:2 | partial def of s | partialdefinitions.cpp:15:2:15:2 | s | partialdefinitions.cpp:15:2:15:10 | ... = ... |
33| partialdefinitions.cpp:15:4:15:4 | partial def of y | partialdefinitions.cpp:15:4:15:4 | y | partialdefinitions.cpp:15:2:15:10 | ... = ... |
4+ | partialdefinitions.cpp:22:29:22:32 | partial def of this | file://:0:0:0:0 | this | partialdefinitions.cpp:22:29:22:40 | ... = ... |
5+ | partialdefinitions.cpp:27:3:27:7 | partial def of myInt | partialdefinitions.cpp:27:3:27:7 | myInt | partialdefinitions.cpp:27:3:27:7 | myInt |
You can’t perform that action at this time.
0 commit comments