[PATCH] Avoid trying to get the alignment of a FieldDecl in an invalid record

Matt Beaumont-Gay matthewbg at google.com
Tue Jun 25 14:24:28 PDT 2013


While investigating PR16292, I added "assert(!D->isInvalidDecl())" to
ASTContext::getASTRecordLayout. The problem I fixed in r184751 was one
of the two paths which tickled that assertion via existing tests; this
is the other. (The actual testcase which triggers the assertion is
SemaCXX/alignof.cpp.) This patch changes ASTContext::getDeclAlign to
skip the actual field alignment calculation (and return 1-byte
alignment in the general case) if the field's parent record is
invalid. The patch also adds the assertion in getASTRecordLayout,
though I can commit that separately if anybody's fussed.

The careful reader will note that I took the opportunity to rename
local variables in the block which I touched to conform to proper LLVM
style, since getDeclAlign currently has a mix of styles and it made me
twitch.

-Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: record-layout-assert.patch
Type: application/octet-stream
Size: 2868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130625/99e8acee/attachment.obj>


More information about the cfe-commits mailing list