diff options
| author | Angel Garcia Gomez <angelgarcia@google.com> | 2015-11-02 11:39:17 +0000 |
|---|---|---|
| committer | Angel Garcia Gomez <angelgarcia@google.com> | 2015-11-02 11:39:17 +0000 |
| commit | dd4ed3af98840c1a57a5594de00dd234cf157b77 (patch) | |
| tree | 7650ddc1383cc092a936445e9b1aa368188c6771 /clang-tools-extra/clang-tidy/modernize | |
| parent | 8286b83f97106fde561b28c7cb1fe7d5a479de6e (diff) | |
| download | bcm5719-llvm-dd4ed3af98840c1a57a5594de00dd234cf157b77.tar.gz bcm5719-llvm-dd4ed3af98840c1a57a5594de00dd234cf157b77.zip | |
Fix crash in redundant-void-arg check.
Summary:
When applying this check to the unit tests, it would hit an assertion:
llvm/tools/clang/lib/Lex/Lexer.cpp:1056: clang::SourceLocation clang::Lexer::getSourceLocation(const char*, unsigned int) const: Assertion `PP && "This doesn't work on raw lexers"' failed.
Reviewers: klimek, LegalizeAdulthood, alexfh
Subscribers: cfe-commits, alexfh
Differential Revision: http://reviews.llvm.org/D14204
llvm-svn: 251792
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize')
| -rw-r--r-- | clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp index 5de65e4d101..e86e8637a18 100644 --- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -47,8 +47,8 @@ namespace modernize { void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(functionDecl(isExpansionInMainFile(), parameterCountIs(0), - unless(isImplicit()), - unless(isExternC())).bind(FunctionId), + unless(isImplicit()), unless(isExternC())) + .bind(FunctionId), this); Finder->addMatcher(typedefDecl(isExpansionInMainFile()).bind(TypedefId), this); @@ -77,9 +77,10 @@ void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { cxxReinterpretCastExpr(isExpansionInMainFile(), CastDestinationIsFunction) .bind(NamedCastId), this); - Finder->addMatcher(cxxConstCastExpr(isExpansionInMainFile(), - CastDestinationIsFunction).bind(NamedCastId), - this); + Finder->addMatcher( + cxxConstCastExpr(isExpansionInMainFile(), CastDestinationIsFunction) + .bind(NamedCastId), + this); Finder->addMatcher(lambdaExpr(isExpansionInMainFile()).bind(LambdaId), this); } @@ -128,11 +129,14 @@ void RedundantVoidArgCheck::processFunctionDecl( void RedundantVoidArgCheck::removeVoidArgumentTokens( const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range, StringRef GrammarLocation) { - std::string DeclText = - Lexer::getSourceText(CharSourceRange::getTokenRange(Range), - *Result.SourceManager, - Result.Context->getLangOpts()).str(); - Lexer PrototypeLexer(Range.getBegin(), Result.Context->getLangOpts(), + 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()); enum TokenState { |

