| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_THROW_BY_VALUE_CATCH_BY_REFERENCE_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_THROW_BY_VALUE_CATCH_BY_REFERENCE_H |
| 11 |
|
| 12 |
#include "../ClangTidyCheck.h" |
| 13 |
|
| 14 |
namespace clang::tidy::misc { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class ThrowByValueCatchByReferenceCheck : public ClangTidyCheck { |
| 28 |
public: |
| 29 |
ThrowByValueCatchByReferenceCheck(StringRef Name, ClangTidyContext *Context); |
| 30 |
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { |
| 31 |
return LangOpts.CPlusPlus; |
| 32 |
} |
| 33 |
void storeOptions(ClangTidyOptions::OptionMap &Opts) override; |
| 34 |
void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 35 |
void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 36 |
|
| 37 |
private: |
| 38 |
void diagnoseThrowLocations(const CXXThrowExpr *ThrowExpr); |
| 39 |
void diagnoseCatchLocations(const CXXCatchStmt *CatchStmt, |
| 40 |
ASTContext &Context); |
| 41 |
bool isFunctionParameter(const DeclRefExpr *DeclRefExpr); |
| 42 |
bool isCatchVariable(const DeclRefExpr *DeclRefExpr); |
| 43 |
bool isFunctionOrCatchVar(const DeclRefExpr *DeclRefExpr); |
| 44 |
const bool CheckAnonymousTemporaries; |
| 45 |
const bool WarnOnLargeObject; |
| 46 |
const uint64_t MaxSizeOptions; |
| 47 |
uint64_t MaxSize; |
| 48 |
}; |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
#endif |