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

bugprone-standalone-empty false positive when returning the result #59517

Closed
firewave opened this issue Dec 14, 2022 · 3 comments
Closed

bugprone-standalone-empty false positive when returning the result #59517

firewave opened this issue Dec 14, 2022 · 3 comments
Labels
clang-tidy false-positive Warning fires when it should not

Comments

@firewave
Copy link

firewave commented Dec 14, 2022

#include <string>

struct A
{
    bool empty() const
    {
        return s.empty();
    }
    std::string s;
};
<source>:7:16: warning: ignoring the result of 'empty()' [bugprone-standalone-empty]
        return s.empty();
               ^

https://godbolt.org/z/v7rxqY1G7

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 14, 2022

@llvm/issue-subscribers-clang-tidy

@v1nh1shungry
Copy link
Contributor

Proposed fix: https://reviews.llvm.org/D141107

cjdb pushed a commit that referenced this issue Jan 13, 2023
…lone-empty

Relevant issue: #59517

Currently this check will warn when the result is used in a `return`
statement, e.g.

```
bool foobar() {
  std::vector<int> v;
  return v.empty();
  // will get a warning here, which makes no sense IMO
}
```

Reviewed By: cjdb, denik

Differential Revision: https://reviews.llvm.org/D141107
@cjdb
Copy link
Contributor

cjdb commented Jan 13, 2023

Fixed. Thanks @v1nh1shungry!

@cjdb cjdb closed this as completed Jan 13, 2023
CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Jan 13, 2023
…lone-empty

Relevant issue: llvm/llvm-project#59517

Currently this check will warn when the result is used in a `return`
statement, e.g.

```
bool foobar() {
  std::vector<int> v;
  return v.empty();
  // will get a warning here, which makes no sense IMO
}
```

Reviewed By: cjdb, denik

Differential Revision: https://reviews.llvm.org/D141107
malavikasamak pushed a commit to apple/llvm-project that referenced this issue Jan 24, 2023
…lone-empty

Relevant issue: llvm#59517

Currently this check will warn when the result is used in a `return`
statement, e.g.

```
bool foobar() {
  std::vector<int> v;
  return v.empty();
  // will get a warning here, which makes no sense IMO
}
```

Reviewed By: cjdb, denik

Differential Revision: https://reviews.llvm.org/D141107

(cherry picked from commit 7910ee7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

5 participants