Conversation
We changed bounds cast expressions to take a bounds expression as the second argument, instead of implicitly inferring the type of bounds expression from the number of arguments. This is more verbose but clearer. Bounds cast expressions now have two forms: Op<T>(e1) Op<T>(e1, bounds-expression) where Op is one of _Assume_bounds_cast or _Dynamic_bounds_cast and T must be a pointer type. This change also improves the error messages and renames the error message names to be clearer. Testing: - There will be a corresponding Checked C repo change to tests for bounds cast expressions. - Add a test for error recovery from bounds cast expression syntax errors.
awruef
left a comment
There was a problem hiding this comment.
Looks good, just two comments about the same thing with GetTypeFromParser.
|
|
||
| QualType DestTy = GetTypeFromParser(D, &castTInfo); | ||
| SourceLocation TypeLoc = (castTInfo->getTypeLoc()).getBeginLoc(); | ||
| QualType DestTy = GetTypeFromParser(D, &CastTInfo); |
There was a problem hiding this comment.
I looked at the code for GetTypeFromParser and I think that either way, it will set CastTInfo to nullptr, so it's okay that it's declared un-initialized. Maybe there should be an assert before it's de-referenced, though?
There was a problem hiding this comment.
Good catch. We should check that CastTInfo is non-null and use a different source location if it is. I'll use the location of the '<' symbol given an expression of the form Op<T>(...), where Op is a bounds cast operator. It'll point the programmer in the right direction, although we could be off by any white space between the '<' and T.
| QualType DestTy = GetTypeFromParser(D, &castTInfo); | ||
| ExprResult ParsedBounds = CorrectDelayedTyposInExpr(bounds); | ||
| SourceLocation TypeLoc = (castTInfo->getTypeLoc()).getBeginLoc(); | ||
| QualType DestTy = GetTypeFromParser(D, &CastTInfo); |
There was a problem hiding this comment.
I looked at the code for GetTypeFromParser and I think that either way, it will set CastTInfo to nullptr, so it's okay that it's declared un-initialized. Maybe there should be an assert before it's de-referenced, though?
…dc#468) We changed bounds cast expressions to take a bounds expression as the second argument, instead of implicitly inferring the kind of bounds expression from the number of arguments. This is more verbose but clearer. Bounds cast expressions now have two forms: Op<T>(e1) Op<T>(e1, bounds-expression) where Op is one of _Assume_bounds_cast or _Dynamic_bounds_cast and T must be a pointer type. This change also improves the error messages and renames the error message names to be clearer. Testing: - There is corresponding Checked C repo change to tests for bounds cast expressions. - Add a test for error recovery from bounds cast expression syntax errors. - Passed local testing on x64 Windows and automated testing on Linux.
We changed bounds cast expressions to take a bounds expression as the
second argument, instead of implicitly inferring the kind of bounds
expression from the number of arguments. This is more verbose but
clearer. Bounds cast expressions now have two forms:
Op(e1)
Op(e1, bounds-expression)
where Op is one of _Assume_bounds_cast or _Dynamic_bounds_cast
and T must be a pointer type.
This change also improves the error messages and renames the
error message names to be clearer.
Testing:
for bounds cast expressions.
errors.