Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb4dac5

Browse files
committed
C++: Minimal caching of the IR type system
This was the minimal amount of predicates I could easily cache without introducing extra cached stages. The predicates that are not cached here, like `CppType::getTypeSize` and `getCanonicalLanguageType`, appear to be cheap. I've tested that this avoids recomputation of the IR type system by running grep -c 'Starting to evaluate predicate CppType::CppType::getIRType_dispred' on the evaluator log for `IRSanity.ql`. It drops from 4 to 1. The pretty-printed DIL drops from 79,175 lines to 76,326 lines.
1 parent 426565a commit fb4dac5

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/IRType.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
private import internal.IRTypeInternal
66

7+
cached
78
private newtype TIRType =
89
TIRVoidType() or
910
TIRUnknownType() or

cpp/ql/src/semmle/code/cpp/ir/internal/CppType.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ private IRType getIRTypeForPRValue(Type type) {
175175
)
176176
}
177177

178+
cached
178179
private newtype TCppType =
179180
TPRValueType(Type type) { exists(getIRTypeForPRValue(type)) } or
180181
TFunctionGLValueType() or
@@ -203,6 +204,7 @@ class CppType extends TCppType {
203204
* Gets the `IRType` that represents this `CppType`. Many different `CppType`s can map to a single
204205
* `IRType`.
205206
*/
207+
cached
206208
IRType getIRType() { none() }
207209

208210
/**

0 commit comments

Comments
 (0)