CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
clangcms::FiniteMathChecker Class Reference

#include <FiniteMathChecker.h>

Inheritance diagram for clangcms::FiniteMathChecker:

Public Member Functions

void checkPreStmt (const clang::CallExpr *ref, clang::ento::CheckerContext &C) const
 

Private Attributes

std::unique_ptr< clang::ento::BugType > BT
 

Detailed Description

Definition at line 11 of file FiniteMathChecker.h.

Member Function Documentation

void clangcms::FiniteMathChecker::checkPreStmt ( const clang::CallExpr *  ref,
clang::ento::CheckerContext &  C 
) const

Definition at line 15 of file FiniteMathChecker.cc.

References BT, eostools::move(), N, and edmIntegrityCheck::report.

16 {
17  const clang::ento::ProgramStateRef state = ctx.getState();
18  const clang::LocationContext *LC = ctx.getLocationContext();
19  const clang::Expr *Callee = CE->getCallee();
20  const clang::FunctionDecl *FD = state->getSVal(Callee, LC).getAsFunctionDecl();
21 
22  if (!FD)
23  return;
24 
25  // Get the name of the callee.
26  clang::IdentifierInfo *II = FD->getIdentifier();
27  if (!II) // if no identifier, not a simple C function
28  return;
29 
30  if (!II->isStr("isnan") && !II->isStr("isinf"))
31  return;
32 
33  clang::ento::ExplodedNode *N = ctx.generateErrorNode();
34  if (!N)
35  return;
36 
37  if (!BT)
38  BT.reset(new clang::ento::BugType(this,"std::isnan / std::isinf does not work when fast-math is used. Please use edm::isNotFinite from 'FWCore/Utilities/interface/isFinite.h'", "fastmath plugin"));
39 
40  std::unique_ptr<clang::ento::BugReport> report = llvm::make_unique<clang::ento::BugReport>(*BT, BT->getName(), N);
41  report->addRange(Callee->getSourceRange());
42  ctx.emitReport(std::move(report));
43 }
std::unique_ptr< clang::ento::BugType > BT
#define N
Definition: blowfish.cc:9
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::unique_ptr<clang::ento::BugType> clangcms::FiniteMathChecker::BT
mutableprivate

Definition at line 12 of file FiniteMathChecker.h.

Referenced by checkPreStmt().