mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Revert "JavaScript: Patch CFG to improve support for non-top level import declarations."
This reverts commit f05e777e64.
This commit is contained in:
committed by
Max Schaefer
parent
5e75a62f5c
commit
b282444740
@@ -281,7 +281,7 @@ import javascript
|
||||
*/
|
||||
class ControlFlowNode extends @cfg_node, Locatable {
|
||||
/** Gets a node succeeding this node in the CFG. */
|
||||
cached ControlFlowNode getASuccessor() {
|
||||
ControlFlowNode getASuccessor() {
|
||||
successor(this, result)
|
||||
}
|
||||
|
||||
@@ -457,47 +457,3 @@ class ConcreteControlFlowNode extends ControlFlowNode {
|
||||
not this instanceof SyntheticControlFlowNode
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A CFG node corresponding to a nested (that is, non-toplevel) import declaration.
|
||||
*
|
||||
* This is a non-standard language feature that is not currently supported very well
|
||||
* by the extractor, in particular such imports do not appear in the control flow graph
|
||||
* generated by the extractor. We patch them in by overriding `getASuccessor`; once an
|
||||
* extractor fix becomes available, this class can be removed.
|
||||
*/
|
||||
private class NestedImportDeclaration extends ImportDeclaration {
|
||||
NestedImportDeclaration() {
|
||||
exists (ASTNode p | p = getParent() |
|
||||
not p instanceof TopLevel
|
||||
) and
|
||||
// if there are no specifiers, the default control flow graph is fine
|
||||
exists(getASpecifier())
|
||||
}
|
||||
|
||||
override ControlFlowNode getASuccessor() {
|
||||
result = getSpecifier(0).getFirstControlFlowNode()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A CFG node corresponding to an import specifier in a nested import declaration.
|
||||
*
|
||||
* As for `NestedImportDeclaration` above, this is a temporary workaround that will be
|
||||
* removed once extractor support for this non-standard language feature becomes available.
|
||||
*/
|
||||
private class NestedImportSpecifier extends ImportSpecifier {
|
||||
NestedImportDeclaration decl;
|
||||
int i;
|
||||
|
||||
NestedImportSpecifier() {
|
||||
this = decl.getSpecifier(i)
|
||||
}
|
||||
|
||||
override ControlFlowNode getASuccessor() {
|
||||
result = decl.getSpecifier(i+1).getFirstControlFlowNode()
|
||||
or
|
||||
not exists(decl.getSpecifier(i+1)) and
|
||||
successor(decl, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user