clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
mpi
BufferDerefCheck.h
Go to the documentation of this file.
1
//===--- BufferDerefCheck.h - clang-tidy-------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H
11
12
#include "../ClangTidyCheck.h"
13
#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
14
#include <optional>
15
16
namespace
clang::tidy::mpi
{
17
18
/// This check verifies if a buffer passed to an MPI (Message Passing Interface)
19
/// function is sufficiently dereferenced. Buffers should be passed as a single
20
/// pointer or array. As MPI function signatures specify void * for their buffer
21
/// types, insufficiently dereferenced buffers can be passed, like for example
22
/// as double pointers or multidimensional arrays, without a compiler warning
23
/// emitted.
24
///
25
/// For the user-facing documentation see:
26
/// http://clang.llvm.org/extra/clang-tidy/checks/mpi/buffer-deref.html
27
class
BufferDerefCheck
:
public
ClangTidyCheck
{
28
public
:
29
BufferDerefCheck
(StringRef
Name
,
ClangTidyContext
*Context)
30
:
ClangTidyCheck
(
Name
, Context) {}
31
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
32
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
33
void
onEndOfTranslationUnit
()
override
;
34
35
private
:
36
/// Checks for all buffers in an MPI call if they are sufficiently
37
/// dereferenced.
38
///
39
/// \param BufferTypes buffer types
40
/// \param BufferExprs buffer arguments as expressions
41
void
checkBuffers(ArrayRef<const Type *> BufferTypes,
42
ArrayRef<const Expr *> BufferExprs);
43
44
enum class
IndirectionType :
unsigned
char
{ Pointer, Array };
45
46
std::optional<ento::mpi::MPIFunctionClassifier> FuncClassifier;
47
};
48
49
}
// namespace clang::tidy::mpi
50
51
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::mpi::BufferDerefCheck
This check verifies if a buffer passed to an MPI (Message Passing Interface) function is sufficiently...
Definition:
BufferDerefCheck.h:27
clang::tidy::mpi::BufferDerefCheck::BufferDerefCheck
BufferDerefCheck(StringRef Name, ClangTidyContext *Context)
Definition:
BufferDerefCheck.h:29
clang::tidy::mpi::BufferDerefCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
BufferDerefCheck.cpp:22
clang::tidy::mpi::BufferDerefCheck::onEndOfTranslationUnit
void onEndOfTranslationUnit() override
Definition:
BufferDerefCheck.cpp:128
clang::tidy::mpi::BufferDerefCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
BufferDerefCheck.cpp:18
clang::tidy::mpi
Definition:
BufferDerefCheck.cpp:16
Generated on Thu Nov 21 2024 14:01:06 for clang-tools by
1.9.6