Skip to content

Conversation

@zeyi2
Copy link
Member

@zeyi2 zeyi2 commented Nov 29, 2025

Closes #156151
Assisted-by: Gemini 3 via Gemini CLI

@zeyi2 zeyi2 marked this pull request as draft November 29, 2025 17:08
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@zeyi2 zeyi2 force-pushed the open-unchecked-optional-access branch from 1b736ad to 11e86d6 Compare December 3, 2025 16:32
@zeyi2 zeyi2 marked this pull request as ready for review December 3, 2025 16:34
Comment on lines 98 to 100
assert(Scale && "Unknown scale encountered");
if (!Scale)
continue;
Copy link
Contributor

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)

Copy link
Contributor

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

Comment on lines -1347 to -1349
if (SK == SK_Invalid || !NamingStyles[SK])
if (SK == SK_Invalid)
return std::nullopt;

const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK];
Copy link
Contributor

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.

Copy link
Member Author

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..

@zeyi2
Copy link
Member Author

zeyi2 commented Dec 17, 2025

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
) it took 2305.9s to proceed clang-tools-extra/clang-tidy/utils/LexerUtils.cpp.

Also, I think clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp requires more than 1 hour to proceed...

The existing fixes can serve as a refactor. WDYT @vbvictor

@zeyi2 zeyi2 marked this pull request as ready for review December 17, 2025 10:33
WarningAsErrorFilter = std::make_unique<CachedGlobList>(
StringRef(getOptions().WarningsAsErrors.value_or("")));
static const std::vector<std::string> EmptyFileExtensions;
if (!parseFileExtensions(getOptions().HeaderFileExtensions
Copy link
Member Author

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.

@zeyi2
Copy link
Member Author

zeyi2 commented Dec 17, 2025

As of AI usage: 67bf385, 8f46670 and 9533351 uses Gemini 3 for code cleanup and pre-commit review. I've manually verified that these changes are reasonable.

@zeyi2 zeyi2 requested review from vbvictor and zwuis December 17, 2025 10:50
@zeyi2 zeyi2 changed the title [clang-tidy][NFC] Enable bugprone-unchecked-optional-access in clang-tidy config and fix warnings [clang-tidy][NFC] Fix bugprone-unchecked-optional-access warnings in codebase Dec 17, 2025
@vbvictor
Copy link
Contributor

vbvictor commented Dec 17, 2025

Sorry for the postponing, I'll restart working on this soon.

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.

Update: I'm not sure whether we should enable this check. On my PC (Intel(R) Core(TM) 7 250H (20) @ 5.40 GHz ) it took 2305.9s to proceed clang-tools-extra/clang-tidy/utils/LexerUtils.cpp.

Hmm, that is very unfortunate and strange. Did you use optimized build of clang-tidy (installed from apt-get or Release local build)? When I did initial run in #156149 (comment) with all checks enabled, I think it didn't run for very long (ryzen 9950x, 96GB ram). I will double-check later.

Lets keep it disabled for now.

@zeyi2
Copy link
Member Author

zeyi2 commented Dec 17, 2025

Did you use optimized build of clang-tidy (installed from apt-get or Release local build)?

I was using the one built from main branch:

$ ./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>&1

It is possible that this problem is because of my laptop..

I will double-check later.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[clang-tidy] Enable 'bugprone-unchecked-optional-access' check in clang-tidy config.

2 participants