blob: 90d812296f359bed07fd988147c73ea4fe961fbd [file] [log] [blame]
Etienne Bergeron1f696b32016-04-15 16:36:00 +00001//===--- SizeofExpressionCheck.h - clang-tidy--------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Etienne Bergeron1f696b32016-04-15 16:36:00 +00006//
7//===----------------------------------------------------------------------===//
8
Alexander Kornienko32738882018-03-15 08:26:19 +00009#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFEXPRESSIONCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFEXPRESSIONCHECK_H
Etienne Bergeron1f696b32016-04-15 16:36:00 +000011
Alexander Kornienko478fc5c2019-03-25 12:38:26 +000012#include "../ClangTidyCheck.h"
Etienne Bergeron1f696b32016-04-15 16:36:00 +000013
14namespace clang {
15namespace tidy {
Alexander Kornienko32738882018-03-15 08:26:19 +000016namespace bugprone {
Etienne Bergeron1f696b32016-04-15 16:36:00 +000017
18/// Find suspicious usages of sizeof expression.
19///
20/// For the user-facing documentation see:
Alexander Kornienko32738882018-03-15 08:26:19 +000021/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html
Etienne Bergeron1f696b32016-04-15 16:36:00 +000022class SizeofExpressionCheck : public ClangTidyCheck {
23public:
24 SizeofExpressionCheck(StringRef Name, ClangTidyContext *Context);
Craig Topper11657c82016-04-16 02:42:03 +000025 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
Etienne Bergeron1f696b32016-04-15 16:36:00 +000026 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
27 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
28
29private:
30 const bool WarnOnSizeOfConstant;
Haojian Wudc62da42018-04-03 15:10:24 +000031 const bool WarnOnSizeOfIntegerExpression;
Etienne Bergeron1f696b32016-04-15 16:36:00 +000032 const bool WarnOnSizeOfThis;
33 const bool WarnOnSizeOfCompareToConstant;
34};
35
Alexander Kornienko32738882018-03-15 08:26:19 +000036} // namespace bugprone
Etienne Bergeron1f696b32016-04-15 16:36:00 +000037} // namespace tidy
38} // namespace clang
39
Alexander Kornienko32738882018-03-15 08:26:19 +000040#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFEXPRESSIONCHECK_H