clang  6.0.0svn
LayoutOverrideSource.h
Go to the documentation of this file.
1 //===--- LayoutOverrideSource.h --Override Record Layouts -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H
11 #define LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H
12 
14 #include "clang/Basic/LLVM.h"
15 #include "llvm/ADT/StringMap.h"
16 #include "llvm/ADT/StringRef.h"
17 
18 namespace clang {
19  /// \brief An external AST source that overrides the layout of
20  /// a specified set of record types.
21  ///
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.
26  /// \brief The layout of a given record.
27  struct Layout {
28  /// \brief The size of the record.
29  uint64_t Size;
30 
31  /// \brief The alignment of the record.
32  uint64_t Align;
33 
34  /// \brief The offsets of the fields, in source order.
35  SmallVector<uint64_t, 8> FieldOffsets;
36  };
37 
38  /// \brief The set of layouts that will be overridden.
39  llvm::StringMap<Layout> Layouts;
40 
41  public:
42  /// \brief Create a new AST source that overrides the layout of some
43  /// set of record types.
44  ///
45  /// The file is the result of passing -fdump-record-layouts to a file.
46  explicit LayoutOverrideSource(StringRef Filename);
47 
48  /// \brief If this particular record type has an overridden layout,
49  /// return that layout.
50  bool
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 *,
56  CharUnits> &VirtualBaseOffsets) override;
57 
58  /// \brief Dump the overridden layouts.
59  void dump();
60  };
61 }
62 
63 #endif
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
bool layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &BaseOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &VirtualBaseOffsets) override
If this particular record type has an overridden layout, return that layout.
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
StringRef Filename
Definition: Format.cpp:1345
void dump()
Dump the overridden layouts.
Abstract interface for external sources of AST nodes.
Dataflow Directional Tag Classes.
LayoutOverrideSource(StringRef Filename)
Create a new AST source that overrides the layout of some set of record types.
An external AST source that overrides the layout of a specified set of record types.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299