This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix `readability-const-return-type` for pure virtual function.
ClosedPublic

Authored by Sockke on Dec 31 2021, 3:42 AM.

Details

Summary

It cannot match a pure virtual function. This patch fixes this behavior.

Diff Detail

Event Timeline

Sockke created this revision.Dec 31 2021, 3:42 AM
Sockke requested review of this revision.Dec 31 2021, 3:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 31 2021, 3:42 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko retitled this revision from Fix `readability-const-return-type` for pure virtual function. to [clang-tidy] Fix `readability-const-return-type` for pure virtual function..Dec 31 2021, 7:26 AM
MTC added subscribers: flx, MTC.Jan 7 2022, 2:06 AM

FYI: I'm from Bytedance Inc, @Sockke, and I are fixing the AutoFix bugs recently, most of them will lead to the compilation error. For this bug, fixing the override virtual methods but missing the pure virtual base method, which will cause the compilation error. These annoying bugs will hinder the large-scale deployment of clang-tidy AutoFix in the production environment.

clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
101

Like @flx comments in https://reviews.llvm.org/D116593, the better choice is that we suppress the fix for the virtual method. What do you think @Sockke?

aaron.ballman added inline comments.Jan 14 2022, 6:49 AM
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
101

I agree that the fix needs to be suppressed here as well, for the same reasons as the quoted review. e.g., https://godbolt.org/z/Yvsb37Yzr

Sockke updated this revision to Diff 411372.Feb 25 2022, 3:34 AM

Removed the fix for the virtual function.

aaron.ballman accepted this revision.Feb 25 2022, 4:08 AM

LGTM aside from a nit; can you also add a release note about the fix to clang-tools-extra/docs/ReleaseNotes.rst?

clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
122
This revision is now accepted and ready to land.Feb 25 2022, 4:08 AM
Sockke updated this revision to Diff 411722.Feb 27 2022, 7:01 PM

Added a release note.

Sockke updated this revision to Diff 412056.Mar 1 2022, 4:51 AM
This revision was landed with ongoing or failed builds.Mar 1 2022, 4:59 AM
This revision was automatically updated to reflect the committed changes.