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

Skip to content

Commit 429aa15

Browse files
committed
C++: Speed up PrintAST.
1 parent decbb08 commit 429aa15

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

cpp/ql/src/semmle/code/cpp/PrintAST.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,22 @@ class PrintASTNode extends TPrintASTNode {
234234
private Function getEnclosingFunction() { result = getParent*().(FunctionNode).getFunction() }
235235
}
236236

237+
private class PrintableElementBase extends ElementBase {
238+
PrintableElementBase() {
239+
not this instanceof Locatable
240+
or
241+
shouldPrintFunction(getEnclosingFunction(this.(Locatable)))
242+
}
243+
244+
pragma[noinline]
245+
string getAPrimaryQlClass0() { result = getAPrimaryQlClass() }
246+
}
247+
237248
/**
238249
* Retrieves the canonical QL class(es) for entity `el`
239250
*/
240-
private string qlClass(ElementBase el) {
241-
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
251+
private string qlClass(PrintableElementBase el) {
252+
result = "[" + concat(el.getAPrimaryQlClass0(), ",") + "] "
242253
// Alternative implementation -- do not delete. It is useful for QL class discovery.
243254
//result = "["+ concat(el.getAQlClass(), ",") + "] "
244255
}

0 commit comments

Comments
 (0)