angelgarcia created this revision. angelgarcia added reviewers: klimek, LegalizeAdulthood. angelgarcia added subscribers: alexfh, cfe-commits.
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. http://reviews.llvm.org/D14204 Files: clang-tidy/modernize/RedundantVoidArgCheck.cpp test/clang-tidy/modernize-redundant-void-arg.cpp Index: test/clang-tidy/modernize-redundant-void-arg.cpp =================================================================== --- test/clang-tidy/modernize-redundant-void-arg.cpp +++ test/clang-tidy/modernize-redundant-void-arg.cpp @@ -417,3 +417,13 @@ // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression // CHECK-FIXES: {{^ }}auto void_returner = []() -> void (*)() { return f1; };{{$}} } + +#define F(A, B) \ + struct F_##A##_##B { \ + F_##A##_##B(void); \ + }; \ + F_##A##_##B::F_##A##_##B(void) + +F(Foo, Bar) { + +} Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp =================================================================== --- clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -128,6 +128,9 @@ void RedundantVoidArgCheck::removeVoidArgumentTokens( const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range, StringRef GrammarLocation) { + if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID()) + return; + std::string DeclText = Lexer::getSourceText(CharSourceRange::getTokenRange(Range), *Result.SourceManager,
Index: test/clang-tidy/modernize-redundant-void-arg.cpp =================================================================== --- test/clang-tidy/modernize-redundant-void-arg.cpp +++ test/clang-tidy/modernize-redundant-void-arg.cpp @@ -417,3 +417,13 @@ // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression // CHECK-FIXES: {{^ }}auto void_returner = []() -> void (*)() { return f1; };{{$}} } + +#define F(A, B) \ + struct F_##A##_##B { \ + F_##A##_##B(void); \ + }; \ + F_##A##_##B::F_##A##_##B(void) + +F(Foo, Bar) { + +} Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp =================================================================== --- clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -128,6 +128,9 @@ void RedundantVoidArgCheck::removeVoidArgumentTokens( const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range, StringRef GrammarLocation) { + if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID()) + return; + std::string DeclText = Lexer::getSourceText(CharSourceRange::getTokenRange(Range), *Result.SourceManager,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits