llvm/clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp

// MallocSizeofChecker.cpp - Check for dubious malloc arguments ---*- C++ -*-=//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Reports inconsistencies between the casted type of the return value of a
// malloc/calloc/realloc call and the operand of any sizeof expressions
// contained within its argument(s).
//
//===----------------------------------------------------------------------===//

#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeLoc.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/raw_ostream.h"

usingnamespaceclang;
usingnamespaceento;

namespace {

TypeCallPair;
ExprParent;

class CastedAllocFinder
  : public ConstStmtVisitor<CastedAllocFinder, TypeCallPair> {};

class SizeofFinder : public ConstStmtVisitor<SizeofFinder> {};

// Determine if the pointee and sizeof types are compatible.  Here
// we ignore constness of pointer types.
static bool typesCompatible(ASTContext &C, QualType A, QualType B) {}

static bool compatibleWithArrayType(ASTContext &C, QualType PT, QualType T) {}

class MallocSizeofChecker : public Checker<check::ASTCodeBody> {};

}

void ento::registerMallocSizeofChecker(CheckerManager &mgr) {}

bool ento::shouldRegisterMallocSizeofChecker(const CheckerManager &mgr) {}