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

[clang-tidy] bugprone-throw-keyword-missing false negatives from hasAncestor skipping too much #115540

Open
5chmidti opened this issue Nov 8, 2024 · 1 comment

Comments

@5chmidti
Copy link
Contributor

5chmidti commented Nov 8, 2024

The matcher is using hasAncestor and could be skipping many different issues, simply because they have an ancestor node (e.g., VarDecl) but that node is not closely related to the construct expression itself.

struct RegularException {
    RegularException(int);
};
void foo() {
    const auto var = []() {
        RegularException{0};  // FN, ignored because of `hasAncestor(varDecl())`
        return 0;
    };
}

struct Bar {
    Bar() : v{0} {
        RegularException{0};  // FN, ignored because of `hasAncestor(cxxConstructorDecl())`
    }
    int v;
};

https://godbolt.org/z/6br6f91vc

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 8, 2024

@llvm/issue-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)

The matcher is using `hasAncestor` and could be skipping many different issues, simply because they have an ancestor node (e.g., `VarDecl`) but that node is not closely related to the construct expression itself.
struct RegularException {
    RegularException(int);
};
void foo() {
    const auto var = []() {
        RegularException{0};  // FN, ignored because of `hasAncestor(varDecl())`
        return 0;
    };
}

struct Bar {
    Bar() : v{0} {
        RegularException{0};  // FN, ignored because of `hasAncestor(cxxConstructorDecl())`
    }
    int v;
};

https://godbolt.org/z/6br6f91vc

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

No branches or pull requests

2 participants