[clang-tidy] New checker to replace dynamic exception specifications
Summary:
New checker to replace dynamic exception
specifications
This is an alternative to D18575 which relied on reparsing the decl to
find the location of dynamic exception specifications, but couldn't
deal with preprocessor conditionals correctly without reparsing the
entire file.
This approach uses D20428 to find dynamic exception specification
locations and handles all cases correctly.
Reviewers: aaron.ballman, alexfh
Reviewed By: aaron.ballman, alexfh
Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb
Patch by Don Hinton!
Differential Revision: https://reviews.llvm.org/D20693
llvm-svn: 304977
2017-06-08 22:04:16 +08:00
|
|
|
//===--- UseNoexceptCheck.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_MODERNIZE_USE_NOEXCEPT_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_NOEXCEPT_H
|
|
|
|
|
|
|
|
#include "../ClangTidy.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
namespace modernize {
|
|
|
|
|
|
|
|
/// \brief Replace dynamic exception specifications, with
|
|
|
|
/// `noexcept` (or user-defined macro) or `noexcept(false)`.
|
|
|
|
/// \code
|
|
|
|
/// void foo() throw();
|
|
|
|
/// void bar() throw(int);
|
|
|
|
/// \endcode
|
|
|
|
/// Is converted to:
|
|
|
|
/// \code
|
|
|
|
/// void foo() ;
|
2017-06-09 01:01:01 +08:00
|
|
|
/// void bar() noexcept(false);
|
[clang-tidy] New checker to replace dynamic exception specifications
Summary:
New checker to replace dynamic exception
specifications
This is an alternative to D18575 which relied on reparsing the decl to
find the location of dynamic exception specifications, but couldn't
deal with preprocessor conditionals correctly without reparsing the
entire file.
This approach uses D20428 to find dynamic exception specification
locations and handles all cases correctly.
Reviewers: aaron.ballman, alexfh
Reviewed By: aaron.ballman, alexfh
Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb
Patch by Don Hinton!
Differential Revision: https://reviews.llvm.org/D20693
llvm-svn: 304977
2017-06-08 22:04:16 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// For the user-facing documentation see:
|
|
|
|
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html
|
|
|
|
class UseNoexceptCheck : public ClangTidyCheck {
|
|
|
|
public:
|
|
|
|
UseNoexceptCheck(StringRef Name, ClangTidyContext *Context);
|
|
|
|
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string NoexceptMacro;
|
|
|
|
bool UseNoexceptFalse;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace modernize
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_NOEXCEPT_H
|