This is an archive of the discontinued LLVM Phabricator instance.

[PCH] Support writing BuiltinBitCastExprs to PCHs
ClosedPublic

Authored by hyd-dev on May 20 2020, 10:51 PM.

Details

Summary

D62825 adds the new BuiltinBitCastExpr, but does not set the Code member of ASTStmtWriter. This is not correct and causes an assertion failue (assert(Code != serialization::STMT_NULL_PTR && "unhandled sub-statement writing AST file")) in ASTStmtWriter::emit() when building PCHs that contain __builtin_bit_cast. This patch adds serialization::EXPR_BUILTIN_BIT_CAST and handles ASTStmtWriter::Code properly.

Diff Detail

Event Timeline

hyd-dev created this revision.May 20 2020, 10:51 PM
hyd-dev edited the summary of this revision. (Show Details)May 20 2020, 10:54 PM
hyd-dev edited the summary of this revision. (Show Details)May 20 2020, 10:57 PM
hyd-dev updated this revision to Diff 265436.EditedMay 20 2020, 11:54 PM

Format builtin-bit-cast.cpp and make it simpler.

hyd-dev edited the summary of this revision. (Show Details)May 21 2020, 12:09 AM
erik.pilkington accepted this revision.Jun 9 2020, 1:01 PM

LGTM (after a minor comment), thank you for fixing this!

clang/lib/Serialization/ASTReaderStmt.cpp
3623

PathSize should always be zero, so I think it makes more sense to assert(Record[ASTStmtReader::NumExprFields] == 0); here and remove the PathSize parameter from the BuiltinBitCastExpr constructor.

This revision is now accepted and ready to land.Jun 9 2020, 1:01 PM
hyd-dev updated this revision to Diff 269765.Jun 10 2020, 2:13 AM
hyd-dev marked an inline comment as done.

Address the comment: remove PathSize from BuiltinBitCastExpr's constructor and assert() it == 0.

hyd-dev added a comment.EditedJun 10 2020, 2:16 AM

If this is OK, please commit it with --author "hyd-dev <yd-huang@outlook.com>". Thanks.

This revision was automatically updated to reflect the committed changes.