Skip to content

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

Merged
merged 6 commits into from
Jan 19, 2017
Merged

Conversation

lenary
Copy link
Collaborator

@lenary lenary commented Jan 19, 2017

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.

@msftclas
Copy link

Hi @lenary, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Samuel Hemsley Elliott). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@lenary
Copy link
Collaborator Author

lenary commented Jan 19, 2017

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
Copy link
Member

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.

@lenary
Copy link
Collaborator Author

lenary commented Jan 19, 2017

Every time I look at theAbv lines, I become less convinced I know what's going on with them. I'm going to review this file again, and run a lot of clang tests.

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 hasBoundsExpr() is false. If we have a bounds expression, we have the field for hasBoundsExpr() followed immediately by a field containing the bounds expression in purpose, showing this is not fixed width.

I think I have a more robust fix incoming, which we can always revisit later.

@lenary
Copy link
Collaborator Author

lenary commented Jan 19, 2017

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.

Copy link
Member

@dtarditi dtarditi left a 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.

@lenary lenary merged commit daa466d into checkedc:master Jan 19, 2017
@lenary lenary deleted the issue104 branch January 25, 2017 19:03
dopelsunce pushed a commit to dopelsunce/checkedc-clang that referenced this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AST Serialization for Struct Member Bounds Information
3 participants