-
Notifications
You must be signed in to change notification settings - Fork 79
Adds (De)Serialization of Declaration Bounds #111
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
Hi @lenary, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
Clang regression tests pass on 64-bit Windows. |
@@ -746,6 +746,10 @@ void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { | |||
void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { | |||
VisitValueDecl(DD); | |||
DD->setInnerLocStart(ReadSourceLocation(Record, Idx)); | |||
|
|||
if (Record[Idx++]) // hasBoundExpr |
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.
One small typo; the comment should be hasBoundsExpr.
Every time I look at the My concern is that these seem to be defining a layout. In this line, I'm saying "there's a fixed-width field here, 1 bit wide, that says whether we have a bounds expression", I think. This is correct only when I think I have a more robust fix incoming, which we can always revisit later. |
Ok, my tests pass. What 9d4e5be does is disable the use of abbreviations if we have a bounds expression, meaning the abbreviations are always correct. This is alright for the moment, but may in future be something we want to optimize. |
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.
Yes, I agree that we should turn off the use of abbreviations when bounds declarations are present for declarations.
This pull request comprehensively revisits and expands the PCH tests, and adds (de)serialization of the bounds associated with global variables, function returns, and struct member fields.
The only way at the moment to test that bounds declarations on global fields and functions are preserved is to redeclare the same function, which should error if you drop the bounds, and not error if you preserve the right bounds as in the precompiled header.
Bounds expressions on struct members are very hard to test, until we start inferring and solving bounds information. The test for
itype()
should work today, the others will become useful later.As for serialization/deserialization. I've added the code to do so to the VisitDeclaratorDecl methods, because the bounds information is stored within that class (as opposed to its subclasses). Doing this alone caused an assertion failure in the bitcode writer, namely
"Invalid abbrev for record!", file ../llvm/include/llvm/Bitcode/BitstreamWriter.h, line 268
. (If this happens again, I hope searching turns up this ticket). I believe I have added the correct entries to the abbreviation system. The clang regression tests pass on 32-bit, I'm currently running them on 64-bit.Closes #104.
Relevant to #105 and #106 but I think the tests need more work before I can close those two.