diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2016-09-24 02:13:45 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2016-09-24 02:13:45 +0000 |
commit | afad84c04b4a6a7ec2d5ac56cf9022e488f875bb (patch) | |
tree | cafef3310ddba5b0c76486a67acb748b4509ec5d /clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp | |
parent | 96cbe7b9a715a3515466492b9bb9df226f2ae095 (diff) | |
download | bcm5719-llvm-afad84c04b4a6a7ec2d5ac56cf9022e488f875bb.tar.gz bcm5719-llvm-afad84c04b4a6a7ec2d5ac56cf9022e488f875bb.zip |
[clang-tidy] Cleaning up language options.
Differential Revision: https://reviews.llvm.org/D24881
llvm-svn: 282319
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp index d81f156f954..6701fa45ced 100644 --- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -45,6 +45,9 @@ const char LambdaId[] = "lambda"; } // namespace void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus) + return; + Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()), unless(isExternC())) .bind(FunctionId), @@ -72,10 +75,6 @@ void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { } void RedundantVoidArgCheck::check(const MatchFinder::MatchResult &Result) { - if (!Result.Context->getLangOpts().CPlusPlus) { - return; - } - const BoundNodes &Nodes = Result.Nodes; if (const auto *Function = Nodes.getNodeAs<FunctionDecl>(FunctionId)) { processFunctionDecl(Result, Function); @@ -118,16 +117,15 @@ void RedundantVoidArgCheck::processFunctionDecl( void RedundantVoidArgCheck::removeVoidArgumentTokens( const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range, StringRef GrammarLocation) { - CharSourceRange CharRange = Lexer::makeFileCharRange( - CharSourceRange::getTokenRange(Range), *Result.SourceManager, - Result.Context->getLangOpts()); - - std::string DeclText = Lexer::getSourceText(CharRange, *Result.SourceManager, - Result.Context->getLangOpts()) - .str(); - Lexer PrototypeLexer(CharRange.getBegin(), Result.Context->getLangOpts(), - DeclText.data(), DeclText.data(), - DeclText.data() + DeclText.size()); + CharSourceRange CharRange = + Lexer::makeFileCharRange(CharSourceRange::getTokenRange(Range), + *Result.SourceManager, getLangOpts()); + + std::string DeclText = + Lexer::getSourceText(CharRange, *Result.SourceManager, getLangOpts()) + .str(); + Lexer PrototypeLexer(CharRange.getBegin(), getLangOpts(), DeclText.data(), + DeclText.data(), DeclText.data() + DeclText.size()); enum TokenState { NothingYet, SawLeftParen, |