void MyChecker::checkPostStmt(const ReturnStmt *RS, CheckerContext &C) const { ProgramStateRef state = C.getState(); const Expr *RetE = RS->getRetValue(); if (RetE) { state = state->add(RetE); C.addTransition(state); } }
void checkASTDecl(const FunctionDecl *D, AnalysisManager &Mgr, BugReporter &BR) { CheckerContext C(D, Mgr, BR); if (D->hasBody()) { const Stmt *Body = D->getBody(); C.addTransition(Mgr.getInitialState(D->getBody())); checkASTStmt(Body, C); } }In this example, the `checkASTDecl` method traverses the AST of a function declaration and checks if the function has a body. If it does, it creates a new program state using the `getInitialState` method and transitions to the new state using `addTransition`. This example is also part of the Clang Static Analyzer library.