UseNoexceptCheck.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===--- UseNoexceptCheck.h - clang-tidy-------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_NOEXCEPT_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_NOEXCEPT_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::modernize {
  12. /// Replace dynamic exception specifications, with
  13. /// `noexcept` (or user-defined macro) or `noexcept(false)`.
  14. /// \code
  15. /// void foo() throw();
  16. /// void bar() throw(int);
  17. /// \endcode
  18. /// Is converted to:
  19. /// \code
  20. /// void foo() ;
  21. /// void bar() noexcept(false);
  22. /// \endcode
  23. ///
  24. /// For the user-facing documentation see:
  25. /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-noexcept.html
  26. class UseNoexceptCheck : public ClangTidyCheck {
  27. public:
  28. UseNoexceptCheck(StringRef Name, ClangTidyContext *Context);
  29. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  30. return LangOpts.CPlusPlus11;
  31. }
  32. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  33. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  34. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  35. private:
  36. const StringRef NoexceptMacro;
  37. const bool UseNoexceptFalse;
  38. };
  39. } // namespace clang::tidy::modernize
  40. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_NOEXCEPT_H