Skip to content

Commit 646efe2

Browse files
committed
C++: Deprecate ConversionConstructor.
1 parent 61178c5 commit 646efe2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cpp/ql/src/semmle/code/cpp/MemberFunction.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ abstract class ImplicitConversionFunction extends MemberFunction {
214214
}
215215

216216
/**
217+
* DEPRECATED: as of C++11 this class does not correspond perfectly with the
218+
* language definition of a converting constructor.
219+
*
217220
* A C++ constructor that also defines an implicit conversion. For example the
218221
* function `MyClass` in the following code is a `ConversionConstructor`:
219222
* ```
@@ -225,7 +228,7 @@ abstract class ImplicitConversionFunction extends MemberFunction {
225228
* };
226229
* ```
227230
*/
228-
class ConversionConstructor extends Constructor, ImplicitConversionFunction {
231+
deprecated class ConversionConstructor extends Constructor, ImplicitConversionFunction {
229232
ConversionConstructor() {
230233
strictcount(Parameter p | p = getAParameter() and not p.hasInitializer()) = 1 and
231234
not hasSpecifier("explicit")

cpp/ql/src/semmle/code/cpp/models/implementations/MemberFunction.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ import semmle.code.cpp.models.interfaces.DataFlow
77
import semmle.code.cpp.models.interfaces.Taint
88

99
/**
10-
* Model for C++ conversion constructors.
10+
* Model for C++ conversion constructors. As of C++11 this does not correspond
11+
* perfectly with the language definition of a converting constructor, however,
12+
* it does correspond with the constructors we are confident taint should flow
13+
* through.
1114
*/
12-
class ConversionConstructorModel extends ConversionConstructor, TaintFunction {
15+
class ConversionConstructorModel extends Constructor, TaintFunction {
16+
ConversionConstructorModel()
17+
{
18+
strictcount(Parameter p | p = getAParameter() and not p.hasInitializer()) = 1 and
19+
not hasSpecifier("explicit")
20+
}
21+
1322
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
1423
// taint flow from the first constructor argument to the returned object
1524
input.isParameter(0) and

0 commit comments

Comments
 (0)