1212import cpp
1313import codingstandards.cpp.dataflow.DataFlow
1414import codingstandards.cpp.dataflow.TaintTracking
15+ private import codingstandards.cpp.Operator
1516
1617/**
1718 * A `basic_fstream` like `std::fstream`
@@ -23,15 +24,31 @@ class FileStream extends ClassTemplateInstantiation {
2324/**
2425 * A `basic_istream` like `std::istream`
2526 */
26- class IStream extends ClassTemplateInstantiation {
27- IStream ( ) { this .getTemplate ( ) .hasQualifiedName ( "std" , "basic_istream" ) }
27+ class IStream extends Type {
28+ IStream ( ) {
29+ this .( Class ) .getQualifiedName ( ) .matches ( "std::basic\\_istream%" )
30+ or
31+ this .getUnspecifiedType ( ) instanceof IStream
32+ or
33+ this .( Class ) .getABaseClass ( ) instanceof IStream
34+ or
35+ this .( ReferenceType ) .getBaseType ( ) instanceof IStream
36+ }
2837}
2938
3039/**
3140 * A `basic_ostream` like `std::ostream`
3241 */
33- class OStream extends ClassTemplateInstantiation {
34- OStream ( ) { this .getTemplate ( ) .hasQualifiedName ( "std" , "basic_ostream" ) }
42+ class OStream extends Type {
43+ OStream ( ) {
44+ this .( Class ) .getQualifiedName ( ) .matches ( "std::basic\\_ostream%" )
45+ or
46+ this .getUnspecifiedType ( ) instanceof OStream
47+ or
48+ this .( Class ) .getABaseClass ( ) instanceof OStream
49+ or
50+ this .( ReferenceType ) .getBaseType ( ) instanceof OStream
51+ }
3552}
3653
3754/**
@@ -53,7 +70,7 @@ predicate sameStreamSource(FileStreamFunctionCall a, FileStreamFunctionCall b) {
5370 * Insertion `operator<<` and Extraction `operator>>` operators.
5471 */
5572class InsertionOperatorCall extends FileStreamFunctionCall {
56- InsertionOperatorCall ( ) { this .getTarget ( ) . ( Operator ) . hasQualifiedName ( "std" , "operator<<" ) }
73+ InsertionOperatorCall ( ) { this .getTarget ( ) instanceof StreamInsertionOperator }
5774
5875 override Expr getFStream ( ) {
5976 result = this .getQualifier ( )
@@ -63,7 +80,7 @@ class InsertionOperatorCall extends FileStreamFunctionCall {
6380}
6481
6582class ExtractionOperatorCall extends FileStreamFunctionCall {
66- ExtractionOperatorCall ( ) { this .getTarget ( ) . ( Operator ) . hasQualifiedName ( "std" , "operator>>" ) }
83+ ExtractionOperatorCall ( ) { this .getTarget ( ) instanceof StreamExtractionOperator }
6784
6885 override Expr getFStream ( ) {
6986 result = this .getQualifier ( )
0 commit comments