blob: 3e5b0bb05b7687dcb8a2247f4aa1c27fcde29d8e [file] [log] [blame]
Alexander Kornienko3396a8b2015-05-22 10:31:17 +00001//===--- NoexceptMoveCtorsCheck.h - clang-tidy-------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
12
13#include "../ClangTidy.h"
14
15namespace clang {
16namespace tidy {
17
18/// \brief The check flags move constructors and assignment operators not marked
19/// with \c noexcept or marked with \c noexcept(expr) where \c expr evaluates to
20/// \c false (but is not a \c false literal itself).
21///
22/// Move constructors of all the types used with STL containers, for example,
23/// need to be declared \c noexcept. Otherwise STL will choose copy constructors
24/// instead. The same is valid for move assignment operations.
25class NoexceptMoveCtorsCheck : public ClangTidyCheck {
26public:
27 NoexceptMoveCtorsCheck(StringRef Name, ClangTidyContext *Context)
28 : ClangTidyCheck(Name, Context) {}
29 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
31};
32
33} // namespace tidy
34} // namespace clang
35
36#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
37