[PATCH] D83972: Modify ImportDefiniton for ObjCInterfaceDecl so that we always the ImportDeclContext one we start the definition
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 16 11:15:13 PDT 2020
shafik created this revision.
shafik added reviewers: teemperor, martong.
Herald added a subscriber: rnkovacs.
Once we start the definition of an `ObjCInterfaceDecl` we won't attempt to `ImportDeclContext` later on. Unlike `RecordDecl` case which uses `DefinitionCompleter` to force `completeDefinition` we don't seem to have a similar mechanism for `ObjCInterfaceDecl`.
This fix was needed due to a bug we see in LLDB expression parsing where an initial expression cause an `ObjCInterfaceDecl` to be defined and subsequent expressions during import do not call `ImportDeclContext` and we can end up in a situation where ivars are imported out of order and not all ivars are imported e.g.
(lldb) expr chb1->hb->field2
ObjCInterfaceDecl 0x7f9457495fe0 <<invalid sloc>> <invalid sloc> <undeserialized declarations> HasBitfield1
|-super ObjCInterface 0x7f9457495e78 'NSObject'
`-ObjCIvarDecl 0x7f945749d478 <<invalid sloc>> <invalid sloc> field2 'unsigned int' public
`-IntegerLiteral 0x7f945749d458 <<invalid sloc>> 'int' 1
We have `field2` which is the second ivar but we are missing `field1`.
In this particular case `ASTContext::lookupFieldBitOffset(...)` assumes we have all ivars and they are in order to obtain the index of the ivar and we break this assumption. This leads eventually to bad IRGen since it has the wrong field offset.
https://reviews.llvm.org/D83972
Files:
clang/lib/AST/ASTImporter.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/API/lang/objc/bitfield_ivars/Makefile
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
lldb/test/API/lang/objc/bitfield_ivars/main.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83972.278538.patch
Type: text/x-patch
Size: 5624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200716/5c80fa76/attachment.bin>
More information about the cfe-commits
mailing list