1 //===--- LayoutOverrideSource.h --Override Record Layouts -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H
11 #define LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H
13 #include "clang/AST/ExternalASTSource.h"
14 #include "clang/Basic/LLVM.h"
15 #include "llvm/ADT/StringMap.h"
16 #include "llvm/ADT/StringRef.h"
19 /// \brief An external AST source that overrides the layout of
20 /// a specified set of record types.
22 /// This class is used only for testing the ability of external AST sources
23 /// to override the layout of record types. Its input is the output format
24 /// of the command-line argument -fdump-record-layouts.
25 class LayoutOverrideSource : public ExternalASTSource {
26 /// \brief The layout of a given record.
28 /// \brief The size of the record.
31 /// \brief The alignment of the record.
34 /// \brief The offsets of the fields, in source order.
35 SmallVector<uint64_t, 8> FieldOffsets;
38 /// \brief The set of layouts that will be overridden.
39 llvm::StringMap<Layout> Layouts;
42 /// \brief Create a new AST source that overrides the layout of some
43 /// set of record types.
45 /// The file is the result of passing -fdump-record-layouts to a file.
46 explicit LayoutOverrideSource(StringRef Filename);
48 /// \brief If this particular record type has an overridden layout,
49 /// return that layout.
51 layoutRecordType(const RecordDecl *Record,
52 uint64_t &Size, uint64_t &Alignment,
53 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
54 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
55 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets);
57 /// \brief Dump the overridden layouts.