GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C++: fix implicit this · github/codeql@fe89174

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cpp/ql
    • lib
      • external
        • ExternalArtifact.qll
      • semmle/code/cpp
        • Class.qll
        • Declaration.qll
        • Element.qll
        • Enum.qll
        • File.qll
        • Function.qll
        • Include.qll
        • Initializer.qll
        • Location.qll
        • Macro.qll
        • MemberFunction.qll
        • Namespace.qll
        • Parameter.qll
        • Preprocessor.qll
        • Print.qll
        • Specifier.qll
        • Struct.qll
        • TestFile.qll
        • Type.qll
        • TypedefType.qll
        • Union.qll
        • UserType.qll
        • Variable.qll
        • commons
          • CommonType.qll
          • Dependency.qll
          • Printf.qll
          • Scanf.qll
          • Synchronization.qll
        • controlflow
          • BasicBlocks.qll
          • ControlFlowGraph.qll
          • IRGuards.qll
          • LocalScopeVariableReachability.qll
          • SSA.qll
          • StackVariableReachability.qll
          • SubBasicBlocks.qll
          • internal
            • ConstantExprs.qll
        • dataflow/internal
          • DataFlowImpl.qll
          • DataFlowImpl2.qll
          • DataFlowImpl3.qll
          • DataFlowImpl4.qll
          • DataFlowImplLocal.qll
          • DataFlowUtil.qll
          • FlowVar.qll
          • SubBasicBlocks.qll
        • exprs
          • Access.qll
          • ArithmeticOperation.qll
          • BuiltInOperations.qll
          • Call.qll
          • Cast.qll
          • Expr.qll
          • Lambda.qll
          • Literal.qll
        • internal
          • QualifiedName.qll
        • ir
          • dataflow/internal
            • DataFlowImpl.qll
            • DataFlowImpl2.qll
            • DataFlowImpl3.qll
            • DataFlowImpl4.qll
            • DataFlowUtil.qll
          • implementation/raw/internal
            • TranslatedExpr.qll
        • metrics
          • MetricClass.qll
          • MetricFile.qll
          • MetricFunction.qll
        • models
          • implementations
            • Allocation.qll
            • GetDelim.qll
            • Gets.qll
            • Memcpy.qll
            • Memset.qll
            • Pure.qll
            • SmartPointer.qll
            • Sscanf.qll
            • StdContainer.qll
            • StdMap.qll
            • StdPair.qll
            • StdSet.qll
            • StdString.qll
            • Strcat.qll
            • Strcpy.qll
            • Strcrement.qll
            • Swap.qll
          • interfaces
            • FunctionInputsAndOutputs.qll
        • padding
          • Padding.qll
        • rangeanalysis
          • RangeSSA.qll
          • SimpleRangeAnalysis.qll
        • security
          • BufferWrite.qll
          • FileWrite.qll
          • FlowSources.qll
          • FunctionWithWrappers.qll
          • Security.qll
          • SensitiveExprs.qll
          • boostorg/asio
            • protocols.qll
        • stmts
          • Block.qll
          • Stmt.qll
    • src
      • Architecture/Refactoring Opportunities
        • ClassesWithManyFields.ql
      • JPL_C/LOC-2/Rule 09
        • Semaphores.qll
      • external
        • CodeDuplication.qll
        • MetricFilter.qll

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cpp/ql/lib/external/ExternalArtifact.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/external/ExternalArtifact.qll
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExternalData extends @externalDataElement {
1515
* Gets the path of the file this data was loaded from, with its
1616
* extension replaced by `.ql`.
1717
*/
18-
string getQueryPath() { result = getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
18+
string getQueryPath() { result = this.getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
1919

2020
/** Gets the number of fields in this data item. */
2121
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
@@ -24,22 +24,22 @@ class ExternalData extends @externalDataElement {
2424
string getField(int i) { externalData(this, _, i, result) }
2525

2626
/** Gets the integer value of the `i`th field of this data item. */
27-
int getFieldAsInt(int i) { result = getField(i).toInt() }
27+
int getFieldAsInt(int i) { result = this.getField(i).toInt() }
2828

2929
/** Gets the floating-point value of the `i`th field of this data item. */
30-
float getFieldAsFloat(int i) { result = getField(i).toFloat() }
30+
float getFieldAsFloat(int i) { result = this.getField(i).toFloat() }
3131

3232
/** Gets the value of the `i`th field of this data item, interpreted as a date. */
33-
date getFieldAsDate(int i) { result = getField(i).toDate() }
33+
date getFieldAsDate(int i) { result = this.getField(i).toDate() }
3434

3535
/** Gets a textual representation of this data item. */
36-
string toString() { result = getQueryPath() + ": " + buildTupleString(0) }
36+
string toString() { result = this.getQueryPath() + ": " + this.buildTupleString(0) }
3737

3838
/** Gets a textual representation of this data item, starting with the `n`th field. */
3939
private string buildTupleString(int n) {
40-
n = getNumFields() - 1 and result = getField(n)
40+
n = this.getNumFields() - 1 and result = this.getField(n)
4141
or
42-
n < getNumFields() - 1 and result = getField(n) + "," + buildTupleString(n + 1)
42+
n < this.getNumFields() - 1 and result = this.getField(n) + "," + this.buildTupleString(n + 1)
4343
}
4444
}
4545

@@ -53,8 +53,8 @@ class DefectExternalData extends ExternalData {
5353
}
5454

5555
/** Gets the URL associated with this data item. */
56-
string getURL() { result = getField(0) }
56+
string getURL() { result = this.getField(0) }
5757

5858
/** Gets the message associated with this data item. */
59-
string getMessage() { result = getField(1) }
59+
string getMessage() { result = this.getField(1) }
6060
}
Collapse file

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

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Class.qll
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ class Class extends UserType {
269269
* DEPRECATED: name changed to `hasImplicitCopyConstructor` to reflect that
270270
* `= default` members are no longer included.
271271
*/
272-
deprecated predicate hasGeneratedCopyConstructor() { hasImplicitCopyConstructor() }
272+
deprecated predicate hasGeneratedCopyConstructor() { this.hasImplicitCopyConstructor() }
273273

274274
/**
275275
* DEPRECATED: name changed to `hasImplicitCopyAssignmentOperator` to
276276
* reflect that `= default` members are no longer included.
277277
*/
278-
deprecated predicate hasGeneratedCopyAssignmentOperator() { hasImplicitCopyConstructor() }
278+
deprecated predicate hasGeneratedCopyAssignmentOperator() { this.hasImplicitCopyConstructor() }
279279

280280
/**
281281
* Holds if this class, struct or union has an implicitly-declared copy
@@ -487,7 +487,7 @@ class Class extends UserType {
487487
exists(ClassDerivation cd |
488488
// Add the offset of the direct base class and the offset of `baseClass`
489489
// within that direct base class.
490-
cd = getADerivation() and
490+
cd = this.getADerivation() and
491491
result = cd.getBaseClass().getANonVirtualBaseClassByteOffset(baseClass) + cd.getByteOffset()
492492
)
493493
}
@@ -502,12 +502,12 @@ class Class extends UserType {
502502
*/
503503
int getABaseClassByteOffset(Class baseClass) {
504504
// Handle the non-virtual case.
505-
result = getANonVirtualBaseClassByteOffset(baseClass)
505+
result = this.getANonVirtualBaseClassByteOffset(baseClass)
506506
or
507507
exists(Class virtualBaseClass, int virtualBaseOffset, int offsetFromVirtualBase |
508508
// Look for the base class as a non-virtual base of a direct or indirect
509509
// virtual base, adding the two offsets.
510-
getVirtualBaseClassByteOffset(virtualBaseClass) = virtualBaseOffset and
510+
this.getVirtualBaseClassByteOffset(virtualBaseClass) = virtualBaseOffset and
511511
offsetFromVirtualBase = virtualBaseClass.getANonVirtualBaseClassByteOffset(baseClass) and
512512
result = virtualBaseOffset + offsetFromVirtualBase
513513
)
@@ -623,11 +623,11 @@ class Class extends UserType {
623623
* inherits one).
624624
*/
625625
predicate isPolymorphic() {
626-
exists(MemberFunction f | f.getDeclaringType() = getABaseClass*() and f.isVirtual())
626+
exists(MemberFunction f | f.getDeclaringType() = this.getABaseClass*() and f.isVirtual())
627627
}
628628

629629
override predicate involvesTemplateParameter() {
630-
getATemplateArgument().(Type).involvesTemplateParameter()
630+
this.getATemplateArgument().(Type).involvesTemplateParameter()
631631
}
632632

633633
/** Holds if this class, struct or union was declared 'final'. */
@@ -765,7 +765,7 @@ class ClassDerivation extends Locatable, @derivation {
765765
* };
766766
* ```
767767
*/
768-
Class getBaseClass() { result = getBaseType().getUnderlyingType() }
768+
Class getBaseClass() { result = this.getBaseType().getUnderlyingType() }
769769

770770
override string getAPrimaryQlClass() { result = "ClassDerivation" }
771771

@@ -818,7 +818,7 @@ class ClassDerivation extends Locatable, @derivation {
818818
predicate hasSpecifier(string s) { this.getASpecifier().hasName(s) }
819819

820820
/** Holds if the derivation is for a virtual base class. */
821-
predicate isVirtual() { hasSpecifier("virtual") }
821+
predicate isVirtual() { this.hasSpecifier("virtual") }
822822

823823
/** Gets the location of the derivation. */
824824
override Location getLocation() { derivations(underlyingElement(this), _, _, _, result) }
@@ -846,7 +846,7 @@ class ClassDerivation extends Locatable, @derivation {
846846
* ```
847847
*/
848848
class LocalClass extends Class {
849-
LocalClass() { isLocal() }
849+
LocalClass() { this.isLocal() }
850850

851851
override string getAPrimaryQlClass() { not this instanceof LocalStruct and result = "LocalClass" }
852852

@@ -989,9 +989,9 @@ class ClassTemplateSpecialization extends Class {
989989
TemplateClass getPrimaryTemplate() {
990990
// Ignoring template arguments, the primary template has the same name
991991
// as each of its specializations.
992-
result.getSimpleName() = getSimpleName() and
992+
result.getSimpleName() = this.getSimpleName() and
993993
// It is in the same namespace as its specializations.
994-
result.getNamespace() = getNamespace() and
994+
result.getNamespace() = this.getNamespace() and
995995
// It is distinguished by the fact that each of its template arguments
996996
// is a distinct template parameter.
997997
count(TemplateParameter tp | tp = result.getATemplateArgument()) =
@@ -1108,7 +1108,7 @@ deprecated class Interface extends Class {
11081108
* ```
11091109
*/
11101110
class VirtualClassDerivation extends ClassDerivation {
1111-
VirtualClassDerivation() { hasSpecifier("virtual") }
1111+
VirtualClassDerivation() { this.hasSpecifier("virtual") }
11121112

11131113
override string getAPrimaryQlClass() { result = "VirtualClassDerivation" }
11141114
}
@@ -1136,7 +1136,7 @@ class VirtualBaseClass extends Class {
11361136
VirtualClassDerivation getAVirtualDerivation() { result.getBaseClass() = this }
11371137

11381138
/** A class/struct that is derived from this one using virtual inheritance. */
1139-
Class getAVirtuallyDerivedClass() { result = getAVirtualDerivation().getDerivedClass() }
1139+
Class getAVirtuallyDerivedClass() { result = this.getAVirtualDerivation().getDerivedClass() }
11401140
}
11411141

11421142
/**
@@ -1155,7 +1155,7 @@ class ProxyClass extends UserType {
11551155
override string getAPrimaryQlClass() { result = "ProxyClass" }
11561156

11571157
/** Gets the location of the proxy class. */
1158-
override Location getLocation() { result = getTemplateParameter().getDefinitionLocation() }
1158+
override Location getLocation() { result = this.getTemplateParameter().getDefinitionLocation() }
11591159

11601160
/** Gets the template parameter for which this is the proxy class. */
11611161
TemplateParameter getTemplateParameter() {
Collapse file

‎cpp/ql/lib/semmle/code/cpp/Declaration.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Declaration.qll
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class Declaration extends Locatable, @declaration {
184184
predicate hasDefinition() { exists(this.getDefinition()) }
185185

186186
/** DEPRECATED: Use `hasDefinition` instead. */
187-
predicate isDefined() { hasDefinition() }
187+
predicate isDefined() { this.hasDefinition() }
188188

189189
/** Gets the preferred location of this declaration, if any. */
190190
override Location getLocation() { none() }
@@ -209,7 +209,7 @@ class Declaration extends Locatable, @declaration {
209209
predicate isStatic() { this.hasSpecifier("static") }
210210

211211
/** Holds if this declaration is a member of a class/struct/union. */
212-
predicate isMember() { hasDeclaringType() }
212+
predicate isMember() { this.hasDeclaringType() }
213213

214214
/** Holds if this declaration is a member of a class/struct/union. */
215215
predicate hasDeclaringType() { exists(this.getDeclaringType()) }
@@ -226,14 +226,14 @@ class Declaration extends Locatable, @declaration {
226226
* When called on a template, this will return a template parameter type for
227227
* both typed and non-typed parameters.
228228
*/
229-
final Locatable getATemplateArgument() { result = getTemplateArgument(_) }
229+
final Locatable getATemplateArgument() { result = this.getTemplateArgument(_) }
230230

231231
/**
232232
* Gets a template argument used to instantiate this declaration from a template.
233233
* When called on a template, this will return a non-typed template
234234
* parameter value.
235235
*/
236-
final Locatable getATemplateArgumentKind() { result = getTemplateArgumentKind(_) }
236+
final Locatable getATemplateArgumentKind() { result = this.getTemplateArgumentKind(_) }
237237

238238
/**
239239
* Gets the `i`th template argument used to instantiate this declaration from a
@@ -252,9 +252,9 @@ class Declaration extends Locatable, @declaration {
252252
* `getTemplateArgument(1)` return `1`.
253253
*/
254254
final Locatable getTemplateArgument(int index) {
255-
if exists(getTemplateArgumentValue(index))
256-
then result = getTemplateArgumentValue(index)
257-
else result = getTemplateArgumentType(index)
255+
if exists(this.getTemplateArgumentValue(index))
256+
then result = this.getTemplateArgumentValue(index)
257+
else result = this.getTemplateArgumentType(index)
258258
}
259259

260260
/**
@@ -275,13 +275,13 @@ class Declaration extends Locatable, @declaration {
275275
* `getTemplateArgumentKind(0)`.
276276
*/
277277
final Locatable getTemplateArgumentKind(int index) {
278-
exists(getTemplateArgumentValue(index)) and
279-
result = getTemplateArgumentType(index)
278+
exists(this.getTemplateArgumentValue(index)) and
279+
result = this.getTemplateArgumentType(index)
280280
}
281281

282282
/** Gets the number of template arguments for this declaration. */
283283
final int getNumberOfTemplateArguments() {
284-
result = count(int i | exists(getTemplateArgument(i)))
284+
result = count(int i | exists(this.getTemplateArgument(i)))
285285
}
286286

287287
private Type getTemplateArgumentType(int index) {
@@ -327,9 +327,9 @@ class DeclarationEntry extends Locatable, TDeclarationEntry {
327327
* available), or the name declared by this entry otherwise.
328328
*/
329329
string getCanonicalName() {
330-
if getDeclaration().hasDefinition()
331-
then result = getDeclaration().getDefinition().getName()
332-
else result = getName()
330+
if this.getDeclaration().hasDefinition()
331+
then result = this.getDeclaration().getDefinition().getName()
332+
else result = this.getName()
333333
}
334334

335335
/**
@@ -370,18 +370,18 @@ class DeclarationEntry extends Locatable, TDeclarationEntry {
370370
/**
371371
* Holds if this declaration entry has a specifier with the given name.
372372
*/
373-
predicate hasSpecifier(string specifier) { getASpecifier() = specifier }
373+
predicate hasSpecifier(string specifier) { this.getASpecifier() = specifier }
374374

375375
/** Holds if this declaration entry is a definition. */
376376
predicate isDefinition() { none() } // overridden in subclasses
377377

378378
override string toString() {
379-
if isDefinition()
380-
then result = "definition of " + getName()
379+
if this.isDefinition()
380+
then result = "definition of " + this.getName()
381381
else
382-
if getName() = getCanonicalName()
383-
then result = "declaration of " + getName()
384-
else result = "declaration of " + getCanonicalName() + " as " + getName()
382+
if this.getName() = this.getCanonicalName()
383+
then result = "declaration of " + this.getName()
384+
else result = "declaration of " + this.getCanonicalName() + " as " + this.getName()
385385
}
386386
}
387387

@@ -580,7 +580,7 @@ private class DirectAccessHolder extends Element {
580580
// transitive closure with a restricted base case.
581581
this.thisCanAccessClassStep(base, derived)
582582
or
583-
exists(Class between | thisCanAccessClassTrans(base, between) |
583+
exists(Class between | this.thisCanAccessClassTrans(base, between) |
584584
isDirectPublicBaseOf(between, derived) or
585585
this.thisCanAccessClassStep(between, derived)
586586
)
Collapse file

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

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Element.qll
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ElementBase extends @element {
6161
/**
6262
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
6363
*/
64-
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
64+
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
6565

6666
/**
6767
* Gets the name of a primary CodeQL class to which this element belongs.
@@ -206,9 +206,9 @@ class Element extends ElementBase {
206206
/** Gets the closest `Element` enclosing this one. */
207207
cached
208208
Element getEnclosingElement() {
209-
result = getEnclosingElementPref()
209+
result = this.getEnclosingElementPref()
210210
or
211-
not exists(getEnclosingElementPref()) and
211+
not exists(this.getEnclosingElementPref()) and
212212
(
213213
this = result.(Class).getAMember()
214214
or
@@ -281,7 +281,7 @@ private predicate isFromUninstantiatedTemplateRec(Element e, Element template) {
281281
* ```
282282
*/
283283
class StaticAssert extends Locatable, @static_assert {
284-
override string toString() { result = "static_assert(..., \"" + getMessage() + "\")" }
284+
override string toString() { result = "static_assert(..., \"" + this.getMessage() + "\")" }
285285

286286
/**
287287
* Gets the expression which this static assertion ensures is true.
Collapse file

‎cpp/ql/lib/semmle/code/cpp/Enum.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Enum.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Enum extends UserType, IntegralOrEnumType {
8585
* ```
8686
*/
8787
class LocalEnum extends Enum {
88-
LocalEnum() { isLocal() }
88+
LocalEnum() { this.isLocal() }
8989

9090
override string getAPrimaryQlClass() { result = "LocalEnum" }
9191
}
Collapse file

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

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/File.qll
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Container extends Locatable, @container {
5252
*/
5353
string getRelativePath() {
5454
exists(string absPath, string pref |
55-
absPath = getAbsolutePath() and sourceLocationPrefix(pref)
55+
absPath = this.getAbsolutePath() and sourceLocationPrefix(pref)
5656
|
5757
absPath = pref and result = ""
5858
or
@@ -79,7 +79,7 @@ class Container extends Locatable, @container {
7979
* </table>
8080
*/
8181
string getBaseName() {
82-
result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
82+
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
8383
}
8484

8585
/**
@@ -105,7 +105,9 @@ class Container extends Locatable, @container {
105105
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
106106
* </table>
107107
*/
108-
string getExtension() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3) }
108+
string getExtension() {
109+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3)
110+
}
109111

110112
/**
111113
* Gets the stem of this container, that is, the prefix of its base name up to
@@ -124,7 +126,9 @@ class Container extends Locatable, @container {
124126
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
125127
* </table>
126128
*/
127-
string getStem() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1) }
129+
string getStem() {
130+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1)
131+
}
128132

129133
/** Gets the parent container of this file or folder, if any. */
130134
Container getParentContainer() {
@@ -135,20 +139,20 @@ class Container extends Locatable, @container {
135139
Container getAChildContainer() { this = result.getParentContainer() }
136140

137141
/** Gets a file in this container. */
138-
File getAFile() { result = getAChildContainer() }
142+
File getAFile() { result = this.getAChildContainer() }
139143

140144
/** Gets the file in this container that has the given `baseName`, if any. */
141145
File getFile(string baseName) {
142-
result = getAFile() and
146+
result = this.getAFile() and
143147
result.getBaseName() = baseName
144148
}
145149

146150
/** Gets a sub-folder in this container. */
147-
Folder getAFolder() { result = getAChildContainer() }
151+
Folder getAFolder() { result = this.getAChildContainer() }
148152

149153
/** Gets the sub-folder in this container that has the given `baseName`, if any. */
150154
Folder getFolder(string baseName) {
151-
result = getAFolder() and
155+
result = this.getAFolder() and
152156
result.getBaseName() = baseName
153157
}
154158

@@ -157,7 +161,7 @@ class Container extends Locatable, @container {
157161
*
158162
* This is the absolute path of the container.
159163
*/
160-
override string toString() { result = getAbsolutePath() }
164+
override string toString() { result = this.getAbsolutePath() }
161165
}
162166

163167
/**

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.