@specs-feup/clava
Version:
A C/C++ source-to-source compiler written in Typescript
28 lines (23 loc) • 759 B
text/typescript
import { Joinpoint, Vardecl } from "../../../Joinpoints.js";
import Checker from "../Checker.js";
import CheckResult from "../CheckResult.js";
/**
* Check for the presence of lambda objects using capture by reference
*/
export default class LambdaChecker extends Checker {
private advice =
" A lambda object must not outlive any of its reference captured objects." +
"Make sure that variables contained in the lambda expression will not use an obsolete pointer.(CWE-416).\n\n";
constructor() {
super("lambda");
}
check($node: Joinpoint) {
if (
!$node.code.match(/.*\[&\]\s*\(.*\)\s*\{.*\}.*/) ||
!($node instanceof Vardecl)
) {
return;
}
return new CheckResult(this.name, $node, this.advice);
}
}