40 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNINTENDEDCHAROSTREAMOUTPUTCHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNINTENDEDCHAROSTREAMOUTPUTCHECK_H11 12#include "../ClangTidyCheck.h"13#include <optional>14 15namespace clang::tidy::bugprone {16 17/// Finds unintended character output from `unsigned char` and `signed char` to18/// an ostream.19///20/// For the user-facing documentation see:21/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unintended-char-ostream-output.html22class UnintendedCharOstreamOutputCheck : public ClangTidyCheck {23public:24 UnintendedCharOstreamOutputCheck(StringRef Name, ClangTidyContext *Context);25 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;26 void registerMatchers(ast_matchers::MatchFinder *Finder) override;27 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;28 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {29 return LangOpts.CPlusPlus;30 }31 32private:33 const std::vector<StringRef> AllowedTypes;34 const std::optional<StringRef> CastTypeName;35};36 37} // namespace clang::tidy::bugprone38 39#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNINTENDEDCHAROSTREAMOUTPUTCHECK_H40