Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Clang-Tidy's modernize-use-starts-ends-with #12718

Merged
merged 1 commit into from
Apr 20, 2024
Merged

Apply Clang-Tidy's modernize-use-starts-ends-with #12718

merged 1 commit into from
Apr 20, 2024

Conversation

nicovank
Copy link
Contributor

@nicovank nicovank commented Apr 19, 2024

I am currently working on some additions to this Clang-Tidy check, and running it on some C++ codebases to test my changes.

This should be safe as it seems Dolphin requires a C++ standard and/or a compiler version that will always have starts_with included. (In CMakeLists: C++23 for MSVC, GCC 10, Clang 12). Dolphin builds on my setup following changes.

python3 ~/llvm-project/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
    -clang-tidy-binary="~/llvm-project/build/bin/clang-tidy" \
    -clang-apply-replacements-binary="~/llvm-project/build/bin/clang-apply-replacements" \
    -checks="-*,modernize-use-starts-ends-with" \
    -header-filter=".*" \
    -fix -format

This improves readability. There's also a theoretical performance improvement replacing find(...) == 0 by compare(...) == 0 or starts_with(...), it's probably negligible.

@BhaaLseN
Copy link
Member

Is this fully automated, or did you modify things by hand? We normally put the curlies on the next line, and we use curlies whenever either condition or contents span over multiple lines; which should be enforced by clang-format (see the output of the lint builder)

@nicovank
Copy link
Contributor Author

This was automated, -format option is supposed to run clang-format after changes. I also noticed that, will re-run manually.

@nicovank
Copy link
Contributor Author

Should be fixed, not sure why it didn't work in the first place, a second clang-format run did the trick. I'll keep an eye on CI.

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reads a lot nicer that way, and clearly communicates intent. I like that :)

@nicovank
Copy link
Contributor Author

Thanks! I have no commit access, please feel free to hit the merge button 👍 .

@AdmiralCurtiss AdmiralCurtiss merged commit 0e7346a into dolphin-emu:master Apr 20, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants