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

//=== LLVMConventionsChecker.cpp - Check LLVM codebase conventions ---*- 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
//
//===----------------------------------------------------------------------===//
//
// This defines LLVMConventionsChecker, a bunch of small little checks
// for checking specific coding conventions in the LLVM/Clang codebase.
//
//===----------------------------------------------------------------------===//

#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"

usingnamespaceclang;
usingnamespaceento;

//===----------------------------------------------------------------------===//
// Generic type checking routines.
//===----------------------------------------------------------------------===//

static bool IsLLVMStringRef(QualType T) {}

/// Check whether the declaration is semantically inside the top-level
/// namespace named by ns.
static bool InNamespace(const Decl *D, StringRef NS) {}

static bool IsStdString(QualType T) {}

static bool IsClangType(const RecordDecl *RD) {}

static bool IsClangDecl(const RecordDecl *RD) {}

static bool IsClangStmt(const RecordDecl *RD) {}

static bool IsClangAttr(const RecordDecl *RD) {}

static bool IsStdVector(QualType T) {}

static bool IsSmallVector(QualType T) {}

//===----------------------------------------------------------------------===//
// CHECK: a StringRef should not be bound to a temporary std::string whose
// lifetime is shorter than the StringRef's.
//===----------------------------------------------------------------------===//

namespace {
class StringRefCheckerVisitor : public StmtVisitor<StringRefCheckerVisitor> {};
} // end anonymous namespace

static void CheckStringRefAssignedTemporary(const Decl *D, BugReporter &BR,
                                            const CheckerBase *Checker) {}

void StringRefCheckerVisitor::VisitDeclStmt(DeclStmt *S) {}

void StringRefCheckerVisitor::VisitVarDecl(VarDecl *VD) {}

//===----------------------------------------------------------------------===//
// CHECK: Clang AST nodes should not have fields that can allocate
//   memory.
//===----------------------------------------------------------------------===//

static bool AllocatesMemory(QualType T) {}

// This type checking could be sped up via dynamic programming.
static bool IsPartOfAST(const CXXRecordDecl *R) {}

namespace {
class ASTFieldVisitor {};
} // end anonymous namespace

static void CheckASTMemory(const CXXRecordDecl *R, BugReporter &BR,
                           const CheckerBase *Checker) {}

void ASTFieldVisitor::Visit(FieldDecl *D) {}

void ASTFieldVisitor::ReportError(QualType T) {}

//===----------------------------------------------------------------------===//
// LLVMConventionsChecker
//===----------------------------------------------------------------------===//

namespace {
class LLVMConventionsChecker : public Checker<
                                                check::ASTDecl<CXXRecordDecl>,
                                                check::ASTCodeBody > {};
}

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

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