mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C++: Implement Function::hasErrors()
This commit is contained in:
@@ -500,6 +500,14 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
|
||||
* Gets the nearest enclosing AccessHolder.
|
||||
*/
|
||||
override AccessHolder getEnclosingAccessHolder() { result = this.getDeclaringType() }
|
||||
|
||||
/**
|
||||
* Holds if this function has extraction errors that create an `ErrorExpr`.
|
||||
*/
|
||||
predicate hasErrors() {
|
||||
// Exclude allocator call arguments because they are are always extracted as `ErrorExpr`.
|
||||
exists(ErrorExpr e | e.getEnclosingFunction() = this and not e.isFirstAllocatorCallArgument())
|
||||
}
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -744,6 +744,13 @@ class ErrorExpr extends Expr, @errorexpr {
|
||||
override string toString() { result = "<error expr>" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ErrorExpr" }
|
||||
|
||||
/**
|
||||
* Holds if this error expression is the first argument to a `new` allocation call.
|
||||
*/
|
||||
predicate isFirstAllocatorCallArgument() {
|
||||
this = any(NewOrNewArrayExpr new).getAllocatorCall().getArgument(0)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user