microsoft / microsoft/vscode-cpptools
clang-tidy fix for cppcoreguidelines-pro-bounds-constant-array-index generates invalid code
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
With 1.10.1 (currently unreleased), using "C_Cpp.codeAnalysis.clangTidy.config": "{ Checks: 'cppcoreguidelines-pro-bounds-constant-array-index', CheckOptions: [{key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader, value: '<gsl/gsl.h>'}]}"
with code
#include <array>
int func(int i)
{
std::array<int, 2> vvv;
return vvv[i];
}
generates the incorrect code return gsl::at(v, i);.
It's already reported at https://github.com/llvm/llvm-project/issues/37858 .
Bug#2: There's another related bug at https://github.com/llvm/llvm-project/issues/55088 , when there's an #if/endif at the top of the file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the clang-tidy configuration and C++ example from the issue, then compare the generated fix with LLVM issues 37858 and 55088. Trace the code-analysis fix path in vscode-cpptools; done means the reported array-index cases no longer generate invalid code, including the variant with a leading #if/endif.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100