@@ -98,7 +98,7 @@ class FOpenCall extends FunctionCall {
98
98
}
99
99
100
100
abstract class FileAccess extends FunctionCall {
101
- abstract Expr getFileExpr ( ) ;
101
+ abstract VariableAccess getFileExpr ( ) ;
102
102
}
103
103
104
104
pragma [ inline]
@@ -114,17 +114,17 @@ class ImplicitFileAccess extends FileAccess {
114
114
string fileName ;
115
115
116
116
ImplicitFileAccess ( ) {
117
- fileName = "stdin" and
117
+ fileName = [ "stdin" , "_Stdin" ] and
118
118
this .getTarget ( ) .hasGlobalName ( [ "getchar" , "getwchar" , "scanf" , "scanf_s" ] )
119
119
or
120
- fileName = "stdout" and
120
+ fileName = [ "stdout" , "_Stdout" ] and
121
121
this .getTarget ( ) .hasGlobalName ( [ "printf" , "printf_s" , "puts" , "putchar" , "putwchar" ] )
122
122
or
123
- fileName = "stderr" and this .getTarget ( ) .hasGlobalName ( "perror" )
123
+ fileName = [ "stderr" , "_Stderr" ] and this .getTarget ( ) .hasGlobalName ( "perror" )
124
124
}
125
125
126
126
/** The expression corresponding to the accessed file */
127
- override Expr getFileExpr ( ) {
127
+ override VariableAccess getFileExpr ( ) {
128
128
fileName = result .( VariableAccess ) .getTarget ( ) .( GlobalVariable ) .toString ( ) or
129
129
fileName = result .findRootCause ( ) .( Macro ) .getName ( )
130
130
}
@@ -141,10 +141,10 @@ class InBandErrorReadFunctionCall extends FileAccess {
141
141
}
142
142
143
143
/** The expression corresponding to the accessed file */
144
- override Expr getFileExpr ( ) {
144
+ override VariableAccess getFileExpr ( ) {
145
145
if this instanceof ImplicitFileAccess
146
146
then result = this .( ImplicitFileAccess ) .getFileExpr ( )
147
- else result = this .getArgument ( 0 )
147
+ else result = [ this .getArgument ( 0 ) , this . getArgument ( 0 ) . ( AddressOfExpr ) . getAnOperand ( ) ]
148
148
}
149
149
}
150
150
@@ -167,10 +167,11 @@ class FileReadFunctionCall extends FileAccess {
167
167
}
168
168
169
169
/** The expression corresponding to the accessed file */
170
- override Expr getFileExpr ( ) {
170
+ override VariableAccess getFileExpr ( ) {
171
171
if this instanceof ImplicitFileAccess
172
172
then result = this .( ImplicitFileAccess ) .getFileExpr ( )
173
- else result = this .getArgument ( filePos )
173
+ else
174
+ result = [ this .getArgument ( filePos ) , this .getArgument ( filePos ) .( AddressOfExpr ) .getAnOperand ( ) ]
174
175
}
175
176
}
176
177
@@ -195,10 +196,11 @@ class FileWriteFunctionCall extends FileAccess {
195
196
}
196
197
197
198
/** The expression corresponding to the accessed file */
198
- override Expr getFileExpr ( ) {
199
+ override VariableAccess getFileExpr ( ) {
199
200
if this instanceof ImplicitFileAccess
200
201
then result = this .( ImplicitFileAccess ) .getFileExpr ( )
201
- else result = this .getArgument ( filePos )
202
+ else
203
+ result = [ this .getArgument ( filePos ) , this .getArgument ( filePos ) .( AddressOfExpr ) .getAnOperand ( ) ]
202
204
}
203
205
}
204
206
@@ -209,7 +211,9 @@ class FileCloseFunctionCall extends FileAccess {
209
211
FileCloseFunctionCall ( ) { this .getTarget ( ) .hasGlobalName ( "fclose" ) }
210
212
211
213
/** The expression corresponding to the accessed file */
212
- override Expr getFileExpr ( ) { result = this .getArgument ( 0 ) }
214
+ override VariableAccess getFileExpr ( ) {
215
+ result = [ this .getArgument ( 0 ) , this .getArgument ( 0 ) .( AddressOfExpr ) .getAnOperand ( ) ]
216
+ }
213
217
}
214
218
215
219
/**
@@ -221,5 +225,7 @@ class FilePositioningFunctionCall extends FileAccess {
221
225
}
222
226
223
227
/** The expression corresponding to the accessed file */
224
- override Expr getFileExpr ( ) { result = this .getArgument ( 0 ) }
228
+ override VariableAccess getFileExpr ( ) {
229
+ result = [ this .getArgument ( 0 ) , this .getArgument ( 0 ) .( AddressOfExpr ) .getAnOperand ( ) ]
230
+ }
225
231
}
0 commit comments