2009-07-19 04:20:21 +08:00
|
|
|
//===- ASTRecordLayoutBuilder.h - Helper class for building record layouts ===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_AST_RECORDLAYOUTBUILDER_H
|
|
|
|
#define LLVM_CLANG_AST_RECORDLAYOUTBUILDER_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
class ASTContext;
|
|
|
|
class ASTRecordLayout;
|
2009-07-19 08:18:47 +08:00
|
|
|
class CXXRecordDecl;
|
2009-07-19 04:20:21 +08:00
|
|
|
class FieldDecl;
|
2009-07-19 04:50:59 +08:00
|
|
|
class ObjCImplementationDecl;
|
|
|
|
class ObjCInterfaceDecl;
|
2009-07-19 04:20:21 +08:00
|
|
|
class RecordDecl;
|
|
|
|
|
|
|
|
class ASTRecordLayoutBuilder {
|
|
|
|
ASTContext &Ctx;
|
|
|
|
|
|
|
|
uint64_t Size;
|
|
|
|
uint64_t Alignment;
|
|
|
|
llvm::SmallVector<uint64_t, 16> FieldOffsets;
|
|
|
|
|
|
|
|
unsigned StructPacking;
|
|
|
|
unsigned NextOffset;
|
|
|
|
bool IsUnion;
|
|
|
|
|
|
|
|
ASTRecordLayoutBuilder(ASTContext &Ctx);
|
|
|
|
|
|
|
|
void Layout(const RecordDecl *D);
|
2009-07-19 08:18:47 +08:00
|
|
|
void Layout(const CXXRecordDecl *D);
|
2009-07-19 04:50:59 +08:00
|
|
|
void Layout(const ObjCInterfaceDecl *D,
|
|
|
|
const ObjCImplementationDecl *Impl);
|
|
|
|
|
2009-07-19 05:48:39 +08:00
|
|
|
void LayoutFields(const RecordDecl *D);
|
2009-07-19 04:20:21 +08:00
|
|
|
void LayoutField(const FieldDecl *D);
|
2009-07-19 05:19:52 +08:00
|
|
|
|
2009-07-19 08:18:47 +08:00
|
|
|
void LayoutNonVirtualBases(const CXXRecordDecl *RD);
|
|
|
|
void LayoutNonVirtualBase(const CXXRecordDecl *RD);
|
|
|
|
|
2009-07-19 05:19:52 +08:00
|
|
|
/// FinishLayout - Finalize record layout. Adjust record size based on the
|
|
|
|
/// alignment.
|
2009-07-19 04:20:21 +08:00
|
|
|
void FinishLayout();
|
|
|
|
|
|
|
|
void UpdateAlignment(unsigned NewAlignment);
|
|
|
|
|
|
|
|
ASTRecordLayoutBuilder(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
|
|
|
|
public:
|
|
|
|
static const ASTRecordLayout *ComputeLayout(ASTContext &Ctx,
|
|
|
|
const RecordDecl *RD);
|
2009-07-19 04:50:59 +08:00
|
|
|
static const ASTRecordLayout *ComputeLayout(ASTContext &Ctx,
|
|
|
|
const ObjCInterfaceDecl *D,
|
|
|
|
const ObjCImplementationDecl *Impl);
|
2009-07-19 04:20:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|