mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Merge pull request #8323 from erik-krogh/acronyms
Enforcing consistent casing of acronyms
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
category: deprecated
|
||||
---
|
||||
* Many classes/predicates/modules that had upper-case acronyms have been renamed to follow our style-guide.
|
||||
The old name still exists as a deprecated alias.
|
||||
@@ -7,67 +7,88 @@ import csharp
|
||||
/**
|
||||
* A `Web.config` file.
|
||||
*/
|
||||
class WebConfigXML extends XMLFile {
|
||||
WebConfigXML() { this.getName().matches("%Web.config") }
|
||||
class WebConfigXml extends XMLFile {
|
||||
WebConfigXml() { this.getName().matches("%Web.config") }
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for WebConfigXml */
|
||||
deprecated class WebConfigXML = WebConfigXml;
|
||||
|
||||
/** A `<configuration>` tag in an ASP.NET configuration file. */
|
||||
class ConfigurationXMLElement extends XMLElement {
|
||||
ConfigurationXMLElement() { this.getName().toLowerCase() = "configuration" }
|
||||
class ConfigurationXmlElement extends XMLElement {
|
||||
ConfigurationXmlElement() { this.getName().toLowerCase() = "configuration" }
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for ConfigurationXmlElement */
|
||||
deprecated class ConfigurationXMLElement = ConfigurationXmlElement;
|
||||
|
||||
/** A `<location>` tag in an ASP.NET configuration file. */
|
||||
class LocationXMLElement extends XMLElement {
|
||||
LocationXMLElement() {
|
||||
this.getParent() instanceof ConfigurationXMLElement and
|
||||
class LocationXmlElement extends XMLElement {
|
||||
LocationXmlElement() {
|
||||
this.getParent() instanceof ConfigurationXmlElement and
|
||||
this.getName().toLowerCase() = "location"
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for LocationXmlElement */
|
||||
deprecated class LocationXMLElement = LocationXmlElement;
|
||||
|
||||
/** A `<system.web>` tag in an ASP.NET configuration file. */
|
||||
class SystemWebXMLElement extends XMLElement {
|
||||
SystemWebXMLElement() {
|
||||
class SystemWebXmlElement extends XMLElement {
|
||||
SystemWebXmlElement() {
|
||||
(
|
||||
this.getParent() instanceof ConfigurationXMLElement
|
||||
this.getParent() instanceof ConfigurationXmlElement
|
||||
or
|
||||
this.getParent() instanceof LocationXMLElement
|
||||
this.getParent() instanceof LocationXmlElement
|
||||
) and
|
||||
this.getName().toLowerCase() = "system.web"
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for SystemWebXmlElement */
|
||||
deprecated class SystemWebXMLElement = SystemWebXmlElement;
|
||||
|
||||
/** A `<system.webServer>` tag in an ASP.NET configuration file. */
|
||||
class SystemWebServerXMLElement extends XMLElement {
|
||||
SystemWebServerXMLElement() {
|
||||
class SystemWebServerXmlElement extends XMLElement {
|
||||
SystemWebServerXmlElement() {
|
||||
(
|
||||
this.getParent() instanceof ConfigurationXMLElement
|
||||
this.getParent() instanceof ConfigurationXmlElement
|
||||
or
|
||||
this.getParent() instanceof LocationXMLElement
|
||||
this.getParent() instanceof LocationXmlElement
|
||||
) and
|
||||
this.getName().toLowerCase() = "system.webserver"
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for SystemWebServerXmlElement */
|
||||
deprecated class SystemWebServerXMLElement = SystemWebServerXmlElement;
|
||||
|
||||
/** A `<customErrors>` tag in an ASP.NET configuration file. */
|
||||
class CustomErrorsXMLElement extends XMLElement {
|
||||
CustomErrorsXMLElement() {
|
||||
this.getParent() instanceof SystemWebXMLElement and
|
||||
class CustomErrorsXmlElement extends XMLElement {
|
||||
CustomErrorsXmlElement() {
|
||||
this.getParent() instanceof SystemWebXmlElement and
|
||||
this.getName().toLowerCase() = "customerrors"
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for CustomErrorsXmlElement */
|
||||
deprecated class CustomErrorsXMLElement = CustomErrorsXmlElement;
|
||||
|
||||
/** A `<httpRuntime>` tag in an ASP.NET configuration file. */
|
||||
class HttpRuntimeXMLElement extends XMLElement {
|
||||
HttpRuntimeXMLElement() {
|
||||
this.getParent() instanceof SystemWebXMLElement and
|
||||
class HttpRuntimeXmlElement extends XMLElement {
|
||||
HttpRuntimeXmlElement() {
|
||||
this.getParent() instanceof SystemWebXmlElement and
|
||||
this.getName().toLowerCase() = "httpruntime"
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for HttpRuntimeXmlElement */
|
||||
deprecated class HttpRuntimeXMLElement = HttpRuntimeXmlElement;
|
||||
|
||||
/** A `<forms>` tag under `<system.web><authentication>` in an ASP.NET configuration file. */
|
||||
class FormsElement extends XMLElement {
|
||||
FormsElement() {
|
||||
this = any(SystemWebXMLElement sw).getAChild("authentication").getAChild("forms")
|
||||
this = any(SystemWebXmlElement sw).getAChild("authentication").getAChild("forms")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +106,7 @@ class FormsElement extends XMLElement {
|
||||
|
||||
/** A `<httpCookies>` tag in an ASP.NET configuration file. */
|
||||
class HttpCookiesElement extends XMLElement {
|
||||
HttpCookiesElement() { this = any(SystemWebXMLElement sw).getAChild("httpCookies") }
|
||||
HttpCookiesElement() { this = any(SystemWebXmlElement sw).getAChild("httpCookies") }
|
||||
|
||||
/**
|
||||
* Gets attribute's `httpOnlyCookies` value.
|
||||
|
||||
@@ -11,7 +11,7 @@ import Location
|
||||
/**
|
||||
* A single line of comment.
|
||||
*
|
||||
* Either a single line comment (`SinglelineComment`), an XML comment (`XmlComment`),
|
||||
* Either a single line comment (`SinglelineComment`), an XML comment (`XmlCommentLine`),
|
||||
* or a line in a multi-line comment (`MultilineComment`).
|
||||
*/
|
||||
class CommentLine extends @commentline {
|
||||
@@ -66,7 +66,7 @@ class MultilineComment extends CommentLine, @multilinecomment {
|
||||
* /// </summary>
|
||||
* ```
|
||||
*/
|
||||
class XmlComment extends CommentLine, @xmldoccomment {
|
||||
class XmlCommentLine extends CommentLine, @xmldoccomment {
|
||||
override string toString() { result = "/// ..." }
|
||||
|
||||
private string xmlAttributeRegex() {
|
||||
@@ -196,7 +196,7 @@ class CommentBlock extends @commentblock {
|
||||
|
||||
/** Holds if this block consists entirely of XML comments. */
|
||||
predicate isXmlCommentBlock() {
|
||||
forall(CommentLine l | l = getAChild() | l instanceof XmlComment)
|
||||
forall(CommentLine l | l = getAChild() | l instanceof XmlCommentLine)
|
||||
}
|
||||
|
||||
/** Gets a `CommentLine` containing text. */
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
import semmle.files.FileSystem
|
||||
|
||||
private class TXMLLocatable =
|
||||
private class TXmlLocatable =
|
||||
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
|
||||
|
||||
/** An XML element that has a location. */
|
||||
class XMLLocatable extends @xmllocatable, TXMLLocatable {
|
||||
class XMLLocatable extends @xmllocatable, TXmlLocatable {
|
||||
/** Gets the source location for this element. */
|
||||
Location getLocation() { xmllocations(this, result) }
|
||||
|
||||
|
||||
@@ -1000,7 +1000,7 @@ module Internal {
|
||||
// The predicates in this module should be evaluated in the same stage as the CFG
|
||||
// construction stage. This is to avoid recomputation of pre-basic-blocks and
|
||||
// pre-SSA predicates
|
||||
private module PreCFG {
|
||||
private module PreCfg {
|
||||
private import semmle.code.csharp.controlflow.internal.PreBasicBlocks as PreBasicBlocks
|
||||
private import semmle.code.csharp.controlflow.internal.PreSsa
|
||||
|
||||
@@ -1414,7 +1414,7 @@ module Internal {
|
||||
}
|
||||
|
||||
cached
|
||||
private module CachedWithCFG {
|
||||
private module CachedWithCfg {
|
||||
private import semmle.code.csharp.Caching
|
||||
|
||||
cached
|
||||
@@ -1719,10 +1719,10 @@ module Internal {
|
||||
}
|
||||
}
|
||||
|
||||
import CachedWithCFG
|
||||
import CachedWithCfg
|
||||
}
|
||||
|
||||
import PreCFG
|
||||
import PreCfg
|
||||
|
||||
private predicate interestingDescendantCandidate(Expr e) {
|
||||
guardControls(e, _, _)
|
||||
|
||||
@@ -12,15 +12,18 @@ private import semmle.code.csharp.dataflow.FlowSummary
|
||||
/**
|
||||
* A callable that is considered a "safe" external API from a security perspective.
|
||||
*/
|
||||
abstract class SafeExternalAPICallable extends Callable { }
|
||||
abstract class SafeExternalApiCallable extends Callable { }
|
||||
|
||||
private class SummarizedCallableSafe extends SafeExternalAPICallable {
|
||||
/** DEPRECATED: Alias for SafeExternalApiCallable */
|
||||
deprecated class SafeExternalAPICallable = SafeExternalApiCallable;
|
||||
|
||||
private class SummarizedCallableSafe extends SafeExternalApiCallable {
|
||||
SummarizedCallableSafe() { this instanceof SummarizedCallable }
|
||||
}
|
||||
|
||||
/** The default set of "safe" external APIs. */
|
||||
private class DefaultSafeExternalAPICallable extends SafeExternalAPICallable {
|
||||
DefaultSafeExternalAPICallable() {
|
||||
private class DefaultSafeExternalApiCallable extends SafeExternalApiCallable {
|
||||
DefaultSafeExternalApiCallable() {
|
||||
this instanceof EqualsMethod or
|
||||
this instanceof IEquatableEqualsMethod or
|
||||
this = any(SystemObjectClass s).getEqualsMethod() or
|
||||
@@ -36,11 +39,11 @@ private class DefaultSafeExternalAPICallable extends SafeExternalAPICallable {
|
||||
}
|
||||
|
||||
/** A node representing data being passed to an external API. */
|
||||
class ExternalAPIDataNode extends DataFlow::Node {
|
||||
class ExternalApiDataNode extends DataFlow::Node {
|
||||
Call call;
|
||||
int i;
|
||||
|
||||
ExternalAPIDataNode() {
|
||||
ExternalApiDataNode() {
|
||||
(
|
||||
// Argument to call
|
||||
this.asExpr() = call.getArgument(i)
|
||||
@@ -59,7 +62,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
|
||||
m.fromSource()
|
||||
) and
|
||||
// Not a call to a known safe external API
|
||||
not call.getTarget().getUnboundDeclaration() instanceof SafeExternalAPICallable
|
||||
not call.getTarget().getUnboundDeclaration() instanceof SafeExternalApiCallable
|
||||
}
|
||||
|
||||
/** Gets the called API callable. */
|
||||
@@ -72,38 +75,47 @@ class ExternalAPIDataNode extends DataFlow::Node {
|
||||
string getCallableDescription() { result = this.getCallable().getQualifiedName() }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */
|
||||
class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration {
|
||||
UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfig" }
|
||||
/** DEPRECATED: Alias for ExternalApiDataNode */
|
||||
deprecated class ExternalAPIDataNode = ExternalApiDataNode;
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration {
|
||||
UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode }
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
|
||||
}
|
||||
|
||||
/** A node representing untrusted data being passed to an external API. */
|
||||
class UntrustedExternalAPIDataNode extends ExternalAPIDataNode {
|
||||
private UntrustedDataToExternalAPIConfig c;
|
||||
/** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */
|
||||
deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig;
|
||||
|
||||
UntrustedExternalAPIDataNode() { c.hasFlow(_, this) }
|
||||
/** A node representing untrusted data being passed to an external API. */
|
||||
class UntrustedExternalApiDataNode extends ExternalApiDataNode {
|
||||
private UntrustedDataToExternalApiConfig c;
|
||||
|
||||
UntrustedExternalApiDataNode() { c.hasFlow(_, this) }
|
||||
|
||||
/** Gets a source of untrusted data which is passed to this external API data node. */
|
||||
DataFlow::Node getAnUntrustedSource() { c.hasFlow(result, this) }
|
||||
}
|
||||
|
||||
private newtype TExternalAPI =
|
||||
TExternalAPIParameter(Callable m, int index) {
|
||||
exists(UntrustedExternalAPIDataNode n |
|
||||
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */
|
||||
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
|
||||
|
||||
private newtype TExternalApi =
|
||||
TExternalApiParameter(Callable m, int index) {
|
||||
exists(UntrustedExternalApiDataNode n |
|
||||
m = n.getCallable().getUnboundDeclaration() and
|
||||
index = n.getIndex()
|
||||
)
|
||||
}
|
||||
|
||||
/** An external API which is used with untrusted data. */
|
||||
class ExternalAPIUsedWithUntrustedData extends TExternalAPI {
|
||||
class ExternalApiUsedWithUntrustedData extends TExternalApi {
|
||||
/** Gets a possibly untrusted use of this external API. */
|
||||
UntrustedExternalAPIDataNode getUntrustedDataNode() {
|
||||
this = TExternalAPIParameter(result.getCallable().getUnboundDeclaration(), result.getIndex())
|
||||
UntrustedExternalApiDataNode getUntrustedDataNode() {
|
||||
this = TExternalApiParameter(result.getCallable().getUnboundDeclaration(), result.getIndex())
|
||||
}
|
||||
|
||||
/** Gets the number of untrusted sources used with this external API. */
|
||||
@@ -116,10 +128,13 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI {
|
||||
exists(Callable m, int index, string indexString |
|
||||
if index = -1 then indexString = "qualifier" else indexString = "param " + index
|
||||
|
|
||||
this = TExternalAPIParameter(m, index) and
|
||||
this = TExternalApiParameter(m, index) and
|
||||
result =
|
||||
m.getDeclaringType().getQualifiedName() + "." + m.toStringWithTypes() + " [" + indexString +
|
||||
"]"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */
|
||||
deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData;
|
||||
|
||||
@@ -117,12 +117,15 @@ class SearchRequestFilterSink extends Sink {
|
||||
*
|
||||
* This will match the encoding methods provided by the AntiXSS library.
|
||||
*/
|
||||
class LDAPEncodeSanitizer extends Sanitizer {
|
||||
LDAPEncodeSanitizer() {
|
||||
class LdapEncodeSanitizer extends Sanitizer {
|
||||
LdapEncodeSanitizer() {
|
||||
this.getExpr().(MethodCall).getTarget().getName().regexpMatch("(?i)LDAP.*Encode.*")
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for LdapEncodeSanitizer */
|
||||
deprecated class LDAPEncodeSanitizer = LdapEncodeSanitizer;
|
||||
|
||||
private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { }
|
||||
|
||||
private class GuidSanitizer extends Sanitizer, GuidSanitizedExpr { }
|
||||
|
||||
@@ -28,10 +28,10 @@ abstract class Sink extends DataFlow::ExprNode {
|
||||
abstract string getReason();
|
||||
}
|
||||
|
||||
private class InsecureXMLSink extends Sink {
|
||||
private class InsecureXmlSink extends Sink {
|
||||
private string reason;
|
||||
|
||||
InsecureXMLSink() {
|
||||
InsecureXmlSink() {
|
||||
exists(InsecureXML::InsecureXmlProcessing r | r.isUnsafe(reason) |
|
||||
this.getExpr() = r.getAnArgument()
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ class SourceMethodOrConstructor extends SourceDeclaration, Callable {
|
||||
}
|
||||
|
||||
/** Gets an XML comment bound to this declaration. */
|
||||
XmlComment getADeclarationXmlComment(Declaration d) {
|
||||
XmlCommentLine getADeclarationXmlComment(Declaration d) {
|
||||
result = getADeclarationCommentBlock(d).getAChild()
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ predicate isDocumentationNeeded(Modifiable decl) {
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<returns>` tag. */
|
||||
class ReturnsXmlComment extends XmlComment {
|
||||
class ReturnsXmlComment extends XmlCommentLine {
|
||||
ReturnsXmlComment() { this.getOpenTag(_) = "returns" }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
@@ -72,7 +72,7 @@ class ReturnsXmlComment extends XmlComment {
|
||||
}
|
||||
|
||||
/** An XML comment containing an `<exception>` tag. */
|
||||
class ExceptionXmlComment extends XmlComment {
|
||||
class ExceptionXmlComment extends XmlCommentLine {
|
||||
ExceptionXmlComment() { this.getOpenTag(_) = "exception" }
|
||||
|
||||
/** Gets a `cref` attribute at offset `offset`, if any. */
|
||||
@@ -83,7 +83,7 @@ class ExceptionXmlComment extends XmlComment {
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<param>` tag. */
|
||||
class ParamXmlComment extends XmlComment {
|
||||
class ParamXmlComment extends XmlCommentLine {
|
||||
ParamXmlComment() { this.getOpenTag(_) = "param" }
|
||||
|
||||
/** Gets the name of this parameter at offset `offset`. */
|
||||
@@ -94,7 +94,7 @@ class ParamXmlComment extends XmlComment {
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<typeparam>` tag. */
|
||||
class TypeparamXmlComment extends XmlComment {
|
||||
class TypeparamXmlComment extends XmlCommentLine {
|
||||
TypeparamXmlComment() { this.getOpenTag(_) = "typeparam" }
|
||||
|
||||
/** Gets the `name` attribute of this element at offset `offset`. */
|
||||
@@ -105,7 +105,7 @@ class TypeparamXmlComment extends XmlComment {
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<summary>` tag. */
|
||||
class SummaryXmlComment extends XmlComment {
|
||||
class SummaryXmlComment extends XmlCommentLine {
|
||||
SummaryXmlComment() { this.getOpenTag(_) = "summary" }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
@@ -119,6 +119,6 @@ class SummaryXmlComment extends XmlComment {
|
||||
}
|
||||
|
||||
/** An XML comment containing an `<inheritdoc>` tag. */
|
||||
class InheritDocXmlComment extends XmlComment {
|
||||
class InheritDocXmlComment extends XmlCommentLine {
|
||||
InheritDocXmlComment() { this.getOpenTag(_) = "inheritdoc" }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import csharp
|
||||
import semmle.code.asp.WebConfig
|
||||
|
||||
from SystemWebXMLElement web, XMLAttribute debugAttribute
|
||||
from SystemWebXmlElement web, XMLAttribute debugAttribute
|
||||
where
|
||||
debugAttribute = web.getAChild("compilation").getAttribute("debug") and
|
||||
not debugAttribute.getValue().toLowerCase() = "false"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import csharp
|
||||
import semmle.code.asp.WebConfig
|
||||
|
||||
from SystemWebXMLElement web, XMLAttribute maxReqLength
|
||||
from SystemWebXmlElement web, XMLAttribute maxReqLength
|
||||
where
|
||||
maxReqLength =
|
||||
web.getAChild(any(string s | s.toLowerCase() = "httpruntime"))
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import csharp
|
||||
import semmle.code.asp.WebConfig
|
||||
|
||||
from SystemWebXMLElement web, XMLAttribute requestvalidateAttribute
|
||||
from SystemWebXmlElement web, XMLAttribute requestvalidateAttribute
|
||||
where
|
||||
requestvalidateAttribute = web.getAChild("pages").getAttribute("validateRequest") and
|
||||
requestvalidateAttribute.getValue().toLowerCase() = "false"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.ExternalAPIsQuery
|
||||
|
||||
from ExternalAPIUsedWithUntrustedData externalAPI
|
||||
select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses,
|
||||
externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by
|
||||
from ExternalApiUsedWithUntrustedData externalApi
|
||||
select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses,
|
||||
externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by
|
||||
numberOfUntrustedSources desc
|
||||
|
||||
@@ -14,8 +14,8 @@ import semmle.code.csharp.dataflow.TaintTracking
|
||||
import semmle.code.csharp.security.dataflow.ExternalAPIsQuery
|
||||
import DataFlow::PathGraph
|
||||
|
||||
from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
where config.hasFlowPath(source, sink)
|
||||
select sink, source, sink,
|
||||
"Call to " + sink.getNode().(ExternalAPIDataNode).getCallableDescription() +
|
||||
"Call to " + sink.getNode().(ExternalApiDataNode).getCallableDescription() +
|
||||
" with untrusted data from $@.", source, source.toString()
|
||||
|
||||
@@ -24,7 +24,7 @@ class Application_Error extends Method {
|
||||
}
|
||||
}
|
||||
|
||||
from CustomErrorsXMLElement customError
|
||||
from CustomErrorsXmlElement customError
|
||||
where
|
||||
// `<customErrors>` must be set to "off" to be dangerous
|
||||
customError.getAttributeValue("mode").toLowerCase() = "off" and
|
||||
|
||||
@@ -19,7 +19,7 @@ import semmle.code.csharp.frameworks.system.Web
|
||||
/**
|
||||
* Holds if the `Web.config` file `webConfig` adds an `X-Frame-Options` header.
|
||||
*/
|
||||
predicate hasWebConfigXFrameOptions(WebConfigXML webConfig) {
|
||||
predicate hasWebConfigXFrameOptions(WebConfigXml webConfig) {
|
||||
// Looking for an entry in `webConfig` that looks like this:
|
||||
// ```xml
|
||||
// <system.webServer>
|
||||
@@ -52,7 +52,7 @@ predicate hasCodeXFrameOptions() {
|
||||
)
|
||||
}
|
||||
|
||||
from WebConfigXML webConfig
|
||||
from WebConfigXml webConfig
|
||||
where
|
||||
not hasWebConfigXFrameOptions(webConfig) and
|
||||
not hasCodeXFrameOptions()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import csharp
|
||||
import semmle.code.asp.WebConfig
|
||||
|
||||
from SystemWebServerXMLElement ws, XMLAttribute a
|
||||
from SystemWebServerXmlElement ws, XMLAttribute a
|
||||
where
|
||||
ws.getAChild("directoryBrowse").getAttribute("enabled") = a and
|
||||
a.getValue() = "true"
|
||||
|
||||
@@ -27,7 +27,7 @@ where
|
||||
)
|
||||
or
|
||||
// header checking is disabled in a configuration file
|
||||
exists(HttpRuntimeXMLElement e, XMLAttribute a |
|
||||
exists(HttpRuntimeXmlElement e, XMLAttribute a |
|
||||
a = e.getAttribute("enableHeaderChecking") and
|
||||
a.getValue().toLowerCase() = "false" and
|
||||
a = l
|
||||
|
||||
@@ -19,24 +19,24 @@ newtype TInstruction =
|
||||
) {
|
||||
IRConstruction::Raw::hasInstruction(tag1, tag2)
|
||||
} or
|
||||
TUnaliasedSSAPhiInstruction(
|
||||
TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation
|
||||
TUnaliasedSsaPhiInstruction(
|
||||
TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation
|
||||
) {
|
||||
UnaliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation)
|
||||
UnaliasedSsa::SSA::hasPhiInstruction(blockStartInstr, memoryLocation)
|
||||
} or
|
||||
TUnaliasedSSAChiInstruction(TRawInstruction primaryInstruction) { none() } or
|
||||
TUnaliasedSSAUnreachedInstruction(IRFunctionBase irFunc) {
|
||||
UnaliasedSSA::SSA::hasUnreachedInstruction(irFunc)
|
||||
TUnaliasedSsaChiInstruction(TRawInstruction primaryInstruction) { none() } or
|
||||
TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
|
||||
UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc)
|
||||
} or
|
||||
TAliasedSSAPhiInstruction(
|
||||
TAliasedSsaPhiInstruction(
|
||||
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation
|
||||
) {
|
||||
AliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation)
|
||||
} or
|
||||
TAliasedSSAChiInstruction(TRawInstruction primaryInstruction) {
|
||||
TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) {
|
||||
AliasedSSA::SSA::hasChiInstruction(primaryInstruction)
|
||||
} or
|
||||
TAliasedSSAUnreachedInstruction(IRFunctionBase irFunc) {
|
||||
TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
|
||||
AliasedSSA::SSA::hasUnreachedInstruction(irFunc)
|
||||
}
|
||||
|
||||
@@ -46,58 +46,64 @@ newtype TInstruction =
|
||||
* These wrappers are not parameterized because it is not possible to invoke an IPA constructor via
|
||||
* a class alias.
|
||||
*/
|
||||
module UnaliasedSSAInstructions {
|
||||
class TPhiInstruction = TUnaliasedSSAPhiInstruction;
|
||||
module UnaliasedSsaInstructions {
|
||||
class TPhiInstruction = TUnaliasedSsaPhiInstruction;
|
||||
|
||||
TPhiInstruction phiInstruction(
|
||||
TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation
|
||||
TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation
|
||||
) {
|
||||
result = TUnaliasedSSAPhiInstruction(blockStartInstr, memoryLocation)
|
||||
result = TUnaliasedSsaPhiInstruction(blockStartInstr, memoryLocation)
|
||||
}
|
||||
|
||||
TRawInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) { none() }
|
||||
|
||||
class TChiInstruction = TUnaliasedSSAChiInstruction;
|
||||
class TChiInstruction = TUnaliasedSsaChiInstruction;
|
||||
|
||||
TChiInstruction chiInstruction(TRawInstruction primaryInstruction) {
|
||||
result = TUnaliasedSSAChiInstruction(primaryInstruction)
|
||||
result = TUnaliasedSsaChiInstruction(primaryInstruction)
|
||||
}
|
||||
|
||||
class TUnreachedInstruction = TUnaliasedSSAUnreachedInstruction;
|
||||
class TUnreachedInstruction = TUnaliasedSsaUnreachedInstruction;
|
||||
|
||||
TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) {
|
||||
result = TUnaliasedSSAUnreachedInstruction(irFunc)
|
||||
result = TUnaliasedSsaUnreachedInstruction(irFunc)
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for UnaliasedSsaInstructions */
|
||||
deprecated module UnaliasedSSAInstructions = UnaliasedSsaInstructions;
|
||||
|
||||
/**
|
||||
* Provides wrappers for the constructors of each branch of `TInstruction` that is used by the
|
||||
* aliased SSA stage.
|
||||
* These wrappers are not parameterized because it is not possible to invoke an IPA constructor via
|
||||
* a class alias.
|
||||
*/
|
||||
module AliasedSSAInstructions {
|
||||
class TPhiInstruction = TAliasedSSAPhiInstruction or TUnaliasedSSAPhiInstruction;
|
||||
module AliasedSsaInstructions {
|
||||
class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction;
|
||||
|
||||
TPhiInstruction phiInstruction(
|
||||
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation
|
||||
) {
|
||||
result = TAliasedSSAPhiInstruction(blockStartInstr, memoryLocation)
|
||||
result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation)
|
||||
}
|
||||
|
||||
TPhiInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) {
|
||||
result = TUnaliasedSSAPhiInstruction(blockStartInstr, _)
|
||||
result = TUnaliasedSsaPhiInstruction(blockStartInstr, _)
|
||||
}
|
||||
|
||||
class TChiInstruction = TAliasedSSAChiInstruction;
|
||||
class TChiInstruction = TAliasedSsaChiInstruction;
|
||||
|
||||
TChiInstruction chiInstruction(TRawInstruction primaryInstruction) {
|
||||
result = TAliasedSSAChiInstruction(primaryInstruction)
|
||||
result = TAliasedSsaChiInstruction(primaryInstruction)
|
||||
}
|
||||
|
||||
class TUnreachedInstruction = TAliasedSSAUnreachedInstruction;
|
||||
class TUnreachedInstruction = TAliasedSsaUnreachedInstruction;
|
||||
|
||||
TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) {
|
||||
result = TAliasedSSAUnreachedInstruction(irFunc)
|
||||
result = TAliasedSsaUnreachedInstruction(irFunc)
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for AliasedSsaInstructions */
|
||||
deprecated module AliasedSSAInstructions = AliasedSsaInstructions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import experimental.ir.internal.IRCSharpLanguage as Language
|
||||
import experimental.ir.implementation.raw.internal.IRConstruction as IRConstruction
|
||||
import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSSA
|
||||
import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa
|
||||
import AliasedSSAStub as AliasedSSA
|
||||
|
||||
@@ -29,7 +29,7 @@ private module Internal {
|
||||
TNoOperand() { none() } or
|
||||
// Can be "removed" later when there's unreachable code
|
||||
// These operands can be reused across all three stages. They just get different defs.
|
||||
TNonSSAMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) {
|
||||
TNonSsaMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) {
|
||||
// Has no definition in raw but will get definitions later
|
||||
useInstr.getOpcode().hasOperand(tag)
|
||||
} or
|
||||
@@ -57,13 +57,21 @@ private module Shared {
|
||||
result = Internal::TRegisterOperand(useInstr, tag, defInstr)
|
||||
}
|
||||
|
||||
class TNonSSAMemoryOperand = Internal::TNonSSAMemoryOperand;
|
||||
class TNonSsaMemoryOperand = Internal::TNonSsaMemoryOperand;
|
||||
|
||||
/** DEPRECATED: Alias for TNonSsaMemoryOperand */
|
||||
deprecated class TNonSSAMemoryOperand = TNonSsaMemoryOperand;
|
||||
|
||||
/**
|
||||
* Returns the non-Phi memory operand with the specified parameters.
|
||||
*/
|
||||
TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) {
|
||||
result = Internal::TNonSSAMemoryOperand(useInstr, tag)
|
||||
TNonSsaMemoryOperand nonSsaMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) {
|
||||
result = Internal::TNonSsaMemoryOperand(useInstr, tag)
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for nonSsaMemoryOperand */
|
||||
deprecated TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) {
|
||||
result = nonSsaMemoryOperand(useInstr, tag)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +88,7 @@ module RawOperands {
|
||||
|
||||
class TChiOperand = Internal::TNoOperand;
|
||||
|
||||
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
|
||||
class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand;
|
||||
|
||||
/**
|
||||
* Returns the Phi operand with the specified parameters.
|
||||
@@ -114,14 +122,14 @@ module RawOperands {
|
||||
* These wrappers are not parameterized because it is not possible to invoke an IPA constructor via
|
||||
* a class alias.
|
||||
*/
|
||||
module UnaliasedSSAOperands {
|
||||
module UnaliasedSsaOperands {
|
||||
import Shared
|
||||
|
||||
class TPhiOperand = Internal::TUnaliasedPhiOperand;
|
||||
|
||||
class TChiOperand = Internal::TNoOperand;
|
||||
|
||||
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
|
||||
class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand;
|
||||
|
||||
/**
|
||||
* Returns the Phi operand with the specified parameters.
|
||||
@@ -148,3 +156,6 @@ module UnaliasedSSAOperands {
|
||||
*/
|
||||
TChiOperand chiOperand(Unaliased::Instruction useInstr, ChiOperandTag tag) { none() }
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for UnaliasedSsaOperands */
|
||||
deprecated module UnaliasedSSAOperands = UnaliasedSsaOperands;
|
||||
|
||||
@@ -55,7 +55,10 @@ class IRVariable extends TIRVariable {
|
||||
* Gets the AST node that declared this variable, or that introduced this
|
||||
* variable as part of the AST-to-IR translation.
|
||||
*/
|
||||
Language::AST getAST() { none() }
|
||||
Language::AST getAst() { none() }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = getAst() }
|
||||
|
||||
/**
|
||||
* Gets an identifier string for the variable. This identifier is unique
|
||||
@@ -66,7 +69,7 @@ class IRVariable extends TIRVariable {
|
||||
/**
|
||||
* Gets the source location of this variable.
|
||||
*/
|
||||
final Language::Location getLocation() { result = getAST().getLocation() }
|
||||
final Language::Location getLocation() { result = getAst().getLocation() }
|
||||
|
||||
/**
|
||||
* Gets the IR for the function that references this variable.
|
||||
@@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable {
|
||||
|
||||
final override string toString() { result = getVariable().toString() }
|
||||
|
||||
final override Language::AST getAST() { result = var }
|
||||
final override Language::AST getAst() { result = var }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = getAst() }
|
||||
|
||||
final override string getUniqueId() {
|
||||
result = getVariable().toString() + " " + getVariable().getLocation().toString()
|
||||
@@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable {
|
||||
|
||||
final override Language::LanguageType getLanguageType() { result = type }
|
||||
|
||||
final override Language::AST getAST() { result = ast }
|
||||
final override Language::AST getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = getAst() }
|
||||
|
||||
override string toString() { result = getBaseString() + getLocationString() }
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction {
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() }
|
||||
final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() }
|
||||
|
||||
/**
|
||||
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
|
||||
@@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction {
|
||||
string getResultId() {
|
||||
this.shouldGenerateDumpStrings() and
|
||||
result =
|
||||
this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank()
|
||||
this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the AST that caused this instruction to be generated.
|
||||
*/
|
||||
final Language::AST getAST() { result = Construction::getInstructionAST(this) }
|
||||
final Language::AST getAst() { result = Construction::getInstructionAst(this) }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the location of the source code for this instruction.
|
||||
*/
|
||||
final Language::Location getLocation() { result = this.getAST().getLocation() }
|
||||
final Language::Location getLocation() { result = this.getAst().getLocation() }
|
||||
|
||||
/**
|
||||
* Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a
|
||||
@@ -459,7 +462,10 @@ class VariableInstruction extends Instruction {
|
||||
/**
|
||||
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
|
||||
*/
|
||||
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
|
||||
final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() }
|
||||
|
||||
/** DEPRECATED: Alias for getAstVariable */
|
||||
deprecated Language::Variable getASTVariable() { result = this.getAstVariable() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ private import internal.OperandInternal
|
||||
* of `TOperand` that are used in this stage.
|
||||
*/
|
||||
private class TStageOperand =
|
||||
TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand;
|
||||
TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand;
|
||||
|
||||
/**
|
||||
* A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as
|
||||
@@ -38,7 +38,7 @@ class Operand extends TStageOperand {
|
||||
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
|
||||
exists(Instruction use, Instruction def | this = registerOperand(use, _, def))
|
||||
or
|
||||
exists(Instruction use | this = nonSSAMemoryOperand(use, _))
|
||||
exists(Instruction use | this = nonSsaMemoryOperand(use, _))
|
||||
or
|
||||
exists(Instruction use, Instruction def, IRBlock predecessorBlock |
|
||||
this = phiOperand(use, def, predecessorBlock, _) or
|
||||
@@ -209,7 +209,7 @@ class Operand extends TStageOperand {
|
||||
class MemoryOperand extends Operand {
|
||||
cached
|
||||
MemoryOperand() {
|
||||
this instanceof TNonSSAMemoryOperand or
|
||||
this instanceof TNonSsaMemoryOperand or
|
||||
this instanceof TPhiOperand or
|
||||
this instanceof TChiOperand
|
||||
}
|
||||
@@ -249,7 +249,7 @@ class NonPhiOperand extends Operand {
|
||||
|
||||
NonPhiOperand() {
|
||||
this = registerOperand(useInstr, tag, _) or
|
||||
this = nonSSAMemoryOperand(useInstr, tag) or
|
||||
this = nonSsaMemoryOperand(useInstr, tag) or
|
||||
this = chiOperand(useInstr, tag)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
|
||||
cached
|
||||
NonPhiMemoryOperand() {
|
||||
this = nonSSAMemoryOperand(useInstr, tag)
|
||||
this = nonSsaMemoryOperand(useInstr, tag)
|
||||
or
|
||||
this = chiOperand(useInstr, tag)
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) {
|
||||
// count rather than strictcount to handle missing AST elements
|
||||
// separate instanceof and inline casts to avoid failed casts with a count of 0
|
||||
instr instanceof VariableAddressInstruction and
|
||||
count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1
|
||||
count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1
|
||||
or
|
||||
instr instanceof ConstantInstruction and
|
||||
count(instr.getResultIRType()) != 1
|
||||
@@ -121,7 +121,7 @@ private predicate variableAddressValueNumber(
|
||||
// The underlying AST element is used as value-numbering key instead of the
|
||||
// `IRVariable` to work around a problem where a variable or expression with
|
||||
// multiple types gives rise to multiple `IRVariable`s.
|
||||
unique( | | instr.getIRVariable().getAST()) = ast
|
||||
unique( | | instr.getIRVariable().getAst()) = ast
|
||||
}
|
||||
|
||||
private predicate initializeParameterValueNumber(
|
||||
@@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber(
|
||||
// The underlying AST element is used as value-numbering key instead of the
|
||||
// `IRVariable` to work around a problem where a variable or expression with
|
||||
// multiple types gives rise to multiple `IRVariable`s.
|
||||
instr.getIRVariable().getAST() = var
|
||||
instr.getIRVariable().getAst() = var
|
||||
}
|
||||
|
||||
private predicate constantValueNumber(
|
||||
|
||||
@@ -62,7 +62,7 @@ module Raw {
|
||||
Callable callable, Language::AST ast, TempVariableTag tag, CSharpType type
|
||||
) {
|
||||
exists(TranslatedElement element |
|
||||
element.getAST() = ast and
|
||||
element.getAst() = ast and
|
||||
callable = element.getFunction() and
|
||||
element.hasTempVariable(tag, type)
|
||||
)
|
||||
@@ -105,7 +105,7 @@ module Raw {
|
||||
tag = getInstructionTag(instruction) and
|
||||
(
|
||||
result = element.getInstructionVariable(tag) or
|
||||
result.(IRStringLiteral).getAST() = element.getInstructionStringLiteral(tag)
|
||||
result.(IRStringLiteral).getAst() = element.getInstructionStringLiteral(tag)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -357,7 +357,7 @@ private module Cached {
|
||||
exists(TranslatedElement s, GotoStmt goto |
|
||||
goto instanceof GotoStmt and
|
||||
not isStrictlyForwardGoto(goto) and
|
||||
goto = s.getAST() and
|
||||
goto = s.getAst() and
|
||||
exists(InstructionTag tag |
|
||||
result = s.getInstructionSuccessor(tag, kind) and
|
||||
instruction = s.getInstruction(tag)
|
||||
@@ -372,8 +372,14 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::AST getInstructionAST(Instruction instruction) {
|
||||
result = getInstructionTranslatedElement(instruction).getAST()
|
||||
Language::AST getInstructionAst(Instruction instruction) {
|
||||
result = getInstructionTranslatedElement(instruction).getAst()
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for getInstructionAst */
|
||||
cached
|
||||
deprecated Language::AST getInstructionAST(Instruction instruction) {
|
||||
result = getInstructionAst(instruction)
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
@@ -15,7 +15,10 @@ abstract class TranslatedCondition extends ConditionBase {
|
||||
|
||||
final override string toString() { result = expr.toString() }
|
||||
|
||||
final override Language::AST getAST() { result = expr }
|
||||
final override Language::AST getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final Expr getExpr() { result = expr }
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ private import common.TranslatedDeclarationBase
|
||||
* `entry`.
|
||||
*/
|
||||
TranslatedLocalDeclaration getTranslatedLocalDeclaration(LocalVariableDeclExpr declExpr) {
|
||||
result.getAST() = declExpr
|
||||
result.getAst() = declExpr
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,10 @@ abstract class TranslatedLocalDeclaration extends TranslatedElement, TTranslated
|
||||
|
||||
final override string toString() { result = expr.toString() }
|
||||
|
||||
final override Language::AST getAST() { result = expr }
|
||||
final override Language::AST getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ IRUserVariable getIRUserVariable(Language::Function func, Language::Variable var
|
||||
}
|
||||
|
||||
IRTempVariable getIRTempVariable(Language::AST ast, TempVariableTag tag) {
|
||||
result.getAST() = ast and
|
||||
result.getAst() = ast and
|
||||
result.getTag() = tag
|
||||
}
|
||||
|
||||
@@ -365,7 +365,10 @@ abstract class TranslatedElement extends TTranslatedElement {
|
||||
/**
|
||||
* Gets the AST node being translated.
|
||||
*/
|
||||
abstract Language::AST getAST();
|
||||
abstract Language::AST getAst();
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Get the first instruction to be executed in the evaluation of this element.
|
||||
@@ -558,7 +561,7 @@ abstract class TranslatedElement extends TTranslatedElement {
|
||||
* Gets the temporary variable generated by this element with tag `tag`.
|
||||
*/
|
||||
final IRTempVariable getTempVariable(TempVariableTag tag) {
|
||||
result.getAST() = this.getAST() and
|
||||
result.getAst() = this.getAst() and
|
||||
result.getTag() = tag and
|
||||
this.hasTempVariable(tag, _)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,10 @@ abstract class TranslatedExpr extends TranslatedExprBase {
|
||||
*/
|
||||
final Type getResultType() { result = expr.getType() }
|
||||
|
||||
final override Language::AST getAST() { result = expr }
|
||||
final override Language::AST getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override Callable getFunction() { result = expr.getEnclosingCallable() }
|
||||
|
||||
@@ -577,9 +580,9 @@ class TranslatedArrayAccess extends TranslatedNonConstantExpr {
|
||||
result = this.getInstruction(ElementsAddressTag(0))
|
||||
or
|
||||
// The successor of an offset expression is a `PointerAdd` expression.
|
||||
child = this.getOffsetOperand(child.getAST().getIndex()) and
|
||||
child.getAST().getIndex() >= 0 and
|
||||
result = this.getInstruction(PointerAddTag(child.getAST().getIndex()))
|
||||
child = this.getOffsetOperand(child.getAst().getIndex()) and
|
||||
child.getAst().getIndex() >= 0 and
|
||||
result = this.getInstruction(PointerAddTag(child.getAst().getIndex()))
|
||||
}
|
||||
|
||||
override Instruction getResult() {
|
||||
@@ -2039,7 +2042,7 @@ class TranslatedObjectCreation extends TranslatedCreation {
|
||||
// Since calls are also expressions, we can't
|
||||
// use the predicate getTranslatedExpr (since that would
|
||||
// also return `this`).
|
||||
result.getAST() = this.getAST()
|
||||
result.getAst() = this.getAst()
|
||||
}
|
||||
|
||||
override predicate needsLoad() { expr.getObjectType().isValueType() }
|
||||
|
||||
@@ -15,7 +15,7 @@ private import experimental.ir.internal.IRCSharpLanguage as Language
|
||||
/**
|
||||
* Gets the `TranslatedFunction` that represents function `callable`.
|
||||
*/
|
||||
TranslatedFunction getTranslatedFunction(Callable callable) { result.getAST() = callable }
|
||||
TranslatedFunction getTranslatedFunction(Callable callable) { result.getAst() = callable }
|
||||
|
||||
/**
|
||||
* Represents the IR translation of a function. This is the root element for
|
||||
@@ -28,7 +28,10 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction {
|
||||
|
||||
final override string toString() { result = callable.toString() }
|
||||
|
||||
final override Language::AST getAST() { result = callable }
|
||||
final override Language::AST getAst() { result = callable }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the function being translated.
|
||||
@@ -269,7 +272,7 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction {
|
||||
/**
|
||||
* Gets the `TranslatedParameter` that represents parameter `param`.
|
||||
*/
|
||||
TranslatedParameter getTranslatedParameter(Parameter param) { result.getAST() = param }
|
||||
TranslatedParameter getTranslatedParameter(Parameter param) { result.getAst() = param }
|
||||
|
||||
/**
|
||||
* Represents the IR translation of a function parameter, including the
|
||||
@@ -282,7 +285,10 @@ class TranslatedParameter extends TranslatedElement, TTranslatedParameter {
|
||||
|
||||
final override string toString() { result = param.toString() }
|
||||
|
||||
final override Language::AST getAST() { result = param }
|
||||
final override Language::AST getAst() { result = param }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override Callable getFunction() { result = param.getCallable() }
|
||||
|
||||
|
||||
@@ -51,7 +51,10 @@ abstract class TranslatedInitialization extends TranslatedElement, TTranslatedIn
|
||||
|
||||
final override Callable getFunction() { result = expr.getEnclosingCallable() }
|
||||
|
||||
final override Language::AST getAST() { result = expr }
|
||||
final override Language::AST getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the expression that is doing the initialization.
|
||||
@@ -206,7 +209,10 @@ abstract class TranslatedElementInitialization extends TranslatedElement {
|
||||
result = initList.toString() + "[" + this.getElementIndex().toString() + "]"
|
||||
}
|
||||
|
||||
final override Language::AST getAST() { result = initList }
|
||||
final override Language::AST getAst() { result = initList }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override Callable getFunction() { result = initList.getEnclosingCallable() }
|
||||
|
||||
@@ -310,7 +316,10 @@ abstract class TranslatedConstructorCallFromConstructor extends TranslatedElemen
|
||||
ConstructorCallContext {
|
||||
Call call;
|
||||
|
||||
final override Language::AST getAST() { result = call }
|
||||
final override Language::AST getAst() { result = call }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override TranslatedElement getChild(int id) {
|
||||
id = 0 and result = this.getConstructorCall()
|
||||
@@ -327,7 +336,7 @@ abstract class TranslatedConstructorCallFromConstructor extends TranslatedElemen
|
||||
}
|
||||
|
||||
TranslatedConstructorInitializer getTranslatedConstructorInitializer(ConstructorInitializer ci) {
|
||||
result.getAST() = ci
|
||||
result.getAst() = ci
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ private import experimental.ir.internal.IRUtilities
|
||||
private import desugar.Foreach
|
||||
private import desugar.Lock
|
||||
|
||||
TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAST() = stmt }
|
||||
TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAst() = stmt }
|
||||
|
||||
abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt {
|
||||
Stmt stmt;
|
||||
@@ -24,7 +24,10 @@ abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt {
|
||||
|
||||
final override string toString() { result = stmt.toString() }
|
||||
|
||||
final override Language::AST getAST() { result = stmt }
|
||||
final override Language::AST getAst() { result = stmt }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override Callable getFunction() { result = stmt.getEnclosingCallable() }
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ private import experimental.ir.implementation.raw.internal.common.TranslatedExpr
|
||||
*/
|
||||
module DelegateElements {
|
||||
TranslatedDelegateConstructorCall getConstructor(DelegateCreation generatedBy) {
|
||||
result.getAST() = generatedBy
|
||||
result.getAst() = generatedBy
|
||||
}
|
||||
|
||||
TranslatedDelegateInvokeCall getInvoke(DelegateCall generatedBy) { result.getAST() = generatedBy }
|
||||
TranslatedDelegateInvokeCall getInvoke(DelegateCall generatedBy) { result.getAst() = generatedBy }
|
||||
|
||||
int noGeneratedElements(Element generatedBy) {
|
||||
(
|
||||
|
||||
@@ -56,9 +56,9 @@ private import internal.TranslatedCompilerGeneratedElement
|
||||
* Module that exposes the functions needed for the translation of the `foreach` stmt.
|
||||
*/
|
||||
module ForeachElements {
|
||||
TranslatedForeachTry getTry(ForeachStmt generatedBy) { result.getAST() = generatedBy }
|
||||
TranslatedForeachTry getTry(ForeachStmt generatedBy) { result.getAst() = generatedBy }
|
||||
|
||||
TranslatedForeachEnumerator getEnumDecl(ForeachStmt generatedBy) { result.getAST() = generatedBy }
|
||||
TranslatedForeachEnumerator getEnumDecl(ForeachStmt generatedBy) { result.getAst() = generatedBy }
|
||||
|
||||
int noGeneratedElements() { result = 13 }
|
||||
}
|
||||
@@ -71,14 +71,14 @@ private class TranslatedForeachTry extends TranslatedCompilerGeneratedTry,
|
||||
|
||||
override TranslatedElement getFinally() {
|
||||
exists(TranslatedForeachFinally ff |
|
||||
ff.getAST() = generatedBy and
|
||||
ff.getAst() = generatedBy and
|
||||
result = ff
|
||||
)
|
||||
}
|
||||
|
||||
override TranslatedElement getBody() {
|
||||
exists(TranslatedForeachWhile fw |
|
||||
fw.getAST() = generatedBy and
|
||||
fw.getAst() = generatedBy and
|
||||
result = fw
|
||||
)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ private class TranslatedForeachFinally extends TranslatedCompilerGeneratedBlock,
|
||||
override TranslatedElement getStmt(int index) {
|
||||
index = 0 and
|
||||
exists(TranslatedForeachDispose fd |
|
||||
fd.getAST() = generatedBy and
|
||||
fd.getAst() = generatedBy and
|
||||
result = fd
|
||||
)
|
||||
}
|
||||
@@ -147,14 +147,14 @@ class TranslatedForeachWhile extends TranslatedCompilerGeneratedStmt, ConditionC
|
||||
|
||||
TranslatedElement getInit() {
|
||||
exists(TranslatedForeachIterVar iv |
|
||||
iv.getAST() = generatedBy and
|
||||
iv.getAst() = generatedBy and
|
||||
result = iv
|
||||
)
|
||||
}
|
||||
|
||||
ValueConditionBase getCondition() {
|
||||
exists(TranslatedForeachWhileCondition cond |
|
||||
cond.getAST() = generatedBy and
|
||||
cond.getAst() = generatedBy and
|
||||
result = cond
|
||||
)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ private class TranslatedForeachMoveNext extends TranslatedCompilerGeneratedCall,
|
||||
|
||||
override TranslatedExprBase getQualifier() {
|
||||
exists(TranslatedMoveNextEnumAcc acc |
|
||||
acc.getAST() = generatedBy and
|
||||
acc.getAst() = generatedBy and
|
||||
result = acc
|
||||
)
|
||||
}
|
||||
@@ -230,7 +230,7 @@ private class TranslatedForeachCurrent extends TranslatedCompilerGeneratedCall,
|
||||
|
||||
override TranslatedExprBase getQualifier() {
|
||||
exists(TranslatedForeachCurrentEnumAcc acc |
|
||||
acc.getAST() = generatedBy and
|
||||
acc.getAst() = generatedBy and
|
||||
result = acc
|
||||
)
|
||||
}
|
||||
@@ -263,7 +263,7 @@ private class TranslatedForeachDispose extends TranslatedCompilerGeneratedCall,
|
||||
|
||||
override TranslatedExprBase getQualifier() {
|
||||
exists(TranslatedForeachDisposeEnumAcc acc |
|
||||
acc.getAST() = generatedBy and
|
||||
acc.getAst() = generatedBy and
|
||||
result = acc
|
||||
)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ private class TranslatedForeachWhileCondition extends TranslatedCompilerGenerate
|
||||
|
||||
override TranslatedCompilerGeneratedCall getValueExpr() {
|
||||
exists(TranslatedForeachMoveNext mn |
|
||||
mn.getAST() = generatedBy and
|
||||
mn.getAst() = generatedBy and
|
||||
result = mn
|
||||
)
|
||||
}
|
||||
@@ -311,7 +311,7 @@ private class TranslatedForeachEnumerator extends TranslatedCompilerGeneratedDec
|
||||
|
||||
override TranslatedCompilerGeneratedCall getInitialization() {
|
||||
exists(TranslatedForeachGetEnumerator ge |
|
||||
ge.getAST() = generatedBy and
|
||||
ge.getAst() = generatedBy and
|
||||
result = ge
|
||||
)
|
||||
}
|
||||
@@ -339,7 +339,7 @@ private class TranslatedForeachIterVar extends TranslatedCompilerGeneratedDeclar
|
||||
|
||||
override TranslatedCompilerGeneratedCall getInitialization() {
|
||||
exists(TranslatedForeachCurrent crtProp |
|
||||
crtProp.getAST() = generatedBy and
|
||||
crtProp.getAst() = generatedBy and
|
||||
result = crtProp
|
||||
)
|
||||
}
|
||||
@@ -361,7 +361,7 @@ private class TranslatedMoveNextEnumAcc extends TTranslatedCompilerGeneratedElem
|
||||
|
||||
override Type getVariableType() {
|
||||
exists(TranslatedForeachGetEnumerator ge |
|
||||
ge.getAST() = generatedBy and
|
||||
ge.getAst() = generatedBy and
|
||||
result = ge.getCallResultType()
|
||||
)
|
||||
}
|
||||
@@ -393,7 +393,7 @@ private class TranslatedForeachCurrentEnumAcc extends TTranslatedCompilerGenerat
|
||||
|
||||
override Type getVariableType() {
|
||||
exists(TranslatedForeachGetEnumerator ge |
|
||||
ge.getAST() = generatedBy and
|
||||
ge.getAst() = generatedBy and
|
||||
result = ge.getCallResultType()
|
||||
)
|
||||
}
|
||||
@@ -425,7 +425,7 @@ private class TranslatedForeachDisposeEnumAcc extends TTranslatedCompilerGenerat
|
||||
|
||||
override Type getVariableType() {
|
||||
exists(TranslatedForeachGetEnumerator ge |
|
||||
ge.getAST() = generatedBy and
|
||||
ge.getAst() = generatedBy and
|
||||
result = ge.getCallResultType()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ private import internal.TranslatedCompilerGeneratedExpr
|
||||
* Module that exposes the functions needed for the translation of the `lock` stmt.
|
||||
*/
|
||||
module LockElements {
|
||||
TranslatedLockedVarDecl getLockedVarDecl(LockStmt generatedBy) { result.getAST() = generatedBy }
|
||||
TranslatedLockedVarDecl getLockedVarDecl(LockStmt generatedBy) { result.getAst() = generatedBy }
|
||||
|
||||
TranslatedLockTry getTry(LockStmt generatedBy) { result.getAST() = generatedBy }
|
||||
TranslatedLockTry getTry(LockStmt generatedBy) { result.getAst() = generatedBy }
|
||||
|
||||
TranslatedLockWasTakenDecl getLockWasTakenDecl(LockStmt generatedBy) {
|
||||
result.getAST() = generatedBy
|
||||
result.getAst() = generatedBy
|
||||
}
|
||||
|
||||
int noGeneratedElements() { result = 14 }
|
||||
@@ -64,14 +64,14 @@ private class TranslatedLockTry extends TranslatedCompilerGeneratedTry,
|
||||
|
||||
override TranslatedElement getFinally() {
|
||||
exists(TranslatedLockFinally fin |
|
||||
fin.getAST() = generatedBy and
|
||||
fin.getAst() = generatedBy and
|
||||
result = fin
|
||||
)
|
||||
}
|
||||
|
||||
override TranslatedElement getBody() {
|
||||
exists(TranslatedLockTryBody ltb |
|
||||
ltb.getAST() = generatedBy and
|
||||
ltb.getAst() = generatedBy and
|
||||
result = ltb
|
||||
)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ private class TranslatedLockTryBody extends TranslatedCompilerGeneratedBlock,
|
||||
override TranslatedElement getStmt(int index) {
|
||||
index = 0 and
|
||||
exists(TranslatedMonitorEnter me |
|
||||
me.getAST() = generatedBy and
|
||||
me.getAst() = generatedBy and
|
||||
result = me
|
||||
)
|
||||
or
|
||||
@@ -110,7 +110,7 @@ private class TranslatedLockFinally extends TranslatedCompilerGeneratedBlock,
|
||||
override TranslatedElement getStmt(int index) {
|
||||
index = 0 and
|
||||
exists(TranslatedFinallyIf fif |
|
||||
fif.getAST() = generatedBy and
|
||||
fif.getAst() = generatedBy and
|
||||
result = fif
|
||||
)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ private class TranslatedMonitorExit extends TranslatedCompilerGeneratedCall,
|
||||
override TranslatedExprBase getArgument(int id) {
|
||||
id = 0 and
|
||||
exists(TranslatedMonitorExitVarAcc var |
|
||||
var.getAST() = generatedBy and
|
||||
var.getAst() = generatedBy and
|
||||
result = var
|
||||
)
|
||||
}
|
||||
@@ -170,13 +170,13 @@ private class TranslatedMonitorEnter extends TranslatedCompilerGeneratedCall,
|
||||
override TranslatedExprBase getArgument(int id) {
|
||||
id = 0 and
|
||||
exists(TranslatedMonitorEnterVarAcc var |
|
||||
var.getAST() = generatedBy and
|
||||
var.getAst() = generatedBy and
|
||||
result = var
|
||||
)
|
||||
or
|
||||
id = 1 and
|
||||
exists(TranslatedLockWasTakenRefArg refArg |
|
||||
refArg.getAST() = generatedBy and
|
||||
refArg.getAst() = generatedBy and
|
||||
result = refArg
|
||||
)
|
||||
}
|
||||
@@ -197,7 +197,7 @@ private class TranslatedIfCondition extends TranslatedCompilerGeneratedValueCond
|
||||
|
||||
override TranslatedCompilerGeneratedExpr getValueExpr() {
|
||||
exists(TranslatedLockWasTakenCondVarAcc condVar |
|
||||
condVar.getAST() = generatedBy and
|
||||
condVar.getAst() = generatedBy and
|
||||
result = condVar
|
||||
)
|
||||
}
|
||||
@@ -216,14 +216,14 @@ private class TranslatedFinallyIf extends TranslatedCompilerGeneratedIfStmt,
|
||||
|
||||
override TranslatedCompilerGeneratedValueCondition getCondition() {
|
||||
exists(TranslatedIfCondition cond |
|
||||
cond.getAST() = generatedBy and
|
||||
cond.getAst() = generatedBy and
|
||||
result = cond
|
||||
)
|
||||
}
|
||||
|
||||
override TranslatedCompilerGeneratedCall getThen() {
|
||||
exists(TranslatedMonitorExit me |
|
||||
me.getAST() = generatedBy and
|
||||
me.getAst() = generatedBy and
|
||||
result = me
|
||||
)
|
||||
}
|
||||
@@ -271,7 +271,7 @@ private class TranslatedLockWasTakenDecl extends TranslatedCompilerGeneratedDecl
|
||||
|
||||
override TranslatedCompilerGeneratedExpr getInitialization() {
|
||||
exists(TranslatedWasTakenConst const |
|
||||
const.getAST() = generatedBy and
|
||||
const.getAst() = generatedBy and
|
||||
result = const
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,5 +18,8 @@ abstract class TranslatedCompilerGeneratedElement extends TranslatedElement,
|
||||
|
||||
final override Callable getFunction() { result = generatedBy.getEnclosingCallable() }
|
||||
|
||||
final override Language::AST getAST() { result = generatedBy }
|
||||
final override Language::AST getAst() { result = generatedBy }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = getAst() }
|
||||
}
|
||||
|
||||
@@ -55,7 +55,10 @@ class IRVariable extends TIRVariable {
|
||||
* Gets the AST node that declared this variable, or that introduced this
|
||||
* variable as part of the AST-to-IR translation.
|
||||
*/
|
||||
Language::AST getAST() { none() }
|
||||
Language::AST getAst() { none() }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = getAst() }
|
||||
|
||||
/**
|
||||
* Gets an identifier string for the variable. This identifier is unique
|
||||
@@ -66,7 +69,7 @@ class IRVariable extends TIRVariable {
|
||||
/**
|
||||
* Gets the source location of this variable.
|
||||
*/
|
||||
final Language::Location getLocation() { result = getAST().getLocation() }
|
||||
final Language::Location getLocation() { result = getAst().getLocation() }
|
||||
|
||||
/**
|
||||
* Gets the IR for the function that references this variable.
|
||||
@@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable {
|
||||
|
||||
final override string toString() { result = getVariable().toString() }
|
||||
|
||||
final override Language::AST getAST() { result = var }
|
||||
final override Language::AST getAst() { result = var }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = getAst() }
|
||||
|
||||
final override string getUniqueId() {
|
||||
result = getVariable().toString() + " " + getVariable().getLocation().toString()
|
||||
@@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable {
|
||||
|
||||
final override Language::LanguageType getLanguageType() { result = type }
|
||||
|
||||
final override Language::AST getAST() { result = ast }
|
||||
final override Language::AST getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = getAst() }
|
||||
|
||||
override string toString() { result = getBaseString() + getLocationString() }
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction {
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() }
|
||||
final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() }
|
||||
|
||||
/**
|
||||
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
|
||||
@@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction {
|
||||
string getResultId() {
|
||||
this.shouldGenerateDumpStrings() and
|
||||
result =
|
||||
this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank()
|
||||
this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the AST that caused this instruction to be generated.
|
||||
*/
|
||||
final Language::AST getAST() { result = Construction::getInstructionAST(this) }
|
||||
final Language::AST getAst() { result = Construction::getInstructionAst(this) }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the location of the source code for this instruction.
|
||||
*/
|
||||
final Language::Location getLocation() { result = this.getAST().getLocation() }
|
||||
final Language::Location getLocation() { result = this.getAst().getLocation() }
|
||||
|
||||
/**
|
||||
* Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a
|
||||
@@ -459,7 +462,10 @@ class VariableInstruction extends Instruction {
|
||||
/**
|
||||
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
|
||||
*/
|
||||
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
|
||||
final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() }
|
||||
|
||||
/** DEPRECATED: Alias for getAstVariable */
|
||||
deprecated Language::Variable getASTVariable() { result = this.getAstVariable() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ private import internal.OperandInternal
|
||||
* of `TOperand` that are used in this stage.
|
||||
*/
|
||||
private class TStageOperand =
|
||||
TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand;
|
||||
TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand;
|
||||
|
||||
/**
|
||||
* A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as
|
||||
@@ -38,7 +38,7 @@ class Operand extends TStageOperand {
|
||||
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
|
||||
exists(Instruction use, Instruction def | this = registerOperand(use, _, def))
|
||||
or
|
||||
exists(Instruction use | this = nonSSAMemoryOperand(use, _))
|
||||
exists(Instruction use | this = nonSsaMemoryOperand(use, _))
|
||||
or
|
||||
exists(Instruction use, Instruction def, IRBlock predecessorBlock |
|
||||
this = phiOperand(use, def, predecessorBlock, _) or
|
||||
@@ -209,7 +209,7 @@ class Operand extends TStageOperand {
|
||||
class MemoryOperand extends Operand {
|
||||
cached
|
||||
MemoryOperand() {
|
||||
this instanceof TNonSSAMemoryOperand or
|
||||
this instanceof TNonSsaMemoryOperand or
|
||||
this instanceof TPhiOperand or
|
||||
this instanceof TChiOperand
|
||||
}
|
||||
@@ -249,7 +249,7 @@ class NonPhiOperand extends Operand {
|
||||
|
||||
NonPhiOperand() {
|
||||
this = registerOperand(useInstr, tag, _) or
|
||||
this = nonSSAMemoryOperand(useInstr, tag) or
|
||||
this = nonSsaMemoryOperand(useInstr, tag) or
|
||||
this = chiOperand(useInstr, tag)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
|
||||
cached
|
||||
NonPhiMemoryOperand() {
|
||||
this = nonSSAMemoryOperand(useInstr, tag)
|
||||
this = nonSsaMemoryOperand(useInstr, tag)
|
||||
or
|
||||
this = chiOperand(useInstr, tag)
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) {
|
||||
// count rather than strictcount to handle missing AST elements
|
||||
// separate instanceof and inline casts to avoid failed casts with a count of 0
|
||||
instr instanceof VariableAddressInstruction and
|
||||
count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1
|
||||
count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1
|
||||
or
|
||||
instr instanceof ConstantInstruction and
|
||||
count(instr.getResultIRType()) != 1
|
||||
@@ -121,7 +121,7 @@ private predicate variableAddressValueNumber(
|
||||
// The underlying AST element is used as value-numbering key instead of the
|
||||
// `IRVariable` to work around a problem where a variable or expression with
|
||||
// multiple types gives rise to multiple `IRVariable`s.
|
||||
unique( | | instr.getIRVariable().getAST()) = ast
|
||||
unique( | | instr.getIRVariable().getAst()) = ast
|
||||
}
|
||||
|
||||
private predicate initializeParameterValueNumber(
|
||||
@@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber(
|
||||
// The underlying AST element is used as value-numbering key instead of the
|
||||
// `IRVariable` to work around a problem where a variable or expression with
|
||||
// multiple types gives rise to multiple `IRVariable`s.
|
||||
instr.getIRVariable().getAST() = var
|
||||
instr.getIRVariable().getAst() = var
|
||||
}
|
||||
|
||||
private predicate constantValueNumber(
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
private import experimental.ir.implementation.internal.TOperand
|
||||
import UnaliasedSSAOperands
|
||||
import UnaliasedSsaOperands
|
||||
|
||||
@@ -2,7 +2,7 @@ private import SSAConstructionInternal
|
||||
private import OldIR
|
||||
private import Alias
|
||||
private import SSAConstruction
|
||||
private import DebugSSA
|
||||
private import DebugSsa
|
||||
|
||||
bindingset[offset]
|
||||
private string getKeySuffixForOffset(int offset) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
private import SSAConstruction as SSA
|
||||
import SSA::SSAConsistency
|
||||
import SSA::SsaConsistency
|
||||
|
||||
@@ -112,7 +112,7 @@ private module Cached {
|
||||
exists(Alias::getResultMemoryLocation(oldInstruction))
|
||||
or
|
||||
// This result was already modeled by a previous iteration of SSA.
|
||||
Alias::canReuseSSAForOldResult(oldInstruction)
|
||||
Alias::canReuseSsaForOldResult(oldInstruction)
|
||||
}
|
||||
|
||||
cached
|
||||
@@ -182,7 +182,7 @@ private module Cached {
|
||||
* unreachable, this predicate will recurse through any degenerate `Phi` instructions to find the
|
||||
* true definition.
|
||||
*/
|
||||
private Instruction getNewDefinitionFromOldSSA(OldIR::MemoryOperand oldOperand, Overlap overlap) {
|
||||
private Instruction getNewDefinitionFromOldSsa(OldIR::MemoryOperand oldOperand, Overlap overlap) {
|
||||
exists(Overlap originalOverlap |
|
||||
originalOverlap = oldOperand.getDefinitionOverlap() and
|
||||
(
|
||||
@@ -191,7 +191,7 @@ private module Cached {
|
||||
or
|
||||
exists(OldIR::PhiInputOperand phiOperand, Overlap phiOperandOverlap |
|
||||
phiOperand = getDegeneratePhiOperand(oldOperand.getAnyDef()) and
|
||||
result = getNewDefinitionFromOldSSA(phiOperand, phiOperandOverlap) and
|
||||
result = getNewDefinitionFromOldSsa(phiOperand, phiOperandOverlap) and
|
||||
overlap =
|
||||
combineOverlap(pragma[only_bind_out](phiOperandOverlap),
|
||||
pragma[only_bind_out](originalOverlap))
|
||||
@@ -233,7 +233,7 @@ private module Cached {
|
||||
)
|
||||
or
|
||||
exists(OldIR::NonPhiMemoryOperand oldOperand |
|
||||
result = getNewDefinitionFromOldSSA(oldOperand, overlap) and
|
||||
result = getNewDefinitionFromOldSsa(oldOperand, overlap) and
|
||||
oldOperand.getUse() = instruction and
|
||||
tag = oldOperand.getOperandTag()
|
||||
)
|
||||
@@ -307,13 +307,13 @@ private module Cached {
|
||||
* Gets the new definition instruction for the operand of `instr` that flows from the block
|
||||
* `newPredecessorBlock`, based on that operand's definition in the old IR.
|
||||
*/
|
||||
private Instruction getNewPhiOperandDefinitionFromOldSSA(
|
||||
private Instruction getNewPhiOperandDefinitionFromOldSsa(
|
||||
Instruction instr, IRBlock newPredecessorBlock, Overlap overlap
|
||||
) {
|
||||
exists(OldIR::PhiInstruction oldPhi, OldIR::PhiInputOperand oldOperand |
|
||||
oldPhi = getOldInstruction(instr) and
|
||||
oldOperand = oldPhi.getInputOperand(getOldBlock(newPredecessorBlock)) and
|
||||
result = getNewDefinitionFromOldSSA(oldOperand, overlap)
|
||||
result = getNewDefinitionFromOldSsa(oldOperand, overlap)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ private module Cached {
|
||||
overlap = Alias::getOverlap(actualDefLocation, useLocation)
|
||||
)
|
||||
or
|
||||
result = getNewPhiOperandDefinitionFromOldSSA(instr, newPredecessorBlock, overlap)
|
||||
result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap)
|
||||
}
|
||||
|
||||
cached
|
||||
@@ -412,17 +412,17 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::AST getInstructionAST(Instruction instr) {
|
||||
result = getOldInstruction(instr).getAST()
|
||||
Language::AST getInstructionAst(Instruction instr) {
|
||||
result = getOldInstruction(instr).getAst()
|
||||
or
|
||||
exists(RawIR::Instruction blockStartInstr |
|
||||
instr = phiInstruction(blockStartInstr, _) and
|
||||
result = blockStartInstr.getAST()
|
||||
result = blockStartInstr.getAst()
|
||||
)
|
||||
or
|
||||
exists(RawIR::Instruction primaryInstr |
|
||||
instr = chiInstruction(primaryInstr) and
|
||||
result = primaryInstr.getAST()
|
||||
result = primaryInstr.getAst()
|
||||
)
|
||||
or
|
||||
exists(IRFunctionBase irFunc |
|
||||
@@ -430,6 +430,12 @@ private module Cached {
|
||||
)
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for getInstructionAst */
|
||||
cached
|
||||
deprecated Language::AST getInstructionAST(Instruction instr) {
|
||||
result = getInstructionAst(instr)
|
||||
}
|
||||
|
||||
cached
|
||||
Language::LanguageType getInstructionResultType(Instruction instr) {
|
||||
result = instr.(RawIR::Instruction).getResultLanguageType()
|
||||
@@ -975,35 +981,41 @@ module DefUse {
|
||||
}
|
||||
}
|
||||
|
||||
predicate canReuseSSAForMemoryResult(Instruction instruction) {
|
||||
predicate canReuseSsaForMemoryResult(Instruction instruction) {
|
||||
exists(OldInstruction oldInstruction |
|
||||
oldInstruction = getOldInstruction(instruction) and
|
||||
(
|
||||
// The previous iteration said it was reusable, so we should mark it as reusable as well.
|
||||
Alias::canReuseSSAForOldResult(oldInstruction)
|
||||
Alias::canReuseSsaForOldResult(oldInstruction)
|
||||
or
|
||||
// The current alias analysis says it is reusable.
|
||||
Alias::getResultMemoryLocation(oldInstruction).canReuseSSA()
|
||||
Alias::getResultMemoryLocation(oldInstruction).canReuseSsa()
|
||||
)
|
||||
)
|
||||
or
|
||||
exists(Alias::MemoryLocation defLocation |
|
||||
// This is a `Phi` for a reusable location, so the result of the `Phi` is reusable as well.
|
||||
instruction = phiInstruction(_, defLocation) and
|
||||
defLocation.canReuseSSA()
|
||||
defLocation.canReuseSsa()
|
||||
)
|
||||
// We don't support reusing SSA for any location that could create a `Chi` instruction.
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsaForMemoryResult */
|
||||
deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1;
|
||||
|
||||
/**
|
||||
* Expose some of the internal predicates to PrintSSA.qll. We do this by publically importing those modules in the
|
||||
* `DebugSSA` module, which is then imported by PrintSSA.
|
||||
*/
|
||||
module DebugSSA {
|
||||
module DebugSsa {
|
||||
import PhiInsertion
|
||||
import DefUse
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for DebugSsa */
|
||||
deprecated module DebugSSA = DebugSsa;
|
||||
|
||||
import CachedForDebugging
|
||||
|
||||
cached
|
||||
@@ -1038,7 +1050,7 @@ private module CachedForDebugging {
|
||||
|
||||
private OldIR::IRTempVariable getOldTempVariable(IRTempVariable var) {
|
||||
result.getEnclosingFunction() = var.getEnclosingFunction() and
|
||||
result.getAST() = var.getAST() and
|
||||
result.getAst() = var.getAst() and
|
||||
result.getTag() = var.getTag()
|
||||
}
|
||||
|
||||
@@ -1061,7 +1073,7 @@ private module CachedForDebugging {
|
||||
int maxValue() { result = 2147483647 }
|
||||
}
|
||||
|
||||
module SSAConsistency {
|
||||
module SsaConsistency {
|
||||
/**
|
||||
* Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis.
|
||||
*/
|
||||
@@ -1114,6 +1126,9 @@ module SSAConsistency {
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for SsaConsistency */
|
||||
deprecated module SSAConsistency = SsaConsistency;
|
||||
|
||||
/**
|
||||
* Provides the portion of the parameterized IR interface that is used to construct the SSA stages
|
||||
* of the IR. The raw stage of the IR does not expose these predicates.
|
||||
|
||||
@@ -3,7 +3,7 @@ import experimental.ir.implementation.raw.internal.reachability.ReachableBlock a
|
||||
import experimental.ir.implementation.raw.internal.reachability.Dominance as Dominance
|
||||
import experimental.ir.implementation.unaliased_ssa.IR as NewIR
|
||||
import experimental.ir.implementation.raw.internal.IRConstruction as RawStage
|
||||
import experimental.ir.implementation.internal.TInstruction::UnaliasedSSAInstructions as SSAInstructions
|
||||
import experimental.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SSAInstructions
|
||||
import experimental.ir.internal.IRCSharpLanguage as Language
|
||||
import SimpleSSA as Alias
|
||||
import experimental.ir.implementation.internal.TOperand::UnaliasedSSAOperands as SSAOperands
|
||||
import experimental.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SSAOperands
|
||||
|
||||
@@ -41,11 +41,14 @@ predicate isVariableModeled(Allocation var) {
|
||||
* subsequent iterations will recompute SSA for any variable that we assumed did not escape, but
|
||||
* actually would have escaped if we had used a sound escape analysis.
|
||||
*/
|
||||
predicate canReuseSSAForVariable(IRAutomaticVariable var) {
|
||||
predicate canReuseSsaForVariable(IRAutomaticVariable var) {
|
||||
isVariableModeled(var) and
|
||||
not allocationEscapes(var)
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsaForVariable */
|
||||
deprecated predicate canReuseSSAForVariable = canReuseSsaForVariable/1;
|
||||
|
||||
private newtype TMemoryLocation = MkMemoryLocation(Allocation var) { isVariableModeled(var) }
|
||||
|
||||
private MemoryLocation getMemoryLocation(Allocation var) { result.getAllocation() = var }
|
||||
@@ -69,10 +72,16 @@ class MemoryLocation extends TMemoryLocation {
|
||||
|
||||
final string getUniqueId() { result = var.getUniqueId() }
|
||||
|
||||
final predicate canReuseSSA() { canReuseSSAForVariable(var) }
|
||||
final predicate canReuseSsa() { canReuseSsaForVariable(var) }
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsa */
|
||||
deprecated predicate canReuseSSA() { canReuseSsa() }
|
||||
}
|
||||
|
||||
predicate canReuseSSAForOldResult(Instruction instr) { none() }
|
||||
predicate canReuseSsaForOldResult(Instruction instr) { none() }
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsaForOldResult */
|
||||
deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1;
|
||||
|
||||
/**
|
||||
* Represents a set of `MemoryLocation`s that cannot overlap with
|
||||
|
||||
@@ -28,8 +28,8 @@ class GuardCondition extends Expr {
|
||||
or
|
||||
// the IR short-circuits if(!x)
|
||||
// don't produce a guard condition for `y = !x` and other non-short-circuited cases
|
||||
not exists(Instruction inst | this = inst.getAST()) and
|
||||
exists(IRGuardCondition ir | this.(LogicalNotExpr).getOperand() = ir.getAST())
|
||||
not exists(Instruction inst | this = inst.getAst()) and
|
||||
exists(IRGuardCondition ir | this.(LogicalNotExpr).getOperand() = ir.getAst())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,8 +172,8 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
|
||||
*/
|
||||
private class GuardConditionFromShortCircuitNot extends GuardCondition, LogicalNotExpr {
|
||||
GuardConditionFromShortCircuitNot() {
|
||||
not exists(Instruction inst | this = inst.getAST()) and
|
||||
exists(IRGuardCondition ir | this.getOperand() = ir.getAST())
|
||||
not exists(Instruction inst | this = inst.getAst()) and
|
||||
exists(IRGuardCondition ir | this.getOperand() = ir.getAst())
|
||||
}
|
||||
|
||||
override predicate controls(BasicBlock controlled, boolean testIsTrue) {
|
||||
@@ -267,7 +267,7 @@ private class GuardConditionFromIR extends GuardCondition {
|
||||
private predicate controlsBlock1(BasicBlock controlled, boolean testIsTrue) {
|
||||
exists(IRBlock irb |
|
||||
forex(IRGuardCondition inst | inst = ir | inst.controls(irb, testIsTrue)) and
|
||||
irb.getAnInstruction().getAST().(ControlFlowElement).getAControlFlowNode().getBasicBlock() =
|
||||
irb.getAnInstruction().getAst().(ControlFlowElement).getAControlFlowNode().getBasicBlock() =
|
||||
controlled and
|
||||
not isUnreachedBlock(irb)
|
||||
)
|
||||
|
||||
@@ -623,7 +623,7 @@ private predicate boundedInstruction(
|
||||
)
|
||||
or
|
||||
exists(PropertyAccess pa |
|
||||
i.(CallInstruction).getAST() = pa and
|
||||
i.(CallInstruction).getAst() = pa and
|
||||
pa.getProperty().getName() = "Length" and
|
||||
b instanceof ZeroBound and
|
||||
delta = origdelta and
|
||||
|
||||
@@ -10,17 +10,17 @@ predicate boundedArrayAccess(ElementAccess aa, int k) {
|
||||
exists(Instruction index, Instruction usage, Bound b, int delta |
|
||||
(
|
||||
// indexer access
|
||||
usage.(CallInstruction).getAST() = aa
|
||||
usage.(CallInstruction).getAst() = aa
|
||||
or
|
||||
// array access
|
||||
usage.(PointerAddInstruction).getAST() = aa
|
||||
usage.(PointerAddInstruction).getAst() = aa
|
||||
) and
|
||||
usage.getAnOperand().getDef() = index and
|
||||
boundedInstruction(index, b, delta, true, _)
|
||||
|
|
||||
exists(PropertyAccess pa |
|
||||
k = delta and
|
||||
b.getInstruction().getAST() = pa and
|
||||
b.getInstruction().getAst() = pa and
|
||||
pa.getProperty().getName() = "Length" and
|
||||
pa.(QualifiableExpr).getQualifier().(VariableAccess).getTarget() =
|
||||
aa.getQualifier().(VariableAccess).getTarget()
|
||||
|
||||
@@ -21,6 +21,8 @@ query predicate multilineComment(
|
||||
commentLine(c, l, numLines, text, rawText)
|
||||
}
|
||||
|
||||
query predicate xmlComment(CommentBlock c, XmlComment l, int numLines, string text, string rawText) {
|
||||
query predicate xmlComment(
|
||||
CommentBlock c, XmlCommentLine l, int numLines, string text, string rawText
|
||||
) {
|
||||
commentLine(c, l, numLines, text, rawText)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user