Skip to content

Commit

Permalink
Merge pull request #27877 from cms-sw/backport-master-27663
Browse files Browse the repository at this point in the history
Update clang headers location and changed interfaces
  • Loading branch information
cmsbuild committed Aug 29, 2019
2 parents 5788410 + f88f67c commit 9588b32
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 29 deletions.
75 changes: 47 additions & 28 deletions Utilities/StaticAnalyzers/src/ClangCmsCheckerPluginRegister.cpp
Expand Up @@ -24,53 +24,72 @@
#include "ThrUnsafeFCallChecker.h"
#include "getParamDumper.h"

#include <clang/StaticAnalyzer/Core/CheckerRegistry.h>
#include <clang/StaticAnalyzer/Frontend/CheckerRegistry.h>

// register all custom checkers with clang
// add new entries here if you want to create a new checker
extern "C" void clang_registerCheckers(clang::ento::CheckerRegistry &registry) {
registry.addChecker<clangcms::ConstCastAwayChecker>(
"threadsafety.ConstCastAway",
"Checks for casts which remove const qualifier and might result in thread-unsafe code");
"Checks for casts which remove const qualifier and might result in thread-unsafe code",
"no docs");
registry.addChecker<clangcms::ConstCastChecker>(
"threadsafety.ConstCast", "Checks for casts which remove const qualifier and might result in thread-unsafe code");
"threadsafety.ConstCast",
"Checks for casts which remove const qualifier and might result in thread-unsafe code",
"no docs");
registry.addChecker<clangcms::TrunCastChecker>(
"optional.TruncatingCast",
"Checks for implicit casts where ToType is smaller than FromType which might result in truncation");
"Checks for implicit casts where ToType is smaller than FromType which might result in truncation",
"no docs");
registry.addChecker<clangcms::StaticLocalChecker>(
"threadsafety.StaticLocal", "Checks for non-const method local statics which might not be thread-safe");
"threadsafety.StaticLocal",
"Checks for non-const method local statics which might not be thread-safe",
"no docs");
registry.addChecker<clangcms::MutableMemberChecker>(
"threadsafety.MutableMember", "Checks for members with the mutable keyword which might not be thread-safe");
"threadsafety.MutableMember",
"Checks for members with the mutable keyword which might not be thread-safe",
"no docs");
registry.addChecker<clangcms::GlobalStaticChecker>(
"threadsafety.GlobalStatic", "Checks for global non-const statics which might not be thread-safe");
registry.addChecker<clangcms::ClassChecker>("optional.ClassChecker", "Checks data classes for thread safety issues");
"threadsafety.GlobalStatic", "Checks for global non-const statics which might not be thread-safe", "no docs");
registry.addChecker<clangcms::ClassChecker>(
"optional.ClassChecker", "Checks data classes for thread safety issues", "no docs");
registry.addChecker<clangcms::ClassDumperCT>("optional.ClassDumperCT",
"dumps template edm::Wrapper,edm::RunCache,edm::LuminosityBlockCache, "
"and edm::GlobalCache types which define data classes ");
registry.addChecker<clangcms::ClassDumperFT>("optional.ClassDumperFT",
"dumps macro TYPELOOKUP_DATA_REG types which define data classes");
registry.addChecker<clangcms::ClassDumperInherit>("optional.ClassDumperInherit",
"Dumps classes inheriting from data classes");
registry.addChecker<clangcms::ClassDumper>("optional.ClassDumper", "Dumps class memmbers and base classes ");
registry.addChecker<clangcms::FiniteMathChecker>("cms.NonFiniteMath", "Reports usage of isnan and isinf.");
registry.addChecker<clangcms::UsingNamespace>("cms.CodeRules.UsingNamespace",
"Checks for 'using namespace' or 'using std::' in header files");
registry.addChecker<clangcms::CatchAll>("cms.CodeRules.CatchAll", "Checks for 'catch(...)' in source files");
"and edm::GlobalCache types which define data classes ",
"no docs");
registry.addChecker<clangcms::ClassDumperFT>(
"optional.ClassDumperFT", "dumps macro TYPELOOKUP_DATA_REG types which define data classes", "no docs");
registry.addChecker<clangcms::ClassDumperInherit>(
"optional.ClassDumperInherit", "Dumps classes inheriting from data classes", "no docs");
registry.addChecker<clangcms::ClassDumper>(
"optional.ClassDumper", "Dumps class memmbers and base classes ", "no docs");
registry.addChecker<clangcms::FiniteMathChecker>("cms.NonFiniteMath", "Reports usage of isnan and isinf.", "no docs");
registry.addChecker<clangcms::UsingNamespace>(
"cms.CodeRules.UsingNamespace", "Checks for 'using namespace' or 'using std::' in header files", "no docs");
registry.addChecker<clangcms::CatchAll>(
"cms.CodeRules.CatchAll", "Checks for 'catch(...)' in source files", "no docs");
registry.addChecker<clangcms::edmChecker>(
"cms.edmChecker",
"Flags classes inheriting from edm::EDProducer,edm::EDFilter,edm::Analyzer or edm::OutputModule");
"Flags classes inheriting from edm::EDProducer,edm::EDFilter,edm::Analyzer or edm::OutputModule",
"no docs");
registry.addChecker<clangcms::getByChecker>(
"optional.getByChecker",
"Checks for calls to edm::getByLabel or edm::getManyByType and reports edm::Handle type passed");
registry.addChecker<clangcms::ArgSizeChecker>("optional.ArgSize", "Reports args passed by value with size>4k.");
registry.addChecker<clangcms::FunctionChecker>("cms.FunctionChecker",
"Reports functions which access non-const statics");
registry.addChecker<clangcms::FunctionDumper>("cms.FunctionDumper", "Reports function calls and overrides");
registry.addChecker<clangcms::EDMPluginDumper>("optional.EDMPluginDumper", "Dumps macro DEFINE_EDM_PLUGIN types");
registry.addChecker<clangcms::ThrUnsafeFCallChecker>("cms.ThrUnsafeFCallChecker",
"Reports calls of known thread unsafe functions");
"Checks for calls to edm::getByLabel or edm::getManyByType and reports edm::Handle type passed",
"no docs");
registry.addChecker<clangcms::ArgSizeChecker>(
"optional.ArgSize", "Reports args passed by value with size>4k.", "no docs");
registry.addChecker<clangcms::FunctionChecker>(
"cms.FunctionChecker", "Reports functions which access non-const statics", "no docs");
registry.addChecker<clangcms::FunctionDumper>(
"cms.FunctionDumper", "Reports function calls and overrides", "no docs");
registry.addChecker<clangcms::EDMPluginDumper>(
"optional.EDMPluginDumper", "Dumps macro DEFINE_EDM_PLUGIN types", "no docs");
registry.addChecker<clangcms::ThrUnsafeFCallChecker>(
"cms.ThrUnsafeFCallChecker", "Reports calls of known thread unsafe functions", "no docs");
registry.addChecker<clangcms::getParamDumper>(
"optional.getParamDumper", "Dumps out calls to edm::ParamaterSet:: getParameter and getUntrackedParameter");
"optional.getParamDumper",
"Dumps out calls to edm::ParamaterSet:: getParameter and getUntrackedParameter",
"no docs");
}

extern "C" const char clang_analyzerAPIVersionString[] = CLANG_ANALYZER_API_VERSION_STRING;
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/src/ClassChecker.cpp
Expand Up @@ -320,7 +320,7 @@ namespace clangcms {

void WalkAST::VisitDeclRefExpr(clang::DeclRefExpr *DRE) {
if (clang::VarDecl *D = llvm::dyn_cast_or_null<clang::VarDecl>(DRE->getDecl())) {
clang::SourceLocation SL = DRE->getLocStart();
clang::SourceLocation SL = DRE->getBeginLoc();
if (BR.getSourceManager().isInSystemHeader(SL) || BR.getSourceManager().isInExternCSystemHeader(SL))
return;
if (support::isSafeClassName(D->getCanonicalDecl()->getQualifiedNameAsString()))
Expand Down

0 comments on commit 9588b32

Please sign in to comment.