<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    For implementing your approach, i'd suggest something like that
    (untested!):<br>
    <br>
    void YourChecker::checkPreCall(const CallEvent &Call,
    CheckerContext &C) const {<br>
      const CallExpr *CE =
    dyn_cast_or_null<CallExpr>(Call.getOriginExpr());<br>
      if (!CE)<br>
        return;<br>
      // Find the parent statement of the call expression, which should
    be somewhere in the caller's body.<br>
      const Stmt *Parent = C.getLocationContext()-<font size="+1">></font>getCurrentStackFrame()->getParent()->getParentMap().getParent(CE);<br>
      if (!isa<CompoundStmt>(Parent)) // Return value not
    discarded?<br>
        return;<br>
      // Proceed with your checks.<br>
    }<br>
    <br>
    However, you might also consider the path-sensitive approach to
    finding discarded/unchecked return values. That is, if the return
    value was saved into a variable, it might have still been discarded,
    so a syntax-only check is not enough, you'd need to see how the
    value flows. For that, you'd need to subscribe to checkDeadSymbols,
    and see if upon the death of the symbol there are no range
    constraints on it; then, if the value was truly unchecked, you can
    throw the warning on the original call expression. But that's more
    complicated.<br>
  </body>
</html>