llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.23k stars 11.66k forks source link

False positive clang-analyzer-alpha.unix.Stream for std::ifstream #27229

Open JVApen opened 8 years ago

JVApen commented 8 years ago
Bugzilla Link 26855
Version unspecified
OS Linux
Attachments Reproduction files
CC @EugeneZelenko,@AnnaZaks,@JVApen

Extended Description

In this reduced test-case, the check clang-analyzer-alpha.unix.Stream of clang-tidy is producing a false positive.

From my understanding, the std::ifstream class closes a file in its destructor (http://en.cppreference.com/w/cpp/io/basic_ifstream) Though this checker complains about potential resource leak (Opened File never closed.)

Full reproduction can be found in attachment. I've verified this bug with clang-tidy build against revision 262776 of trunk.

0f73b9cf-134f-41af-a8b1-14d9f305ee95 commented 8 years ago

A lot of the alpha static analyzer checks are not usable; some of them are checks that we are currently developing, some are known not to work due to limitations in the analyzer, some should be deleted.

Do you call clang to see the list of all checkers? Maybe we should not list them..

llvmbot commented 8 years ago

We don't list them by default. We only list them, when people ask to list all checks (clang-tidy -list-checks -checks=*). However, running all checks on any code is a bad idea anyway.

0f73b9cf-134f-41af-a8b1-14d9f305ee95 commented 8 years ago

Do you list them as available checkers? Most of them are not close to production quality.

llvmbot commented 8 years ago

Clang-tidy doesn't run alpha checkers by default, but they can be turned on, if the user wants to. I don't think we need to remove this possibility at all.

0f73b9cf-134f-41af-a8b1-14d9f305ee95 commented 8 years ago

Clang-tidy should not expose alpha checkers. They are not supported; a lot of them have known bugs.

JVApen commented 8 years ago

assigned to @tkremenek