llvm / llvm-project

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

cert-dcl37-c / cert-dcl51-cpp aliases should probably also alias AllowedIdentifiers option #44246

Open seanm opened 4 years ago

seanm commented 4 years ago
Bugzilla Link 44901
Version unspecified
OS All

Extended Description

I currently suppress bugprone-reserved-identifier false positives by passing this clang-tidy flag:

-config="{CheckOptions: [{key: bugprone-reserved-identifier.AllowedIdentifiers, value: _BSD_SOURCE}]}"

That works.

Now the in-progress release notes for clang-tidy 11 say:

New alias cert-dcl37-c to bugprone-reserved-identifier was added.
New alias cert-dcl51-cpp to bugprone-reserved-identifier was added.

Trying now, I get cert-dcl37-c and cert-dcl51-cpp warnings.

Is one really expected to restate the option 3 times for the 3 aliases?

As in:

-config="{CheckOptions: [{key: bugprone-reserved-identifier.AllowedIdentifiers, value: _BSD_SOURCE}, {key: cert-dcl37-c.AllowedIdentifiers, value: _BSD_SOURCE}, {key: cert-dcl51-cpp.AllowedIdentifiers, value: _BSD_SOURCE}]}"

I tried, and it does work. But it would be nice if the options got aliased too.

llvmbot commented 4 years ago

Alias' in clang-tidy is a touchy subject.

You should probably disable the cert alias to the bugprone-reserved-identifier check to prevent it running 3 times.

Alias options would mean everytime an aliased check is ran multiple times the options would be the same, therefore you would get double diagnostics(and fix-its) for each issue. Some projects may also like to run checks multiple times with different options which would also break this.

Maybe a specific fix for this check could be having a global options named something like AllowedReservedIdentifiers which could then be read by each of the alias checks