Skip to content

Commit 4f53a1a

Browse files
committed
JS: Cache ClassNode::Range
1 parent d0b8b32 commit 4f53a1a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,56 +1081,67 @@ module ClassNode {
10811081
* Subclass this to introduce new kinds of class nodes. If you want to refine
10821082
* the definition of existing class nodes, subclass `DataFlow::ClassNode` instead.
10831083
*/
1084+
cached
10841085
abstract class Range extends DataFlow::SourceNode {
10851086
/**
10861087
* Gets the name of the class, if it has one.
10871088
*/
1089+
cached
10881090
abstract string getName();
10891091

10901092
/**
10911093
* Gets a description of the class.
10921094
*/
1095+
cached
10931096
abstract string describe();
10941097

10951098
/**
10961099
* Gets the constructor function of this class.
10971100
*/
1101+
cached
10981102
abstract FunctionNode getConstructor();
10991103

11001104
/**
11011105
* Gets the instance member with the given name and kind.
11021106
*/
1107+
cached
11031108
abstract FunctionNode getInstanceMember(string name, MemberKind kind);
11041109

11051110
/**
11061111
* Gets an instance member with the given kind.
11071112
*/
1113+
cached
11081114
abstract FunctionNode getAnInstanceMember(MemberKind kind);
11091115

11101116
/**
11111117
* Gets the static method of this class with the given name.
11121118
*/
1119+
cached
11131120
abstract FunctionNode getStaticMethod(string name);
11141121

11151122
/**
11161123
* Gets a static method of this class.
11171124
*
11181125
* The constructor is not considered a static method.
11191126
*/
1127+
cached
11201128
abstract FunctionNode getAStaticMethod();
11211129

11221130
/**
11231131
* Gets a dataflow node representing a class to be used as the super-class
11241132
* of this node.
11251133
*/
1134+
cached
11261135
abstract DataFlow::Node getASuperClassNode();
11271136

11281137
/**
11291138
* Gets the type annotation for the field `fieldName`, if any.
11301139
*/
1140+
cached
11311141
TypeAnnotation getFieldTypeAnnotation(string fieldName) { none() }
11321142

11331143
/** Gets a decorator applied to this class. */
1144+
cached
11341145
DataFlow::Node getADecorator() { none() }
11351146
}
11361147

javascript/ql/src/semmle/javascript/internal/CachedStages.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ module Stages {
135135
exists(any(AccessPath a).getAnInstanceIn(_))
136136
or
137137
exists(any(DataFlow::PropRef ref).getBase())
138+
or
139+
exists(any(DataFlow::ClassNode cls))
138140
}
139141
}
140142

0 commit comments

Comments
 (0)