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

[clangd] Disable crashy unchecked-optional-access tidy check #69427

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

kadircet
Copy link
Member

@kadircet kadircet commented Oct 18, 2023

Fixes #69369.
Fixes clangd/clangd#1700.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 18, 2023

@llvm/pr-subscribers-clangd

Author: kadir çetinkaya (kadircet)

Changes

Fixes #69369.


Full diff: https://github.com/llvm/llvm-project/pull/69427.diff

1 Files Affected:

  • (modified) clang-tools-extra/clangd/TidyProvider.cpp (+3)
diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp
index f101199a20cebf9..2a6fba52e29bf43 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -219,6 +219,9 @@ TidyProvider disableUnusableChecks(llvm::ArrayRef<std::string> ExtraBadChecks) {
       "-bugprone-use-after-move",
       // Alias for bugprone-use-after-move.
       "-hicpp-invalid-access-moved",
+      // Check uses dataflow analysis, which might hang/crash unexpectedly on
+      // incomplete code.
+      "-bugprone-unchecked-optional-access",
 
       // ----- Performance problems -----
 

@@ -219,6 +219,9 @@ TidyProvider disableUnusableChecks(llvm::ArrayRef<std::string> ExtraBadChecks) {
"-bugprone-use-after-move",
// Alias for bugprone-use-after-move.
"-hicpp-invalid-access-moved",
// Check uses dataflow analysis, which might hang/crash unexpectedly on
// incomplete code.
"-bugprone-unchecked-optional-access",
Copy link
Collaborator

Choose a reason for hiding this comment

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

A consequence of putting the check here, is that a user who wants the check in spite of its bugginess does not have a way to enable it.

It was suggested, in clangd/clangd#1700 (comment) and clangd/clangd#1337 (comment), that we should have a way to allow users to override the disablements in this "bad checks" list. Could you weigh in on that proposal?

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW, we had this check enabled internally before it was upstream'd and experience on incomplete code has always been problematic. Hence I don't see much point in letting people run this on an incomplete AST. I believe the recommended workflow should be through running clang-tidy binary directly. I'll add some comments on those threads too.

Copy link
Collaborator

@HighCommander4 HighCommander4 Oct 19, 2023

Choose a reason for hiding this comment

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

Thanks. I commented in clangd/clangd#1337 (comment) about users maybe asking for an override in the future, but for now, avoiding the much more common case of users who don't care about this checker being burned by its brittleness is definitely the more pressing concern.

@kadircet
Copy link
Member Author

thanks for the pointers @HighCommander4 !

@kadircet kadircet merged commit e63ab13 into llvm:main Oct 19, 2023
4 checks passed
@HighCommander4
Copy link
Collaborator

This may be a good candidate for a 17.0.x backport.

@kadircet
Copy link
Member Author

yeah, initiated that (i think) already in #69568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants