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

◆ checkPreStmt()

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

Definition at line 14 of file FiniteMathChecker.cc.

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

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

Member Data Documentation

◆ BT

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

Definition at line 12 of file FiniteMathChecker.h.

Referenced by checkPreStmt().

clangcms::FiniteMathChecker::BT
std::unique_ptr< clang::ento::BugType > BT
Definition: FiniteMathChecker.h:12
N
#define N
Definition: blowfish.cc:9
edmIntegrityCheck.report
report
Definition: edmIntegrityCheck.py:349
eostools.move
def move(src, dest)
Definition: eostools.py:511