blob: 6adc6e63b082a5eb1ce41b24f7d123bb79f3e086 [file] [log] [blame]
Anders Carlssondbd920c2009-10-11 22:13:54 +00001//===--- CGVtable.h - Emit LLVM Code for C++ vtables ----------------------===//
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// This contains code dealing with C++ code generation of virtual tables.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CLANG_CODEGEN_CGVTABLE_H
15#define CLANG_CODEGEN_CGVTABLE_H
16
17#include "llvm/ADT/DenseMap.h"
18
19namespace clang {
20 class CXXMethodDecl;
21 class CXXRecordDecl;
22
23namespace CodeGen {
24 class CodeGenModule;
25
26class CGVtableInfo {
27 CodeGenModule &CGM;
28
29 /// MethodVtableIndices - Contains the index (relative to the vtable address
30 /// point) where the function pointer for a virtual function is stored.
31 typedef llvm::DenseMap<const CXXMethodDecl *, int64_t> MethodVtableIndicesTy;
32 MethodVtableIndicesTy MethodVtableIndices;
33
34 typedef std::pair<const CXXRecordDecl *,
35 const CXXRecordDecl *> ClassPairTy;
36
37 /// VirtualBaseClassIndicies - Contains the index into the vtable where the
38 /// offsets for virtual bases of a class are stored.
39 typedef llvm::DenseMap<ClassPairTy, int64_t> VirtualBaseClassIndiciesTy;
40 VirtualBaseClassIndiciesTy VirtualBaseClassIndicies;
41public:
42 CGVtableInfo(CodeGenModule &CGM)
43 : CGM(CGM) { }
44
45 /// getMethodVtableIndex - Return the index (relative to the vtable address
46 /// point) where the function pointer for the given virtual function is
47 /// stored.
48 int64_t getMethodVtableIndex(const CXXMethodDecl *MD);
49
50 /// getVirtualBaseOffsetIndex - Return the index (relative to the vtable address
51 /// point) where the offset of the given virtual base of the given class is
52 // stored.
53 int64_t getVirtualBaseOffsetIndex(const CXXRecordDecl *RD,
54 const CXXRecordDecl *VBase);
55};
56
57}
58}
59#endif