Skip to content

Commit 3832d4c

Browse files
author
Dave Bartolomeo
committed
C++: Mark deprecated overrides as deprecated
The QL compiler is about to be changed to emit a warning when overriding a deprecated predicate. This PR marks the existing overrides of deprecated predicates as `deprecated` themselves, which avoids the warning. The `Print.qll` models seem to preserve the `isWideCharDefault()` predicate for backwards compatibility, so we can't remove them and must continue overriding them. The `XML.qll` override is necessary because both superclasses declare the `getName()` predicate. One is `deprecated`, and the other is `abstract`, so we have to have an override.
1 parent 0a8b3ad commit 3832d4c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class XMLFile extends XMLParent, File {
119119
override string toString() { result = XMLParent.super.toString() }
120120

121121
/** Gets the name of this XML file. */
122-
override string getName() { result = File.super.getAbsolutePath() }
122+
deprecated override string getName() { result = File.super.getAbsolutePath() }
123123

124124
/**
125125
* DEPRECATED: Use `getAbsolutePath()` instead.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Printf extends FormattingFunction, AliasFunction {
1919

2020
override int getFormatParameterIndex() { result = 0 }
2121

22-
override predicate isWideCharDefault() {
22+
deprecated override predicate isWideCharDefault() {
2323
hasGlobalOrStdName("wprintf") or
2424
hasGlobalName("wprintf_s")
2525
}
@@ -47,7 +47,7 @@ class Fprintf extends FormattingFunction {
4747

4848
override int getFormatParameterIndex() { result = 1 }
4949

50-
override predicate isWideCharDefault() { hasGlobalOrStdName("fwprintf") }
50+
deprecated override predicate isWideCharDefault() { hasGlobalOrStdName("fwprintf") }
5151

5252
override int getOutputParameterIndex() { result = 0 }
5353
}
@@ -70,7 +70,7 @@ class Sprintf extends FormattingFunction {
7070
not exists(getDefinition().getFile().getRelativePath())
7171
}
7272

73-
override predicate isWideCharDefault() {
73+
deprecated override predicate isWideCharDefault() {
7474
getParameter(getFormatParameterIndex())
7575
.getType()
7676
.getUnspecifiedType()
@@ -136,7 +136,7 @@ class Snprintf extends FormattingFunction {
136136
else result = getFirstFormatArgumentIndex() - 1
137137
}
138138

139-
override predicate isWideCharDefault() {
139+
deprecated override predicate isWideCharDefault() {
140140
getParameter(getFormatParameterIndex())
141141
.getType()
142142
.getUnspecifiedType()
@@ -201,7 +201,7 @@ class StringCchPrintf extends FormattingFunction {
201201
if getName().matches("%Ex") then result = 5 else result = 2
202202
}
203203

204-
override predicate isWideCharDefault() {
204+
deprecated override predicate isWideCharDefault() {
205205
getParameter(getFormatParameterIndex())
206206
.getType()
207207
.getUnspecifiedType()

0 commit comments

Comments
 (0)