Skip to content

Commit 7723324

Browse files
authored
Merge pull request #21896 from jketema/jketema/deprecated
C++: Remove deprecated code
2 parents 42c4d8a + e66b1e4 commit 7723324

8 files changed

Lines changed: 17 additions & 164 deletions

File tree

cpp/ql/lib/DefaultOptions.qll

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class Options extends string {
3030
predicate overrideReturnsNull(Call call) {
3131
// Used in CVS:
3232
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup")
33-
or
34-
CustomOptions::overrideReturnsNull(call) // old Options.qll
3533
}
3634

3735
/**
@@ -45,8 +43,6 @@ class Options extends string {
4543
// Used in CVS:
4644
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup") and
4745
nullValue(call.getArgument(0))
48-
or
49-
CustomOptions::returnsNull(call) // old Options.qll
5046
}
5147

5248
/**
@@ -65,8 +61,6 @@ class Options extends string {
6561
f.hasGlobalOrStdName([
6662
"exit", "_exit", "_Exit", "abort", "__assert_fail", "longjmp", "__builtin_unreachable"
6763
])
68-
or
69-
CustomOptions::exits(f) // old Options.qll
7064
}
7165

7266
/**
@@ -79,19 +73,15 @@ class Options extends string {
7973
* runtime, the program's behavior is undefined)
8074
*/
8175
predicate exprExits(Expr e) {
82-
e.(AssumeExpr).getChild(0).(CompileTimeConstantInt).getIntValue() = 0 or
83-
CustomOptions::exprExits(e) // old Options.qll
76+
e.(AssumeExpr).getChild(0).(CompileTimeConstantInt).getIntValue() = 0
8477
}
8578

8679
/**
8780
* Holds if function `f` should always have its return value checked.
8881
*
8982
* By default holds only for `fgets`.
9083
*/
91-
predicate alwaysCheckReturnValue(Function f) {
92-
f.hasGlobalOrStdName("fgets") or
93-
CustomOptions::alwaysCheckReturnValue(f) // old Options.qll
94-
}
84+
predicate alwaysCheckReturnValue(Function f) { f.hasGlobalOrStdName("fgets") }
9585

9686
/**
9787
* Holds if it is reasonable to ignore the return value of function
@@ -107,8 +97,6 @@ class Options extends string {
10797
// common way of sleeping using select:
10898
fc.getTarget().hasGlobalName("select") and
10999
fc.getArgument(0).getValue() = "0"
110-
or
111-
CustomOptions::okToIgnoreReturnValue(fc) // old Options.qll
112100
}
113101
}
114102

cpp/ql/lib/Options.qll

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -98,57 +98,3 @@ class CustomMutexType extends MutexType {
9898
*/
9999
override predicate unlockAccess(FunctionCall fc, Expr arg) { none() }
100100
}
101-
102-
/**
103-
* DEPRECATED: customize `CustomOptions.overrideReturnsNull` instead.
104-
*
105-
* This predicate is required to support backwards compatibility for
106-
* older `Options.qll` files. It should not be removed or modified by
107-
* end users.
108-
*/
109-
predicate overrideReturnsNull(Call call) { none() }
110-
111-
/**
112-
* DEPRECATED: customize `CustomOptions.returnsNull` instead.
113-
*
114-
* This predicate is required to support backwards compatibility for
115-
* older `Options.qll` files. It should not be removed or modified by
116-
* end users.
117-
*/
118-
predicate returnsNull(Call call) { none() }
119-
120-
/**
121-
* DEPRECATED: customize `CustomOptions.exits` instead.
122-
*
123-
* This predicate is required to support backwards compatibility for
124-
* older `Options.qll` files. It should not be removed or modified by
125-
* end users.
126-
*/
127-
predicate exits(Function f) { none() }
128-
129-
/**
130-
* DEPRECATED: customize `CustomOptions.exprExits` instead.
131-
*
132-
* This predicate is required to support backwards compatibility for
133-
* older `Options.qll` files. It should not be removed or modified by
134-
* end users.
135-
*/
136-
predicate exprExits(Expr e) { none() }
137-
138-
/**
139-
* DEPRECATED: customize `CustomOptions.alwaysCheckReturnValue` instead.
140-
*
141-
* This predicate is required to support backwards compatibility for
142-
* older `Options.qll` files. It should not be removed or modified by
143-
* end users.
144-
*/
145-
predicate alwaysCheckReturnValue(Function f) { none() }
146-
147-
/**
148-
* DEPRECATED: customize `CustomOptions.okToIgnoreReturnValue` instead.
149-
*
150-
* This predicate is required to support backwards compatibility for
151-
* older `Options.qll` files. It should not be removed or modified by
152-
* end users.
153-
*/
154-
predicate okToIgnoreReturnValue(FunctionCall fc) { none() }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
category: breaking
3+
---
4+
* Removed the deprecated `overrideReturnsNull` predicate from `Options.qll`. Use `CustomOptions.overrideReturnsNull` instead.
5+
* Removed the deprecated `returnsNull` predicate from `Options.qll`. Use `CustomOptions.returnsNull` instead.
6+
* Removed the deprecated `exits` predicate from `Options.qll`. Use `CustomOptions.exits` instead.
7+
* Removed the deprecated `exprExits` predicate from `Options.qll`. Use `CustomOptions.exprExits` instead.
8+
* Removed the deprecated `alwaysCheckReturnValue` predicate from `Options.qll`. Use `CustomOptions.alwaysCheckReturnValue` instead.
9+
* Removed the deprecated `okToIgnoreReturnValue` predicate from `Options.qll`. Use `CustomOptions.okToIgnoreReturnValue` instead.
10+
* Removed the deprecated `semmle.code.cpp.Member`. Import `semmle.code.cpp.Element` and/or `semmle.code.cpp.Type` directly.
11+
* Removed the deprecated `UnknownDefaultLocation` class. Use `UnknownLocation` instead.
12+
* Removed the deprecated `UnknownExprLocation` class. Use `UnknownLocation` instead.
13+
* Removed the deprecated `UnknownStmtLocation` class. Use `UnknownLocation` instead.
14+
* Removed the deprecated `TemplateParameter` class. Use `TypeTemplateParameter` instead.
15+
* Support for class resolution across link targets has been removed for databases which were created with CodeQL versions before 1.23.0.

