blob: 69fb1f1005996e25ed8697c216fa8e3d6d9d6705 [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
Mike Stumpab28c132009-10-13 22:54:56 +000050 /// getVirtualBaseOffsetIndex - Return the index (relative to the vtable
51 /// address point) where the offset of the virtual base that contains the
52 /// given Base is stored, otherwise, if no virtual base contains the given
53 /// class, return 0. Base must be a virtual base class or an unambigious
54 /// base.
Anders Carlssondbd920c2009-10-11 22:13:54 +000055 int64_t getVirtualBaseOffsetIndex(const CXXRecordDecl *RD,
56 const CXXRecordDecl *VBase);
57};
58
59}
60}
61#endif