[PATCH] D69745: [analyzer] Checker: check::BeginAnalysis

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 19:27:07 PDT 2019


Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Charusso added a parent revision: D69731: [analyzer] CheckerContext: Make the Preprocessor available.

This callback is called when the analysis starts. It could be used to
construct the fields of the checker. Here is an example:

  void CoolFuncChecker::checkBeginAnalysis(CheckerContext &C) const {
    CheckerManager &Mgr = C.getCheckerManager();
  
    CheckCoolFunctions = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
        this, "WantToCheckCoolFunctions");
  
    BT = std::make_unique<BugType>(Mgr.getCurrentCheckerName(),
                                   "Cool function call", categories::TooCool);
  
    Preprocessor &PP = C.getPreprocessor();
    UseMyCoolLib = PP.isMacroDefined("__MY_COOL_LIB__");
  }


Repository:
  rC Clang

https://reviews.llvm.org/D69745

Files:
  clang/include/clang/StaticAnalyzer/Core/Checker.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/traversal-begin-end-function.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69745.227560.patch
Type: text/x-patch
Size: 11785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191102/bf703d16/attachment.bin>


More information about the cfe-commits mailing list