<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94940>94940</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Checker callbacks only triggered for some statements
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
T-Gruber
</td>
</tr>
</table>
<pre>
I am currently working on different checkers for the Clang Static Analyser (llvm-project version release 17.x). One of the goals is to gain information about inline assembly code (GCCAsmStmt, ...). For this I wanted to use the callback method checkPreStmt<clang::GCCAsmStmt>. I noticed that not all stmts trigger the checkPreStmt. I am aware of this for statements that affect branches, such as IfStmt or similar, as the checkBranchCondition is triggered for these. However, I would expect the checkPreStmt/checkPostStmt to be called for statements such as clang::GCCAsmStmt or clang::CompoundStmt.
Here is the code relevant code snippet of the implemented checker:
```cpp
class AsmChecker
: public clang::ento::Checker<clang::ento::check::PreStmt<clang::Stmt> {
public:
void checkPreStmt(const clang::Stmt *PreS,
clang::ento::CheckerContext &CC) const {
llvm::outs() << "checkPreStmt: StmtClassName = " << PreS->getStmtClassName() << "\n";
}
```
For the following example:
```cpp
extern int a, b, res;
int main() {
__asm__("addl %%ebx, %%eax;" : "=a"(res) : "a"(a), "b"(b));
return 0;
}
```
The corresponding checkPreStmt is not triggered for all Stmts contained in the AST:
```
checkPreStmt: StmtClassName = ImplicitCastExpr
checkPreStmt: StmtClassName = ImplicitCastExpr
checkPreStmt: StmtClassName = IntegerLiteral
checkPreStmt: StmtClassName = ReturnStmt
```
A look at the ExprEngine shows that ExprEngine::VisitGCCAsmStmt is called for GCCAsmStmts, but this function does not call the corresponding pre- and post-checkers (runCheckersForPreStmt/runCheckersForPostStmt) as is the case for some statements (e.g. VisitArraySubscriptExpr).
Is there a good reason for triggering the checkers only for certain statements or is this a current limitation?
I would be very grateful for any hints
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/e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