Skip to content

Commit 45fdf69

Browse files
committed
C++: add SemLocation so SemBound is copy-shareable
1 parent 623e390 commit 45fdf69

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/semantic/SemanticBound.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
private import SemanticExpr
66
private import SemanticExprSpecific::SemanticExprConfig as Specific
77
private import SemanticSSA
8-
private import semmle.code.cpp.Location // TODO: SemLocation?
8+
private import SemanticLocation // TODO: SemLocation?
99

1010
/**
1111
* A valid base for an expression bound.
@@ -15,7 +15,7 @@ private import semmle.code.cpp.Location // TODO: SemLocation?
1515
class SemBound instanceof Specific::Bound {
1616
final string toString() { result = super.toString() }
1717

18-
final Location getLocation() { result = super.getLocation() }
18+
final SemLocation getLocation() { result = super.getLocation() }
1919

2020
final SemExpr getExpr(int delta) { result = Specific::getBoundExpr(this, delta) }
2121
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
private import semmle.code.cpp.Location
2+
3+
class SemLocation instanceof Location {
4+
/**
5+
* Gets a textual representation of this element.
6+
*
7+
* The format is "file://filePath:startLine:startColumn:endLine:endColumn".
8+
*/
9+
string toString() {
10+
result = super.toString()
11+
}
12+
/**
13+
* Holds if this element is at the specified location.
14+
* The location spans column `startcolumn` of line `startline` to
15+
* column `endcolumn` of line `endline` in file `filepath`.
16+
* For more information, see
17+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
18+
*/
19+
predicate hasLocationInfo(
20+
string filepath, int startline, int startcolumn, int endline, int endcolumn
21+
) {
22+
super.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
23+
}
24+
}

cpp/ql/lib/experimental/semmle/code/cpp/semantic/analysis/RangeAnalysisImpl.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ private import experimental.semmle.code.cpp.semantic.analysis.FloatDelta
44
private import RangeUtils
55
private import experimental.semmle.code.cpp.semantic.SemanticBound as SemanticBound
66
private import semmle.code.cpp.ir.IR as IR
7-
private import semmle.code.cpp.Location // TODO: SemLocation?
7+
private import experimental.semmle.code.cpp.semantic.SemanticLocation
88

99
module ConstantBounds implements BoundSig<FloatDelta> {
1010
class SemBound instanceof SemanticBound::SemBound {
@@ -16,7 +16,7 @@ module ConstantBounds implements BoundSig<FloatDelta> {
1616

1717
string toString() { result = super.toString() }
1818

19-
Location getLocation() { result = super.getLocation() }
19+
SemLocation getLocation() { result = super.getLocation() }
2020

2121
SemExpr getExpr(float delta) { result = super.getExpr(delta) }
2222
}
@@ -36,7 +36,7 @@ private module RelativeBounds implements BoundSig<FloatDelta> {
3636

3737
string toString() { result = super.toString() }
3838

39-
Location getLocation() { result = super.getLocation() }
39+
SemLocation getLocation() { result = super.getLocation() }
4040

4141
SemExpr getExpr(float delta) { result = super.getExpr(delta) }
4242
}

cpp/ql/lib/experimental/semmle/code/cpp/semantic/analysis/RangeAnalysisStage.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import experimental.semmle.code.cpp.semantic.SemanticCFG
7373
import experimental.semmle.code.cpp.semantic.SemanticType
7474
import experimental.semmle.code.cpp.semantic.SemanticOpcode
7575
private import ConstantAnalysis
76-
private import semmle.code.cpp.Location
76+
import experimental.semmle.code.cpp.semantic.SemanticLocation
7777

7878
/**
7979
* Holds if `typ` is a small integral type with the given lower and upper bounds.
@@ -231,7 +231,7 @@ signature module BoundSig<DeltaSig D> {
231231
class SemBound {
232232
string toString();
233233

234-
Location getLocation();
234+
SemLocation getLocation();
235235

236236
SemExpr getExpr(D::Delta delta);
237237
}

0 commit comments

Comments
 (0)