diff options
| author | Miklos Vajna <vmiklos@vmiklos.hu> | 2018-10-21 19:16:25 +0000 |
|---|---|---|
| committer | Miklos Vajna <vmiklos@vmiklos.hu> | 2018-10-21 19:16:25 +0000 |
| commit | e967a12733565fff0beb16865bd21e381b75b250 (patch) | |
| tree | 07156e641bab1e93ceda8f59e80c709dd42f2931 /clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp | |
| parent | ca8a05ac34b69559911a014c64fdbaa998c1da99 (diff) | |
| download | bcm5719-llvm-e967a12733565fff0beb16865bd21e381b75b250.tar.gz bcm5719-llvm-e967a12733565fff0beb16865bd21e381b75b250.zip | |
[clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-get
And also enable it by default to be consistent with e.g. modernize-use-using.
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: JonasToth
Differential Revision: https://reviews.llvm.org/D53454
llvm-svn: 344871
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp index b03b546fde0..189130efcae 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -91,6 +91,11 @@ void registerMatchersForGetEquals(MatchFinder *Finder, } // namespace +void RedundantSmartptrGetCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreMacros", IgnoreMacros); +} + void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. @@ -126,6 +131,9 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { bool IsPtrToPtr = Result.Nodes.getNodeAs<Decl>("ptr_to_ptr") != nullptr; bool IsMemberExpr = Result.Nodes.getNodeAs<Expr>("memberExpr") != nullptr; const auto *GetCall = Result.Nodes.getNodeAs<Expr>("redundant_get"); + if (GetCall->getBeginLoc().isMacroID() && IgnoreMacros) + return; + const auto *Smartptr = Result.Nodes.getNodeAs<Expr>("smart_pointer"); if (IsPtrToPtr && IsMemberExpr) { |

