Skip to content

Commit df9533f

Browse files
authored
Merge pull request #8347 from erik-krogh/depBeGone
remove all deprecations that are over a year old
2 parents d316ad1 + 9466043 commit df9533f

File tree

138 files changed

+189
-3932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+189
-3932
lines changed

config/blame-deprecations.mjs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import fs from "fs";
2+
import path from "path";
3+
import cp from "child_process";
4+
function* walk(dir) {
5+
for (const file of fs.readdirSync(dir)) {
6+
const filePath = path.join(dir, file);
7+
if (fs.statSync(filePath).isDirectory()) {
8+
yield* walk(filePath);
9+
} else {
10+
yield filePath;
11+
}
12+
}
13+
}
14+
15+
function* deprecatedFiles(dir) {
16+
for (const file of walk(dir)) {
17+
if (file.endsWith(".ql") || file.endsWith(".qll")) {
18+
const contents = fs.readFileSync(file, "utf8");
19+
if (/\sdeprecated\s/.test(contents)) {
20+
yield file;
21+
}
22+
}
23+
}
24+
}
25+
26+
const blameRegExp =
27+
/^(\^?\w+)\s.+\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (?:\+|-)\d{4})\s+(\d+)\).*$/;
28+
29+
function* deprecationMessages(dir) {
30+
for (const file of deprecatedFiles(dir)) {
31+
const blame = cp.execFileSync("git", ["blame", "--", file]);
32+
const lines = blame.toString().split("\n");
33+
for (let i = 0; i < lines.length; i++) {
34+
const line = lines[i];
35+
if (line.includes(" deprecated ")) {
36+
try {
37+
const [_, sha, time, lineNumber] = line.match(blameRegExp);
38+
const date = new Date(time);
39+
// check if it's within the last 14 months (a year, plus 2 months for safety, in case a PR was delayed)
40+
if (date.getTime() >= Date.now() - 14 * 31 * 24 * 60 * 60 * 1000) {
41+
continue;
42+
}
43+
const message = `${file}:${lineNumber} was last updated on ${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
44+
yield [message, date];
45+
} catch (e) {
46+
console.log(e);
47+
console.log("----");
48+
console.log(line);
49+
console.log("----");
50+
process.exit(0);
51+
}
52+
}
53+
}
54+
}
55+
}
56+
[...deprecationMessages(".")]
57+
.sort((a, b) => a[1].getTime() - b[1].getTime())
58+
.forEach((msg) => console.log(msg[0]));
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* All deprecated predicates/classes/modules that have been deprecated for over a year have been deleted.

cpp/ql/lib/cpp.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,4 @@ import semmle.code.cpp.Comments
6969
import semmle.code.cpp.Preprocessor
7070
import semmle.code.cpp.Iteration
7171
import semmle.code.cpp.NameQualifiers
72-
import semmle.code.cpp.ObjectiveC
73-
import semmle.code.cpp.exprs.ObjectiveC
7472
import DefaultOptions

cpp/ql/lib/semmle/code/cpp/Class.qll

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,6 @@ class Class extends UserType {
111111
result = this.getCanonicalMember(index).(TemplateVariable).getAnInstantiation()
112112
}
113113

114-
/**
115-
* DEPRECATED: Use `getCanonicalMember(int)` or `getAMember(int)` instead.
116-
* Gets the `index`th member of this class.
117-
*/
118-
deprecated Declaration getMember(int index) {
119-
member(underlyingElement(this), index, unresolveElement(result))
120-
}
121-
122-
/**
123-
* DEPRECATED: As this includes a somewhat arbitrary number of
124-
* template instantiations, it is unlikely to do what
125-
* you need.
126-
* Gets the number of members that this class has. This includes both
127-
* templates that are in this class, and instantiations of those
128-
* templates.
129-
*/
130-
deprecated int getNumMember() { result = count(this.getAMember()) }
131-
132114
/**
133115
* Gets a private member declared in this class, struct or union.
134116
* For template members, this may be either the template or an
@@ -208,23 +190,6 @@ class Class extends UserType {
208190
*/
209191
deprecated predicate hasCopyConstructor() { this.getAMemberFunction() instanceof CopyConstructor }
210192

211-
/**
212-
* Holds if this class has a copy assignment operator that is either
213-
* explicitly declared (though possibly `= delete`) or is auto-generated,
214-
* non-trivial and called from somewhere.
215-
*
216-
* DEPRECATED: There is more than one reasonable definition of what it means
217-
* to have a copy assignment operator, and we do not want to promote one
218-
* particular definition by naming it with this predicate. Having a copy
219-
* assignment operator could mean that such a member is declared or defined
220-
* in the source or that it is callable by a particular caller. For C++11,
221-
* there's also a question of whether to include members that are defaulted
222-
* or deleted.
223-
*/
224-
deprecated predicate hasCopyAssignmentOperator() {
225-
this.getAMemberFunction() instanceof CopyAssignmentOperator
226-
}
227-
228193
/**
229194
* Like accessOfBaseMember but returns multiple results if there are multiple
230195
* paths to `base` through the inheritance graph.
@@ -1070,31 +1035,6 @@ class PartialClassTemplateSpecialization extends ClassTemplateSpecialization {
10701035
override string getAPrimaryQlClass() { result = "PartialClassTemplateSpecialization" }
10711036
}
10721037

1073-
/**
1074-
* An "interface" is a class that only contains pure virtual functions (and contains
1075-
* at least one such function). For example:
1076-
* ```
1077-
* class MyInterfaceClass {
1078-
* public:
1079-
* virtual void myMethod1() = 0;
1080-
* virtual void myMethod2() = 0;
1081-
* };
1082-
* ```
1083-
*
1084-
* DEPRECATED: This class is considered to be too specific for general usage.
1085-
*/
1086-
deprecated class Interface extends Class {
1087-
Interface() {
1088-
forex(Declaration m |
1089-
m.getDeclaringType() = this.getABaseClass*() and not compgenerated(unresolveElement(m))
1090-
|
1091-
m instanceof PureVirtualFunction
1092-
)
1093-
}
1094-
1095-
override string getAPrimaryQlClass() { result = "Interface" }
1096-
}
1097-
10981038
/**
10991039
* A class/struct derivation that is virtual. For example the derivation in
11001040
* the following code is a `VirtualClassDerivation`:

cpp/ql/lib/semmle/code/cpp/Element.qll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ class ElementBase extends @element {
5555
cached
5656
string toString() { none() }
5757

58-
/** DEPRECATED: use `getAPrimaryQlClass` instead. */
59-
deprecated string getCanonicalQLClass() { result = this.getAPrimaryQlClass() }
60-
6158
/**
6259
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
6360
*/
@@ -91,13 +88,6 @@ class Element extends ElementBase {
9188
*/
9289
predicate fromSource() { this.getFile().fromSource() }
9390

94-
/**
95-
* Holds if this element may be from a library.
96-
*
97-
* DEPRECATED: always true.
98-
*/
99-
deprecated predicate fromLibrary() { this.getFile().fromLibrary() }
100-
10191
/** Gets the primary location of this element. */
10292
Location getLocation() { none() }
10393

cpp/ql/lib/semmle/code/cpp/File.qll

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -196,31 +196,11 @@ class Folder extends Container, @folder {
196196
*/
197197
deprecated string getName() { folders(underlyingElement(this), result) }
198198

199-
/**
200-
* DEPRECATED: use `getAbsolutePath` instead.
201-
* Holds if this element is named `name`.
202-
*/
203-
deprecated predicate hasName(string name) { name = this.getName() }
204-
205-
/**
206-
* DEPRECATED: use `getAbsolutePath` instead.
207-
* Gets the full name of this folder.
208-
*/
209-
deprecated string getFullName() { result = this.getName() }
210-
211199
/**
212200
* DEPRECATED: use `getBaseName` instead.
213201
* Gets the last part of the folder name.
214202
*/
215203
deprecated string getShortName() { result = this.getBaseName() }
216-
217-
/**
218-
* DEPRECATED: use `getParentContainer` instead.
219-
* Gets the parent folder.
220-
*/
221-
deprecated Folder getParent() {
222-
containerparent(unresolveElement(result), underlyingElement(this))
223-
}
224204
}
225205

226206
/**
@@ -308,13 +288,6 @@ class File extends Container, @file {
308288
*/
309289
override predicate fromSource() { numlines(underlyingElement(this), _, _, _) }
310290

311-
/**
312-
* Holds if this file may be from a library.
313-
*
314-
* DEPRECATED: For historical reasons this is true for any file.
315-
*/
316-
deprecated override predicate fromLibrary() { any() }
317-
318291
/** Gets the metric file. */
319292
MetricFile getMetrics() { result = this }
320293

@@ -428,25 +401,3 @@ class CppFile extends File {
428401

429402
override string getAPrimaryQlClass() { result = "CppFile" }
430403
}
431-
432-
/**
433-
* DEPRECATED: Objective-C is no longer supported.
434-
* An Objective C source file, as determined by file extension.
435-
*
436-
* For the related notion of whether a file is compiled as Objective C
437-
* code, use `File.compiledAsObjC`.
438-
*/
439-
deprecated class ObjCFile extends File {
440-
ObjCFile() { none() }
441-
}
442-
443-
/**
444-
* DEPRECATED: Objective-C is no longer supported.
445-
* An Objective C++ source file, as determined by file extension.
446-
*
447-
* For the related notion of whether a file is compiled as Objective C++
448-
* code, use `File.compiledAsObjCpp`.
449-
*/
450-
deprecated class ObjCppFile extends File {
451-
ObjCppFile() { none() }
452-
}

cpp/ql/lib/semmle/code/cpp/Location.qll

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,6 @@ class Location extends @location {
105105
}
106106
}
107107

108-
/**
109-
* DEPRECATED: Use `Location` instead.
110-
* A location of an element. Not used for expressions or statements, which
111-
* instead use LocationExpr and LocationStmt respectively.
112-
*/
113-
deprecated library class LocationDefault extends Location, @location_default { }
114-
115-
/**
116-
* DEPRECATED: Use `Location` instead.
117-
* A location of a statement.
118-
*/
119-
deprecated library class LocationStmt extends Location, @location_stmt { }
120-
121-
/**
122-
* DEPRECATED: Use `Location` instead.
123-
* A location of an expression.
124-
*/
125-
deprecated library class LocationExpr extends Location, @location_expr { }
126-
127108
/**
128109
* Gets the length of the longest line in file `f`.
129110
*/

cpp/ql/lib/semmle/code/cpp/Macro.qll

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ class Macro extends PreprocessorDirective, @ppd_define {
3030
else result = "#define " + this.getHead() + " " + this.getBody()
3131
}
3232

33-
/**
34-
* Holds if the body of the macro starts with an unmatched closing
35-
* parenthesis. For example:
36-
*
37-
* #define RPAREN() )
38-
*
39-
* DEPRECATED: This predicate has a misleading name.
40-
*/
41-
deprecated predicate isFunctionLike() { this.getBody().regexpMatch("[^(]*\\).*") }
42-
4333
/**
4434
* Gets the name of the macro. For example, `MAX` in
4535
* `#define MAX(x,y) (((x)>(y))?(x):(y))`.
@@ -261,46 +251,6 @@ class MacroInvocation extends MacroAccess {
261251
string getExpandedArgument(int i) { macro_argument_expanded(underlyingElement(this), i, result) }
262252
}
263253

264-
/**
265-
* A top-level expression generated by a macro invocation.
266-
*
267-
* DEPRECATED: Use `MacroInvocation.getExpr()` directly to get an
268-
* expression generated at the top-level of a macro invocation. Use
269-
* `MacroInvocation.getAnAffectedElement()` to get any element generated
270-
* by a macro invocation.
271-
*/
272-
deprecated class MacroInvocationExpr extends Expr {
273-
MacroInvocationExpr() { exists(MacroInvocation i | this = i.getExpr()) }
274-
275-
/**
276-
* Gets the macro invocation of which this is the top-level expression.
277-
*/
278-
MacroInvocation getInvocation() { result.getExpr() = this }
279-
280-
/** Gets the name of the invoked macro. */
281-
string getMacroName() { result = this.getInvocation().getMacroName() }
282-
}
283-
284-
/**
285-
* A top-level statement generated by a macro invocation.
286-
*
287-
* DEPRECATED: Use `MacroInvocation.getStmt()` directly to get a
288-
* statement generated at the top-level of a macro invocation. Use
289-
* `MacroInvocation.getAnAffectedElement()` to get any element generated
290-
* by a macro invocation.
291-
*/
292-
deprecated class MacroInvocationStmt extends Stmt {
293-
MacroInvocationStmt() { exists(MacroInvocation i | this = i.getStmt()) }
294-
295-
/**
296-
* Gets the macro invocation of which this is the top-level statement.
297-
*/
298-
MacroInvocation getInvocation() { result.getStmt() = this }
299-
300-
/** Gets the name of the invoked macro. */
301-
string getMacroName() { result = this.getInvocation().getMacroName() }
302-
}
303-
304254
/** Holds if `l` is the location of a macro. */
305255
predicate macroLocation(Location l) { macrolocationbind(_, l) }
306256

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -233,40 +233,6 @@ class ImplicitConversionFunction extends MemberFunction {
233233
Type getDestType() { none() } // overridden in subclasses
234234
}
235235

236-
/**
237-
* DEPRECATED: as of C++11 this class does not correspond perfectly with the
238-
* language definition of a converting constructor.
239-
*
240-
* A C++ constructor that also defines an implicit conversion. For example the
241-
* function `MyClass` in the following code is a `ConversionConstructor`:
242-
* ```
243-
* class MyClass {
244-
* public:
245-
* MyClass(const MyOtherClass &from) {
246-
* ...
247-
* }
248-
* };
249-
* ```
250-
*/
251-
deprecated class ConversionConstructor extends Constructor, ImplicitConversionFunction {
252-
ConversionConstructor() {
253-
strictcount(Parameter p | p = this.getAParameter() and not p.hasInitializer()) = 1 and
254-
not this.hasSpecifier("explicit")
255-
}
256-
257-
override string getAPrimaryQlClass() {
258-
not this instanceof CopyConstructor and
259-
not this instanceof MoveConstructor and
260-
result = "ConversionConstructor"
261-
}
262-
263-
/** Gets the type this `ConversionConstructor` takes as input. */
264-
override Type getSourceType() { result = this.getParameter(0).getType() }
265-
266-
/** Gets the type this `ConversionConstructor` is a constructor of. */
267-
override Type getDestType() { result = this.getDeclaringType() }
268-
}
269-
270236
private predicate hasCopySignature(MemberFunction f) {
271237
f.getParameter(0).getUnspecifiedType().(LValueReferenceType).getBaseType() = f.getDeclaringType()
272238
}

0 commit comments

Comments
 (0)