Page MenuHomePhabricator

Fix crash in redundant-void-arg check.
ClosedPublic

Authored by angelgarcia on Oct 30 2015, 8:41 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

angelgarcia retitled this revision from to Fix crash in redundant-void-arg check..
angelgarcia updated this object.
angelgarcia added subscribers: alexfh, cfe-commits.
alexfh added inline comments.Oct 30 2015, 9:33 AM
clang-tidy/modernize/RedundantVoidArgCheck.cpp
131 ↗(On Diff #38815)

What happens if instead you pass the range through Lexer::makeFileCharRange? This might be a way to enable fixes at least in some trivial cases involving macros.

angelgarcia updated this revision to Diff 38887.Nov 2 2015, 3:07 AM

Use Lexer::makeFileCharRange (and a few changes due to clang-format).

It seems to work as well.

alexfh added a comment.Nov 2 2015, 3:22 AM

Use Lexer::makeFileCharRange (and a few changes due to clang-format).

It seems to work as well.

Can you add a test where a void argument is removed in a macro (which would be the whole point of using the makeFileCharRange instead of just bailing out on all macros)?

E.g. does this work in a simple case like this one?

#define M(x) x
M(void f(void) {})
// CHECK-FIXES: M(void f() {})
angelgarcia updated this revision to Diff 38889.Nov 2 2015, 3:29 AM

Sorry, I forgot. That case works just fine.

alexfh accepted this revision.Nov 2 2015, 3:34 AM
alexfh added a reviewer: alexfh.

Thanks! Looks good!

This revision is now accepted and ready to land.Nov 2 2015, 3:34 AM
angelgarcia closed this revision.Nov 2 2015, 3:41 AM
This revision was automatically updated to reflect the committed changes.