llvm / llvm/llvm-project

[clang-tidy] Disable analysis for broken TU by default

Open
#196,733 4 comments 5 reactions 1 assignee Claimed by @vbvictor View on GitHub
clang-tidy enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Currently, clang-tidy will still run check even with `clang-diagnostic-error`'s.
This error means that TU doesn't have complete AST (some part can be missing or some nodes are converted to `RecoveryExpr`).

I propose we should disable analysis for TU that have broken AST because it may:

1. crash clang-tidy
2. provide misleading diagnostics from checks

In our docs we already state that we don't really support analysis with `clang-diagnostic-errors`:

> Clang compiler errors (such as syntax errors, semantic errors, or other failures that prevent Clang from compiling the code) are reported with the check name clang-diagnostic-error. These represent fundamental compilation failures that must be fixed before clang-tidy can perform its analysis. Unlike other diagnostics, clang-diagnostic-error cannot be disabled, as clang-tidy requires valid code to function.

Main part: "clang-tidy requires valid code to function"

We can have a new flag to allow analysis on broken TU for backward-comparability.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.