Details
- Reviewers
aaron.ballman alexfh hokein
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
looking at this at least many are indeed valid results:
I guess false positives could be reduced by eliminating those cases where the variables are (intentionally) modified.
FIX-IT isn't quite that obvious. Some options:
- look for other typedef which contains the same as const
- create new typedef/using
- remove "*" from typedef and adjust all usage accordingly. Implies removing "Ptr" suffix.
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp | ||
---|---|---|
2 | is this good practice? I didn't want to duplicate everything here. | |
32 | not sure how to remove the regex here without duplicating everything |
clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp | ||
---|---|---|
64 | llvm_unreachable |
LGTM!
I think we can punt on the fixit for now as this is a good incremental improvement. Another possible option is to remove the const from the declaration using the typedef (there may be situations where you cannot add a new typedef or modify the existing one because the typedef is in a system header).
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp | ||
---|---|---|
2 | Yes, this is a good way to reduce duplication. | |
32 | I think the regex is reasonable enough. |
Thanks for the review!
Could someone commit this? As I can not.
Alexander Lanin <alex@lanin.de>
I've commit on your behalf in ecc7dae50c41bc8a129a158ecf0ae0270126505c. Sorry about the delay in committing and thank you for the patch!
I reverted in e3b15ed376f3753d2a4e16281f8230e4ffed41ba. @AlexanderLanin, do you mind taking a look?
Updated misc-misplaced-const.c to reflect new output and fixed one wrong col in misc-misplaced-const.cpp - I really do not understand how that happened.
Rebased and verified with check-clang-tools.
llvm_unreachable