This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] modernize-avoid-bind: Fix crash when method name is not a simple identifier
ClosedPublic

Authored by jspam on May 19 2022, 12:03 AM.

Details

Summary

The following assertion fails when referencing an operator member:

include/clang/AST/Decl.h:275: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed.

Additionally, use the call syntax instead of "operator()" and fix
missing "return" keyword.

Diff Detail

Event Timeline

jspam created this revision.May 19 2022, 12:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2022, 12:03 AM
jspam requested review of this revision.May 19 2022, 12:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2022, 12:03 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
njames93 added inline comments.
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
367

Fixing a crash is good, but these fixes leave a lot to be desired. If you could handle the cases when the name is an operator call by actually using the operator it would be be a lot nicer.

auto EEE = [d] { d(1, 2); };

This definitely could be done in a follow up commit.

jspam updated this revision to Diff 438265.Jun 20 2022, 12:06 AM

Improve fixes

As suggested by njames93, use call syntax instead of operator().

jspam edited the summary of this revision. (Show Details)Jun 20 2022, 12:07 AM
PiotrZSL accepted this revision.Nov 10 2023, 8:32 AM
PiotrZSL added a subscriber: PiotrZSL.

Crash no longer happens on main, but this change introduce nice fix for operators handling.

This revision is now accepted and ready to land.Nov 10 2023, 8:32 AM