aspect-build / aspect-build/rules_lint
[Bug]: clang-tidy: clang-diagnostic-macro-redefined is always warned
- Dominant language
- Starlark
- Stars
- 154
- Forks
- 125
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 20
Description
### What happened?
When checking `clang-diagnostic-macro-redefined` is enabled and either or both `defines` and `local_defines` are set in the target, the warning always appears, as the options passed to the compiler are duplicated with reduced double quotes.
For example, when we have the target "foo" as follows:
```py
cc_binary(
name = "foo",
local_defines = ["FOO=\\\"1\\\""],
)
```
The clang-tidy is called with the following arguments:
```console
/path/to/clang-tidy --fix foo.cpp -- -target x86_64-linux-gnu ... -DFOO="1" -DFOO=\"1\" ...
```
The arguments ends with the warning or error:
```
error: 'FOO' macro redefined [clang-diagnostic-macro-redefined,-warnings-as-errors]
```
### Version
Development (host) and target OS/architectures: Linux / Ubuntu 24.04 / x86_64
Output of `bazel --version`: 9.1.0
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: 2.6.0
Language(s) and/or frameworks involved: C++ / clang-tidy
### How to reproduce
```shell
```
### Any other information?
_No response_
Contributor guide
Research direction
Start by tracing the clang-tidy invocation when a target uses defines or local_defines, comparing how each macro argument is assembled and quoted. Reproduce the foo target example and verify that the generated command no longer passes duplicate macro definitions or emits clang-diagnostic-macro-redefined.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100