mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] NFC: Stop over aligning DeclContexts
DeclContexts as they exist today are "over aligned" when compared to their natural alignment boundary and therefore they can easily cause adjacent padding when dropped into the middle of objects via C++ inheritance, or when the clang importer prefaces Swift AST allocations with a pointer to the corresponding clang AST node. With this change, we move DeclContexts to the front of the memory layout of AST nodes. This allows us to restore natural alignment, save memory, and as a side effect: more easily avoid "over alignment" in the future because DeclContexts now only need to directly track which AST node hierarchy they're associated with, not specific AST nodes within each hierarchy. Finally, as a word of caution, after this change one can no longer assume that AST nodes safely convert back and forth with "void*". For example, WitnessTableEntry needed fixing with this change.
This commit is contained in:
@@ -127,7 +127,7 @@ enum class ResilienceStrategy : unsigned {
|
||||
/// output binary and logical module (such as a single library or executable).
|
||||
///
|
||||
/// \sa FileUnit
|
||||
class ModuleDecl : public TypeDecl, public DeclContext {
|
||||
class ModuleDecl : public DeclContext, public TypeDecl {
|
||||
public:
|
||||
typedef ArrayRef<std::pair<Identifier, SourceLoc>> AccessPathTy;
|
||||
typedef std::pair<ModuleDecl::AccessPathTy, ModuleDecl*> ImportedModule;
|
||||
|
||||
Reference in New Issue
Block a user