[clang-tools-extra] [clang-tidy] Fix false positive in readability-redundant-preprocessor for builtin checks (PR #181734)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 11:57:06 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE LINT COMMENT: clang-tidy-->
:warning: C/C++ code linter, clang-tidy found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
```bash
git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py -path build -p1 -quiet
```
</details>
<details>
<summary>
View the output from clang-tidy here.
</summary>
```
clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp:43:5: warning: variable 'Condition' of type 'StringRef' can be declared 'const' [misc-const-correctness]
43 | StringRef Condition = getConditionText(Loc);
| ^
| const
clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp:81:5: warning: variable 'SpellingLoc' of type 'SourceLocation' can be declared 'const' [misc-const-correctness]
81 | SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
| ^
| const
clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp:83:5: warning: variable 'AfterIf' of type 'SourceLocation' can be declared 'const' [misc-const-correctness]
83 | SourceLocation AfterIf =
| ^
| const
clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp:90:5: warning: variable 'Buffer' of type 'StringRef' can be declared 'const' [misc-const-correctness]
90 | StringRef Buffer = SM.getBufferData(FID, &Invalid);
| ^
| const
clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp:97:7: warning: variable 'C' of type 'char' can be declared 'const' [misc-const-correctness]
97 | char C = Buffer[End];
| ^
| const
```
</details>
https://github.com/llvm/llvm-project/pull/181734
More information about the cfe-commits
mailing list