summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@vmiklos.hu>2018-10-13 07:58:05 +0000
committerMiklos Vajna <vmiklos@vmiklos.hu>2018-10-13 07:58:05 +0000
commitabfccc2cf69459efe189d31f330e4e8164a40ba5 (patch)
treeb76030ac6c1251c7823c401ea7656cdd2c339c05 /clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
parent162435e7b5e026b9f988c730bb6527683f6aa853 (diff)
downloadbcm5719-llvm-abfccc2cf69459efe189d31f330e4e8164a40ba5.tar.gz
bcm5719-llvm-abfccc2cf69459efe189d31f330e4e8164a40ba5.zip
[clang-tidy] add IgnoreMacros option to modernize-use-equals-delete
And also enable it by default to be consistent with e.g. modernize-use-using. This improves consistency inside the check itself as well: both checks are now disabled in macros by default. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D53217 llvm-svn: 344440
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
index f5adb13f555..fc8425d9439 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -21,6 +21,10 @@ namespace modernize {
static const char SpecialFunction[] = "SpecialFunction";
static const char DeletedNotPublic[] = "DeletedNotPublic";
+void UseEqualsDeleteCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+ Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
@@ -57,6 +61,8 @@ void UseEqualsDeleteCheck::check(const MatchFinder::MatchResult &Result) {
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
+ if (Func->getLocation().isMacroID() && IgnoreMacros)
+ return;
// FIXME: Improve FixItHint to make the method public.
diag(Func->getLocation(),
"use '= delete' to prohibit calling of a special member function")
@@ -66,7 +72,7 @@ void UseEqualsDeleteCheck::check(const MatchFinder::MatchResult &Result) {
// Ignore this warning in macros, since it's extremely noisy in code using
// DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to
// automatically fix the warning when macros are in play.
- if (Func->getLocation().isMacroID())
+ if (Func->getLocation().isMacroID() && IgnoreMacros)
return;
// FIXME: Add FixItHint to make the method public.
diag(Func->getLocation(), "deleted member function should be public");
OpenPOWER on IntegriCloud