[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / lib / AST / Interp / Record.cpp
blob909416e6e1a1a53936061d4ff5ce2d6add7b8578
1 //===--- Record.cpp - struct and class metadata for the VM ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "Record.h"
11 using namespace clang;
12 using namespace clang::interp;
14 Record::Record(const RecordDecl *Decl, BaseList &&SrcBases,
15 FieldList &&SrcFields, VirtualBaseList &&SrcVirtualBases,
16 unsigned VirtualSize, unsigned BaseSize)
17 : Decl(Decl), Bases(std::move(SrcBases)), Fields(std::move(SrcFields)),
18 BaseSize(BaseSize), VirtualSize(VirtualSize) {
19 for (Base &V : SrcVirtualBases)
20 VirtualBases.push_back({ V.Decl, V.Offset + BaseSize, V.Desc, V.R });
22 for (Base &B : Bases)
23 BaseMap[B.Decl] = &B;
24 for (Field &F : Fields)
25 FieldMap[F.Decl] = &F;
26 for (Base &V : VirtualBases)
27 VirtualBaseMap[V.Decl] = &V;
30 const Record::Field *Record::getField(const FieldDecl *FD) const {
31 auto It = FieldMap.find(FD);
32 assert(It != FieldMap.end() && "Missing field");
33 return It->second;
36 const Record::Base *Record::getBase(const RecordDecl *FD) const {
37 auto It = BaseMap.find(FD);
38 assert(It != BaseMap.end() && "Missing base");
39 return It->second;
42 const Record::Base *Record::getBase(QualType T) const {
43 if (!T->isRecordType())
44 return nullptr;
46 const RecordDecl *RD = T->getAs<RecordType>()->getDecl();
47 return BaseMap.lookup(RD);
50 const Record::Base *Record::getVirtualBase(const RecordDecl *FD) const {
51 auto It = VirtualBaseMap.find(FD);
52 assert(It != VirtualBaseMap.end() && "Missing virtual base");
53 return It->second;