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

//=- NSErrorChecker.cpp - Coding conventions for uses of NSError -*- 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 file defines a CheckNSError, a flow-insensitive check
//  that determines if an Objective-C class interface correctly returns
//  a non-void return type.
//
//  File under feature request PR 2600.
//
//===----------------------------------------------------------------------===//

#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

usingnamespaceclang;
usingnamespaceento;

static bool IsNSError(QualType T, IdentifierInfo *II);
static bool IsCFError(QualType T, IdentifierInfo *II);

//===----------------------------------------------------------------------===//
// NSErrorMethodChecker
//===----------------------------------------------------------------------===//

namespace {
class NSErrorMethodChecker
    : public Checker< check::ASTDecl<ObjCMethodDecl> > {};
}

void NSErrorMethodChecker::checkASTDecl(const ObjCMethodDecl *D,
                                        AnalysisManager &mgr,
                                        BugReporter &BR) const {}

//===----------------------------------------------------------------------===//
// CFErrorFunctionChecker
//===----------------------------------------------------------------------===//

namespace {
class CFErrorFunctionChecker
    : public Checker< check::ASTDecl<FunctionDecl> > {};
}

static bool hasReservedReturnType(const FunctionDecl *D) {}

void CFErrorFunctionChecker::checkASTDecl(const FunctionDecl *D,
                                        AnalysisManager &mgr,
                                        BugReporter &BR) const {}

//===----------------------------------------------------------------------===//
// NSOrCFErrorDerefChecker
//===----------------------------------------------------------------------===//

namespace {

class NSErrorDerefBug : public BugType {};

class CFErrorDerefBug : public BugType {};

}

namespace {
class NSOrCFErrorDerefChecker
    : public Checker< check::Location,
                        check::Event<ImplicitNullDerefEvent> > {};
}

ErrorOutFlag;
REGISTER_TRAIT_WITH_PROGRAMSTATE()
REGISTER_TRAIT_WITH_PROGRAMSTATE()

template <typename T>
static bool hasFlag(SVal val, ProgramStateRef state) {}

template <typename T>
static void setFlag(ProgramStateRef state, SVal val, CheckerContext &C) {}

static QualType parameterTypeFromSVal(SVal val, CheckerContext &C) {}

void NSOrCFErrorDerefChecker::checkLocation(SVal loc, bool isLoad,
                                            const Stmt *S,
                                            CheckerContext &C) const {}

void NSOrCFErrorDerefChecker::checkEvent(ImplicitNullDerefEvent event) const {}

static bool IsNSError(QualType T, IdentifierInfo *II) {}

static bool IsCFError(QualType T, IdentifierInfo *II) {}

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

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

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

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

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

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