Limiting << operator to ostream, and putting this check at the same location as the check for basic_string for + operator.

This commit is contained in:
Benjamin Rodes
2024-01-04 15:25:47 -05:00
parent 8d84540a54
commit e9bb3b4b28

View File

@@ -21,16 +21,16 @@ class StringConcatenation extends Call {
or
this.getTarget() instanceof StrlcatFunction
or
// operator+ concat
// operator+ and ostream (<<) concat
exists(Call call, Operator op |
call.getTarget() = op and
op.hasQualifiedName(["std", "bsl"], "operator+") and
op.getType().(UserType).hasQualifiedName(["std", "bsl"], "basic_string") and
op.hasQualifiedName(["std", "bsl"], ["operator+", "operator<<"]) and
op.getType()
.stripType()
.(UserType)
.hasQualifiedName(["std", "bsl"], ["basic_string", "basic_ostream"]) and
this = call
)
or
// string stream concat (operator<<)
this.getTarget().hasQualifiedName(["std", "bsl"], "operator<<")
}
/**