-
Notifications
You must be signed in to change notification settings - Fork 349
[BoundsSafety] Allow using bounds-attributed types when deducing auto #11463
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
[BoundsSafety] Allow using bounds-attributed types when deducing auto #11463
Conversation
08b300d
to
c65fa57
Compare
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
Allow using bounds-attributed types when deducing auto type in attribute-only mode. Since the bounds-attributed type can depend on a variable in a different scope etc., we drop the bounds-attributed sugar and emit a warning. rdar://140995829
c65fa57
to
6b8f628
Compare
As discussed on slack, I removed support for inferring |
@swift-ci test llvm |
if (const auto *CATy = dyn_cast<CountAttributedType>(BATy)) { | ||
DesugaredTy = CATy->desugar(); | ||
Kind = CATy->getKind(); | ||
} else { |
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.
what about __null_terminated
?
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.
auto
will get __null_terminated
without any warnings/errors:
void foo(int *__null_terminated x) {
__auto_type p = x;
auto r = x;
}
FunctionDecl foo 'void (int * __terminated_by(0))'
|-ParmVarDecl used x 'int * __terminated_by(0)':'int *'
`-CompoundStmt
|-DeclStmt
| `-VarDecl p 'int * __terminated_by(0)':'int *' cinit
| `-ImplicitCastExpr 'int * __terminated_by(0)':'int *' <LValueToRValue>
| `-DeclRefExpr 'int * __terminated_by(0)':'int *' lvalue ParmVar 'x' 'int * __terminated_by(0)':'int *'
`-DeclStmt
`-VarDecl r 'int * __terminated_by(0)':'int *' cinit
`-ImplicitCastExpr 'int * __terminated_by(0)':'int *' <LValueToRValue>
`-DeclRefExpr 'int * __terminated_by(0)':'int *' lvalue ParmVar 'x' 'int * __terminated_by(0)':'int *'
Unrelated tests are failing. |
Allow using bounds-attributed types when deducing auto type in attribute-only mode. Since the bounds-attributed sugar would depend on a variable in a different scope etc, we drop the sugar and emit a warning.
rdar://140995829