File indexing completed on 2026-05-10 08:36:20
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_THROW_BY_VALUE_CATCH_BY_REFERENCE_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_THROW_BY_VALUE_CATCH_BY_REFERENCE_H
0011
0012 #include "../ClangTidyCheck.h"
0013
0014 namespace clang::tidy::misc {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 class ThrowByValueCatchByReferenceCheck : public ClangTidyCheck {
0028 public:
0029 ThrowByValueCatchByReferenceCheck(StringRef Name, ClangTidyContext *Context);
0030 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0031 return LangOpts.CPlusPlus;
0032 }
0033 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0034 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0035 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0036
0037 private:
0038 void diagnoseThrowLocations(const CXXThrowExpr *ThrowExpr);
0039 void diagnoseCatchLocations(const CXXCatchStmt *CatchStmt,
0040 ASTContext &Context);
0041 bool isFunctionParameter(const DeclRefExpr *DeclRefExpr);
0042 bool isCatchVariable(const DeclRefExpr *DeclRefExpr);
0043 bool isFunctionOrCatchVar(const DeclRefExpr *DeclRefExpr);
0044 const bool CheckAnonymousTemporaries;
0045 const bool WarnOnLargeObject;
0046 const uint64_t MaxSizeOptions;
0047 uint64_t MaxSize;
0048 };
0049
0050 }
0051
0052 #endif