[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 03:25:31 PDT 2024
================
@@ -23,38 +25,35 @@ using namespace ento;
namespace {
class FixedAddressChecker
- : public Checker< check::PreStmt<BinaryOperator> > {
+ : public Checker<check::PreStmt<BinaryOperator>, check::PreStmt<DeclStmt>,
+ check::PreStmt<CallExpr>> {
const BugType BT{this, "Use fixed address"};
+ void checkUseOfFixedAddress(QualType DstType, const Expr *SrcExpr,
+ CheckerContext &C) const;
+
public:
void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;
+ void checkPreStmt(const DeclStmt *D, CheckerContext &C) const;
+ void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
};
}
-void FixedAddressChecker::checkPreStmt(const BinaryOperator *B,
- CheckerContext &C) const {
- // Using a fixed address is not portable because that address will probably
- // not be valid in all environments or platforms.
-
- if (B->getOpcode() != BO_Assign)
- return;
-
- QualType T = B->getType();
- if (!T->isPointerType())
+void FixedAddressChecker::checkUseOfFixedAddress(QualType DstType,
+ const Expr *SrcExpr,
+ CheckerContext &C) const {
+ if (!DstType->isPointerType())
----------------
steakhal wrote:
Can the destination type be reference type?
https://github.com/llvm/llvm-project/pull/110977
More information about the cfe-commits
mailing list