diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2015-09-30 14:09:38 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2015-09-30 14:09:38 +0000 |
| commit | 8db15e4a4d758ed0c2ceb17f9c0b4911f1a9221b (patch) | |
| tree | 265931fd4d2f3b4a31261dd4f1a5009342443615 /clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h | |
| parent | bcea69669f3a2c0aa250274c4ccb823d24ee1f12 (diff) | |
| download | bcm5719-llvm-8db15e4a4d758ed0c2ceb17f9c0b4911f1a9221b.tar.gz bcm5719-llvm-8db15e4a4d758ed0c2ceb17f9c0b4911f1a9221b.zip | |
Adding a checker (misc-non-copyable-objects) that detects situations where a non-copyable C type is being dereferenced, such as FILE or pthread_mutex_t. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object
llvm-svn: 248907
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h')
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h b/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h new file mode 100644 index 00000000000..c812e50037a --- /dev/null +++ b/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h @@ -0,0 +1,31 @@ +//===--- NonCopyableObjects.h - clang-tidy-----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// The check flags dereferences and non-pointer declarations of objects that +/// are not meant to be passed by value, such as C FILE objects. +class NonCopyableObjectsCheck : public ClangTidyCheck { +public: + NonCopyableObjectsCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H |

