CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
|
|
#include "clang/StaticAnalyzer/Core/Checker.h"
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
|
|
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
|
|
|
|
// This simple plugin is used by clang/test/Analysis/checker-plugins.c
|
|
// to test the use of a checker that is defined in a plugin.
|
|
|
|
using namespace clang;
|
|
using namespace ento;
|
|
|
|
namespace {
|
|
class MainCallChecker : public Checker<check::PreStmt<CallExpr>> {
|
|
|
|
const BugType BT{this, "call to main", "example analyzer plugin"};
|
|
|
|
public:
|
|
void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
|
|
};
|
|
} // end anonymous namespace
|
|
|
|
void MainCallChecker::checkPreStmt(const CallExpr *CE,
|
|
CheckerContext &C) const {
|
|
const Expr *Callee = CE->getCallee();
|
|
const FunctionDecl *FD = C.getSVal(Callee).getAsFunctionDecl();
|
|
|
|
if (!FD)
|
|
return;
|
|
|
|
// Get the name of the callee.
|
|
IdentifierInfo *II = FD->getIdentifier();
|
|
if (!II) // if no identifier, not a simple C function
|
|
return;
|
|
|
|
if (II->isStr("main")) {
|
|
ExplodedNode *N = C.generateErrorNode();
|
|
if (!N)
|
|
return;
|
|
|
|
auto report =
|
|
std::make_unique<PathSensitiveBugReport>(BT, BT.getDescription(), N);
|
|
report->addRange(Callee->getSourceRange());
|
|
C.emitReport(std::move(report));
|
|
}
|
|
}
|
|
|
|
// Register plugin!
|
|
extern "C" void clang_registerCheckers(CheckerRegistry &Registry) {
|
|
Registry.addChecker<MainCallChecker>("example.MainCallChecker",
|
|
"Example Description");
|
|
}
|
|
|
|
extern "C" const char clang_analyzerAPIVersionString[] =
|
|
CLANG_ANALYZER_API_VERSION_STRING;
|