-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[clang-tidy][NFC] Fix bugprone-unchecked-optional-access warnings in codebase
#170004
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
base: main
Are you sure you want to change the base?
Conversation
…idyDiagnosticConsumer" This reverts commit 7f6239f.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
1b736ad to
11e86d6
Compare
| assert(Scale && "Unknown scale encountered"); | ||
| if (!Scale) | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we then remove first assert if we still check via if later? (but preserve comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels weird that dataflow framework didn't count it as "validation", could it be a FP?
Later, you used assert(BestConversion && "text"); for the same purpose of validation
| if (SK == SK_Invalid || !NamingStyles[SK]) | ||
| if (SK == SK_Invalid) | ||
| return std::nullopt; | ||
|
|
||
| const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So dataflow couldn't handle checking for multiple optional values in one go? Seems like FP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is actually a FP..
|
Sorry for the postponing, I'll restart working on this soon. Update: I'm not sure whether we should enable this check. On my PC (Intel(R) Core(TM) 7 250H (20) @ 5.40 GHz Also, I think The existing fixes can serve as a refactor. WDYT @vbvictor |
…btractionCheck" This reverts commit 4f0c342.
| WarningAsErrorFilter = std::make_unique<CachedGlobList>( | ||
| StringRef(getOptions().WarningsAsErrors.value_or(""))); | ||
| static const std::vector<std::string> EmptyFileExtensions; | ||
| if (!parseFileExtensions(getOptions().HeaderFileExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is required, rewriting this to:
if (!parseFileExtensions(getOptions().HeaderFileExtensions.value_or(EmptyFileExtensions),...
causes a test failures, same as the below one.
bugprone-unchecked-optional-access in clang-tidy config and fix warningsbugprone-unchecked-optional-access warnings in codebase
No problem, this is actually a good part of open source development when you don't have any deadlines:) So you can pause for as long as you want.
Hmm, that is very unfortunate and strange. Did you use Lets keep it disabled for now. |
I was using the one built from $ ./build/bin/clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 22.0.0git
Optimized build with assertions.The command I use is: python3 clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
-clang-tidy-binary=./build/bin/clang-tidy \
-checks='-*,bugprone-unchecked-optional-access' \
-p=./build \
clang-tools-extra/clang-tidy > clang_tidy_output.log 2>&1It is possible that this problem is because of my laptop..
Thanks! |
Closes #156151
Assisted-by: Gemini 3 via Gemini CLI