forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++: Move SsaConsistency to its own file
This removes the import of the `Print` library in places that are used in production and not just debugging.
- Loading branch information
Showing
37 changed files
with
235 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: breaking | ||
--- | ||
* The internal `SsaConsistency` module has been moved from `SSAConstruction` to `SSAConsitency`, and the deprecated `SSAConsistency` module has been removed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRConsistencyImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintIRImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import semmle.code.cpp.ir.IRConfiguration as IRConfiguration | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
57 changes: 55 additions & 2 deletions
57
cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
private import SSAConstruction as Ssa | ||
import Ssa::SsaConsistency | ||
import SsaConsistency | ||
import SSAConsistencyImports | ||
|
||
module SsaConsistency { | ||
/** | ||
* Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis. | ||
*/ | ||
query predicate multipleOperandMemoryLocations( | ||
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
exists(int locationCount | | ||
locationCount = strictcount(Alias::getOperandMemoryLocation(operand)) and | ||
locationCount > 1 and | ||
func = operand.getEnclosingIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = | ||
operand.getUse().toString() + " " + "Operand has " + locationCount.toString() + | ||
" memory accesses in function '$@': " + | ||
strictconcat(Alias::getOperandMemoryLocation(operand).toString(), ", ") | ||
) | ||
} | ||
|
||
/** | ||
* Holds if a `MemoryLocation` does not have an associated `VirtualVariable`. | ||
*/ | ||
query predicate missingVirtualVariableForMemoryLocation( | ||
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
not exists(location.getVirtualVariable()) and | ||
func = location.getIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = "Memory location has no virtual variable in function '$@'." | ||
} | ||
|
||
/** | ||
* Holds if a `MemoryLocation` is a member of more than one `VirtualVariable`. | ||
*/ | ||
query predicate multipleVirtualVariablesForMemoryLocation( | ||
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
exists(int vvarCount | | ||
vvarCount = strictcount(location.getVirtualVariable()) and | ||
vvarCount > 1 and | ||
func = location.getIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = | ||
"Memory location has " + vvarCount.toString() + " virtual variables in function '$@': (" + | ||
concat(Alias::VirtualVariable vvar | | ||
vvar = location.getVirtualVariable() | ||
| | ||
vvar.toString(), ", " | ||
) + ")." | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistencyImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import semmle.code.cpp.ir.implementation.raw.IR as OldIR | ||
import AliasedSSA as Alias | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConsistencyImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/PrintIRImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import semmle.code.cpp.ir.IRConfiguration as IRConfiguration | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRConsistencyImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
1 change: 1 addition & 0 deletions
1
cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintIRImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import semmle.code.cpp.ir.IRConfiguration as IRConfiguration | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
57 changes: 55 additions & 2 deletions
57
cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
private import SSAConstruction as Ssa | ||
import Ssa::SsaConsistency | ||
import SsaConsistency | ||
import SSAConsistencyImports | ||
|
||
module SsaConsistency { | ||
/** | ||
* Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis. | ||
*/ | ||
query predicate multipleOperandMemoryLocations( | ||
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
exists(int locationCount | | ||
locationCount = strictcount(Alias::getOperandMemoryLocation(operand)) and | ||
locationCount > 1 and | ||
func = operand.getEnclosingIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = | ||
operand.getUse().toString() + " " + "Operand has " + locationCount.toString() + | ||
" memory accesses in function '$@': " + | ||
strictconcat(Alias::getOperandMemoryLocation(operand).toString(), ", ") | ||
) | ||
} | ||
|
||
/** | ||
* Holds if a `MemoryLocation` does not have an associated `VirtualVariable`. | ||
*/ | ||
query predicate missingVirtualVariableForMemoryLocation( | ||
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
not exists(location.getVirtualVariable()) and | ||
func = location.getIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = "Memory location has no virtual variable in function '$@'." | ||
} | ||
|
||
/** | ||
* Holds if a `MemoryLocation` is a member of more than one `VirtualVariable`. | ||
*/ | ||
query predicate multipleVirtualVariablesForMemoryLocation( | ||
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText | ||
) { | ||
exists(int vvarCount | | ||
vvarCount = strictcount(location.getVirtualVariable()) and | ||
vvarCount > 1 and | ||
func = location.getIRFunction() and | ||
funcText = LanguageDebug::getIdentityString(func.getFunction()) and | ||
message = | ||
"Memory location has " + vvarCount.toString() + " virtual variables in function '$@': (" + | ||
concat(Alias::VirtualVariable vvar | | ||
vvar = location.getVirtualVariable() | ||
| | ||
vvar.toString(), ", " | ||
) + ")." | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistencyImports.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import semmle.code.cpp.ir.implementation.raw.IR as OldIR | ||
import SimpleSSA as Alias | ||
import semmle.code.cpp.ir.internal.IRCppLanguageDebug as LanguageDebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.