clang-tidy: add check for non-trivial thread_local vars
Do not allow thread_local vars with non-trivial destructors
This commit is contained in:
1 parent
a786fd2041
commit
34c9cee380
5 files changed
+79
-2
No files matched your search
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2023 Bitcoin Developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef NONTRIVIAL_THREADLOCAL_CHECK_H
|
||||
#define NONTRIVIAL_THREADLOCAL_CHECK_H
|
||||
|
||||
#include <clang-tidy/ClangTidyCheck.h>
|
||||
|
||||
namespace bitcoin {
|
||||
|
||||
// Warn about any thread_local variable with a non-trivial destructor.
|
||||
class NonTrivialThreadLocal final : public clang::tidy::ClangTidyCheck
|
||||
{
|
||||
public:
|
||||
NonTrivialThreadLocal(clang::StringRef Name, clang::tidy::ClangTidyContext* Context)
|
||||
: clang::tidy::ClangTidyCheck(Name, Context) {}
|
||||
|
||||
bool isLanguageVersionSupported(const clang::LangOptions& LangOpts) const override
|
||||
{
|
||||
return LangOpts.CPlusPlus;
|
||||
}
|
||||
void registerMatchers(clang::ast_matchers::MatchFinder* Finder) override;
|
||||
void check(const clang::ast_matchers::MatchFinder::MatchResult& Result) override;
|
||||
};
|
||||
|
||||
} // namespace bitcoin
|
||||
|
||||
#endif // NONTRIVIAL_THREADLOCAL_CHECK_H
|
||||
Reference in new issue
Block a user