cpp/ql/lib/cpp.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import semmle.code.cpp.Class
3232
import semmle.code.cpp.Struct
3333
import semmle.code.cpp.Union
3434
import semmle.code.cpp.Enum
35-
import semmle.code.cpp.Member
3635
import semmle.code.cpp.Field
3736
import semmle.code.cpp.Function
3837
import semmle.code.cpp.MemberFunction

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,3 @@ class UnknownLocation extends Location {
148148
this.getFile().getAbsolutePath() = "" and locations_default(this, _, 0, 0, 0, 0)
149149
}
150150
}
151-
152-
/**
153-
* A dummy location which is used when something doesn't have a location in
154-
* the source code but needs to have a `Location` associated with it.
155-
*
156-
* DEPRECATED: use `UnknownLocation`
157-
*/
158-
deprecated class UnknownDefaultLocation extends UnknownLocation { }
159-
160-
/**
161-
* A dummy location which is used when an expression doesn't have a
162-
* location in the source code but needs to have a `Location` associated
163-
* with it.
164-
*
165-
* DEPRECATED: use `UnknownLocation`
166-
*/
167-
deprecated class UnknownExprLocation extends UnknownLocation { }
168-
169-
/**
170-
* A dummy location which is used when a statement doesn't have a location
171-
* in the source code but needs to have a `Location` associated with it.
172-
*
173-
* DEPRECATED: use `UnknownLocation`
174-
*/
175-
deprecated class UnknownStmtLocation extends UnknownLocation { }

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ class NonTypeTemplateParameter extends Literal, TemplateParameterImpl {
3535
override string getAPrimaryQlClass() { result = "NonTypeTemplateParameter" }
3636
}
3737

38-
/**
39-
* A C++ `typename` (or `class`) template parameter.
40-
*
41-
* DEPRECATED: Use `TypeTemplateParameter` instead.
42-
*/
43-
deprecated class TemplateParameter = TypeTemplateParameter;
44-
4538
/**
4639
* A C++ `typename` (or `class`) template parameter.
4740
*

cpp/ql/lib/semmle/code/cpp/internal/ResolveClass.qll

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,5 @@
11
import semmle.code.cpp.Type
22

3-
/** For upgraded databases without mangled name info. */
4-
pragma[noinline]
5-
private string getTopLevelClassName(@usertype c) {
6-
not mangled_name(_, _, _) and
7-
isClass(c) and
8-
usertypes(c, result, _) and
9-
not namespacembrs(_, c) and // not in a namespace
10-
not member(_, _, c) and // not in some structure
11-
not class_instantiation(c, _) // not a template instantiation
12-
}
13-
14-
/**
15-
* For upgraded databases without mangled name info.
16-
* Holds if `d` is a unique complete class named `name`.
17-
*/
18-
pragma[noinline]
19-
private predicate existsCompleteWithName(string name, @usertype d) {
20-
not mangled_name(_, _, _) and
21-
is_complete(d) and
22-
name = getTopLevelClassName(d) and
23-
onlyOneCompleteClassExistsWithName(name)
24-
}
25-
26-
/** For upgraded databases without mangled name info. */
27-
pragma[noinline]
28-
private predicate onlyOneCompleteClassExistsWithName(string name) {
29-
not mangled_name(_, _, _) and
30-
strictcount(@usertype c | is_complete(c) and getTopLevelClassName(c) = name) = 1
31-
}
32-
33-
/**
34-
* For upgraded databases without mangled name info.
35-
* Holds if `c` is an incomplete class named `name`.
36-
*/
37-
pragma[noinline]
38-
private predicate existsIncompleteWithName(string name, @usertype c) {
39-
not mangled_name(_, _, _) and
40-
not is_complete(c) and
41-
name = getTopLevelClassName(c)
42-
}
43-
44-
/**
45-
* For upgraded databases without mangled name info.
46-
* Holds if `c` is an incomplete class, and there exists a unique complete class `d`
47-
* with the same name.
48-
*/
49-
private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
50-
not mangled_name(_, _, _) and
51-
exists(string name |
52-
existsIncompleteWithName(name, c) and
53-
existsCompleteWithName(name, d)
54-
)
55-
}
56-
573
pragma[noinline]
584
private @mangledname getClassMangledName(@usertype c) {
595
isClass(c) and
@@ -103,10 +49,7 @@ private module Cached {
10349
@usertype resolveClass(@usertype c) {
10450
hasCompleteTwin(c, result)
10551
or
106-
oldHasCompleteTwin(c, result)
107-
or
10852
not hasCompleteTwin(c, _) and
109-
not oldHasCompleteTwin(c, _) and
11053
result = c
11154
}
11255

0 commit comments

Comments
 (0)