llvm/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp

//===--- SignalHandlerCheck.cpp - clang-tidy ------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "SignalHandlerCheck.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/STLExtras.h"

// This is the minimal set of safe functions.
// https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers
constexpr llvm::StringLiteral MinimalConformingFunctions[] =;

// The POSIX-defined set of safe functions.
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03
// 'quick_exit' is added to the set additionally because it looks like the
// mentioned POSIX specification was not updated after 'quick_exit' appeared
// in the C11 standard.
// Also, we want to keep the "minimal set" a subset of the "POSIX set".
// The list is repeated in bugprone-signal-handler.rst and should be kept up to date.
constexpr llvm::StringLiteral POSIXConformingFunctions[] =;

usingnamespaceclang::ast_matchers;

namespace clang::tidy {

template <>
struct OptionEnumMapping<
    bugprone::SignalHandlerCheck::AsyncSafeFunctionSetKind> {};

namespace bugprone {

namespace {

/// Returns if a function is declared inside a system header.
/// These functions are considered to be "standard" (system-provided) library
/// functions.
bool isStandardFunction(const FunctionDecl *FD) {}

/// Check if a statement is "C++-only".
/// This includes all statements that have a class name with "CXX" prefix
/// and every other statement that is declared in file ExprCXX.h.
bool isCXXOnlyStmt(const Stmt *S) {}

/// Given a call graph node of a \p Caller function and a \p Callee that is
/// called from \p Caller, get a \c CallExpr of the corresponding function call.
/// It is unspecified which call is found if multiple calls exist, but the order
/// should be deterministic (depend only on the AST).
Expr *findCallExpr(const CallGraphNode *Caller, const CallGraphNode *Callee) {}

SourceRange getSourceRangeOfStmt(const Stmt *S, ASTContext &Ctx) {}

} // namespace

AST_MATCHER(FunctionDecl, isStandardFunction) {}

SignalHandlerCheck::SignalHandlerCheck(StringRef Name,
                                       ClangTidyContext *Context)
    :{}

void SignalHandlerCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {}

bool SignalHandlerCheck::isLanguageVersionSupported(
    const LangOptions &LangOpts) const {}

void SignalHandlerCheck::registerMatchers(MatchFinder *Finder) {}

void SignalHandlerCheck::check(const MatchFinder::MatchResult &Result) {}

bool SignalHandlerCheck::checkFunction(
    const FunctionDecl *FD, const Expr *CallOrRef,
    std::function<void(bool)> ChainReporter) {}

bool SignalHandlerCheck::checkFunctionCPP14(
    const FunctionDecl *FD, const Expr *CallOrRef,
    std::function<void(bool)> ChainReporter) {}

bool SignalHandlerCheck::isStandardFunctionAsyncSafe(
    const FunctionDecl *FD) const {}

void SignalHandlerCheck::reportHandlerChain(
    const llvm::df_iterator<clang::CallGraphNode *> &Itr,
    const DeclRefExpr *HandlerRef, bool SkipPathEnd) {}

} // namespace bugprone
} // namespace clang::tidy