Author: angelgarcia Date: Mon Nov 2 10:18:23 2015 New Revision: 251807 URL: http://llvm.org/viewvc/llvm-project?rev=251807&view=rev Log: Fix another crash in the redundant-void-arg check.
Summary: The check was assuming that a definition of a function always has a body, but a declaration that explicitly defaults or deletes a function is a definition too. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14238 Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=251807&r1=251806&r2=251807&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Mon Nov 2 10:18:23 2015 @@ -116,9 +116,12 @@ void RedundantVoidArgCheck::processFunct const MatchFinder::MatchResult &Result, const FunctionDecl *Function) { SourceLocation Start = Function->getLocStart(); if (Function->isThisDeclarationADefinition()) { - SourceLocation BeforeBody = - Function->getBody()->getLocStart().getLocWithOffset(-1); - removeVoidArgumentTokens(Result, SourceRange(Start, BeforeBody), + SourceLocation End; + if (Function->hasBody()) + End = Function->getBody()->getLocStart().getLocWithOffset(-1); + else + End = Function->getLocEnd(); + removeVoidArgumentTokens(Result, SourceRange(Start, End), "function definition"); } else { removeVoidArgumentTokens(Result, Function->getSourceRange(), Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=251807&r1=251806&r2=251807&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Mon Nov 2 10:18:23 2015 @@ -433,3 +433,9 @@ M(void inmacro(void) {}) F(Foo, Bar) { } + +struct DefinitionWithNoBody { + DefinitionWithNoBody(void) = delete; + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition + // CHECK-FIXES: DefinitionWithNoBody() = delete; +}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits