clang  10.0.0svn
Record.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
9 #include "Record.h"
10 
11 using namespace clang;
12 using namespace clang::interp;
13 
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 });
21 
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;
28 }
29 
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;
34 }
35 
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;
40 }
41 
43  auto It = VirtualBaseMap.find(FD);
44  assert(It != VirtualBaseMap.end() && "Missing virtual base");
45  return It->second;
46 }
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
const Base * getBase(const RecordDecl *FD) const
Returns a base descriptor.
Definition: Record.cpp:36
Represents a struct/union/class.
Definition: Decl.h:3662
Represents a member of a struct/union/class.
Definition: Decl.h:2643
Definition: Format.h:2392
#define V(N, I)
Definition: ASTContext.h:2921
Dataflow Directional Tag Classes.
Describes a record field.
Definition: Record.h:26
const Field * getField(const FieldDecl *FD) const
Returns a field.
Definition: Record.cpp:30
const Base * getVirtualBase(const RecordDecl *RD) const
Returns a virtual base descriptor.
Definition: Record.cpp:42
Describes a base class.
Definition: Record.h:33