-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Open
[clang][BoundsSafety] Extend
-Wvla-potential-size-confusion for struct fields and bounds annotations#129783Feature
Copy link
Labels
clang:bounds-safetyIssue/PR relating to the experimental -fbounds-safety feature in ClangIssue/PR relating to the experimental -fbounds-safety feature in Clangclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
-Wvla-potential-size-confusion diagnoses when n references the file scope variable and not the parameter.
int n;
void func(int array[n], int n);
We may want to extend it to diagnose on situations mentioned in the PR:
- Diagnosing a similar situation in structures. e.g.,
int n;
struct S {
int n;
int array[sizeof(n)]; // Refers to outer n, not member n
};- Diagnosing with constant-size arrays (requires tracking the expression for the constant-size array in the
QualType) e.g.,
constexpr int n = 12;
void func(int array[n], int n);- Potentially, also diagnosing with any ambiguous situations with bounds annotations like below (with or without the
-fexperimental-late-parse-attributesflag:
constexpr int n;
struct foo {
int * ptr __counted_by(n);
int n;
};
Metadata
Metadata
Assignees
Labels
clang:bounds-safetyIssue/PR relating to the experimental -fbounds-safety feature in ClangIssue/PR relating to the experimental -fbounds-safety feature in Clangclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"