|
|
|||
File indexing completed on 2026-05-10 08:36:55
0001 //===--- LayoutOverrideSource.h --Override Record Layouts -------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H 0010 #define LLVM_CLANG_FRONTEND_LAYOUTOVERRIDESOURCE_H 0011 0012 #include "clang/AST/ExternalASTSource.h" 0013 #include "clang/Basic/LLVM.h" 0014 #include "llvm/ADT/StringMap.h" 0015 #include "llvm/ADT/StringRef.h" 0016 0017 namespace clang { 0018 /// An external AST source that overrides the layout of 0019 /// a specified set of record types. 0020 /// 0021 /// This class is used only for testing the ability of external AST sources 0022 /// to override the layout of record types. Its input is the output format 0023 /// of the command-line argument -fdump-record-layouts. 0024 class LayoutOverrideSource : public ExternalASTSource { 0025 /// The layout of a given record. 0026 struct Layout { 0027 /// The size of the record. 0028 uint64_t Size; 0029 0030 /// The alignment of the record. 0031 uint64_t Align; 0032 0033 /// The offsets of non-virtual base classes in the record. 0034 SmallVector<CharUnits, 8> BaseOffsets; 0035 0036 /// The offsets of virtual base classes in the record. 0037 SmallVector<CharUnits, 8> VBaseOffsets; 0038 0039 /// The offsets of the fields, in source order. 0040 SmallVector<uint64_t, 8> FieldOffsets; 0041 }; 0042 0043 /// The set of layouts that will be overridden. 0044 llvm::StringMap<Layout> Layouts; 0045 0046 public: 0047 /// Create a new AST source that overrides the layout of some 0048 /// set of record types. 0049 /// 0050 /// The file is the result of passing -fdump-record-layouts to a file. 0051 explicit LayoutOverrideSource(StringRef Filename); 0052 0053 /// If this particular record type has an overridden layout, 0054 /// return that layout. 0055 bool 0056 layoutRecordType(const RecordDecl *Record, 0057 uint64_t &Size, uint64_t &Alignment, 0058 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, 0059 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, 0060 llvm::DenseMap<const CXXRecordDecl *, 0061 CharUnits> &VirtualBaseOffsets) override; 0062 0063 /// Dump the overridden layouts. 0064 void dump(); 0065 }; 0066 } 0067 0068 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|