Skip to content

Commit e9bb3b4

Browse files
committed
Limiting << operator to ostream, and putting this check at the same location as the check for basic_string for + operator.
1 parent 8d84540 commit e9bb3b4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cpp/ql/lib/semmle/code/cpp/commons/StringConcatenation.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ class StringConcatenation extends Call {
2121
or
2222
this.getTarget() instanceof StrlcatFunction
2323
or
24-
// operator+ concat
24+
// operator+ and ostream (<<) concat
2525
exists(Call call, Operator op |
2626
call.getTarget() = op and
27-
op.hasQualifiedName(["std", "bsl"], "operator+") and
28-
op.getType().(UserType).hasQualifiedName(["std", "bsl"], "basic_string") and
27+
op.hasQualifiedName(["std", "bsl"], ["operator+", "operator<<"]) and
28+
op.getType()
29+
.stripType()
30+
.(UserType)
31+
.hasQualifiedName(["std", "bsl"], ["basic_string", "basic_ostream"]) and
2932
this = call
3033
)
31-
or
32-
// string stream concat (operator<<)
33-
this.getTarget().hasQualifiedName(["std", "bsl"], "operator<<")
3434
}
3535

3636
/**

0 commit comments

Comments
 (0)