-
Notifications
You must be signed in to change notification settings - Fork 341
[Safe Buffers][BoundsSafety] Initial bounds attributes support for FAMs #10254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci test llvm |
Enable parsing and syntax-level checking of bound attributes in flexible array member declarations. (rdar://139293326)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Could you add these test cases?
class FAM_THIS_ARROW_ARROW {
T *tp;
int fam[__counted_by(this->tp->count)]; // expected-error{{arrow notation not allowed for struct member in count parameter}}
};
class FAM_THIS_ARROW_DOT {
T *t;
int fam[__counted_by(this->t.count)]; // dot-expressions in counted-by is ok for FAMs
};
class FAM_ARITHMETIC {
int count;
int offset;
int fam[__counted_by(count - offset)]; // ok
};
class FAM_THIS_PTR_ARITHMETIC {
int count;
int fam[__counted_by((this + 1)->count]; // error
};
class FAM_THIS_PTR_ARITHMETIC {
int count;
int fam[__counted_by(*this.count]; // error
};
1195d74
to
2d6d738
Compare
clang/lib/Sema/SemaType.cpp
Outdated
@@ -10904,7 +10911,7 @@ class CountArgChecker : public TreeTransform<CountArgChecker> { | |||
VD->getType(), VK_LValue); | |||
return DRE; | |||
} | |||
|
|||
BOUNDS_SAFETY_CHECK_FAM_OR_ARROW_FOR_MEMBER: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh an do we maybe want to extract this into a lambda or helper function instead of a goto label?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…Ms (#10254) Enable parsing and syntax-level checking of bound attributes in flexible array member declarations. (rdar://139293326)
Enable parsing and syntax-level checking of bound attributes in flexible array member declarations.
(rdar://139293326)