/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Interp/Record.cpp
Line | Count | Source (jump to first uncovered line) |
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 | 0 | BaseSize(BaseSize), VirtualSize(VirtualSize) { |
19 | 0 | for (Base &V : SrcVirtualBases) |
20 | 0 | VirtualBases.push_back({ V.Decl, V.Offset + BaseSize, V.Desc, V.R }); |
21 | |
|
22 | 0 | for (Base &B : Bases) |
23 | 0 | BaseMap[B.Decl] = &B; |
24 | 0 | for (Field &F : Fields) |
25 | 0 | FieldMap[F.Decl] = &F; |
26 | 0 | for (Base &V : VirtualBases) |
27 | 0 | VirtualBaseMap[V.Decl] = &V; |
28 | 0 | } |
29 | | |
30 | 0 | const Record::Field *Record::getField(const FieldDecl *FD) const { |
31 | 0 | auto It = FieldMap.find(FD); |
32 | 0 | assert(It != FieldMap.end() && "Missing field"); |
33 | 0 | return It->second; |
34 | 0 | } |
35 | | |
36 | 0 | const Record::Base *Record::getBase(const RecordDecl *FD) const { |
37 | 0 | auto It = BaseMap.find(FD); |
38 | 0 | assert(It != BaseMap.end() && "Missing base"); |
39 | 0 | return It->second; |
40 | 0 | } |
41 | | |
42 | 0 | const Record::Base *Record::getVirtualBase(const RecordDecl *FD) const { |
43 | 0 | auto It = VirtualBaseMap.find(FD); |
44 | 0 | assert(It != VirtualBaseMap.end() && "Missing virtual base"); |
45 | 0 | return It->second; |
46 | 0 | } |