Skip to content

Commit f00a9ac

Browse files
authored
Merge pull request #10112 from jketema/orphaned
C++: Handle orphaned local variables
2 parents f3ef851 + 2adf566 commit f00a9ac

File tree

16 files changed

+8843
-189
lines changed

16 files changed

+8843
-189
lines changed

cpp/downgrades/f96ad9b2da43bbc9e55a72a165febd270ae07981/old.dbscheme

Lines changed: 2136 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/f96ad9b2da43bbc9e55a72a165febd270ae07981/semmlecode.cpp.dbscheme

Lines changed: 2131 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: Add relation for orphaned local variables
2+
compatibility: full
3+
orphaned_variables.rel: delete

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ class LocalVariable extends LocalScopeVariable, @localvariable {
398398
exists(DeclStmt s | s.getADeclaration() = this and s.getEnclosingFunction() = result)
399399
or
400400
exists(ConditionDeclExpr e | e.getVariable() = this and e.getEnclosingFunction() = result)
401+
or
402+
orphaned_variables(underlyingElement(this), unresolveElement(result))
401403
}
402404
}
403405

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ autoderivation(
523523
int derivation_type: @type ref
524524
);
525525

526+
orphaned_variables(
527+
int var: @localvariable ref,
528+
int function: @function ref
529+
)
530+
526531
enumconstants(
527532
unique int id: @enumconstant,
528533
int parent: @usertype ref,

0 commit comments

Comments
 (0)