//===--- CGVtable.cpp - Emit LLVM Code for C++ vtables --------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This contains code dealing with C++ code generation of virtual tables.////===----------------------------------------------------------------------===//#include"CodeGenModule.h"#include"CodeGenFunction.h"#include"clang/AST/CXXInheritance.h"#include"clang/AST/RecordLayout.h"#include"llvm/ADT/DenseSet.h"#include<cstdio>usingnamespaceclang;usingnamespaceCodeGen;namespace{classVtableBuilder{public:/// Index_t - Vtable index type.typedefuint64_tIndex_t;private:std::vector<llvm::Constant*>&methods;std::vector<llvm::Constant*>submethods;llvm::Type*Ptr8Ty;/// Class - The most derived class that this vtable is being built for.constCXXRecordDecl*Class;/// LayoutClass - The most derived class used for virtual base layout/// information.constCXXRecordDecl*LayoutClass;/// LayoutOffset - The offset for Class in LayoutClass.uint64_tLayoutOffset;/// BLayout - Layout for the most derived class that this vtable is being/// built for.constASTRecordLayout&BLayout;llvm::SmallSet<constCXXRecordDecl*,32>IndirectPrimary;llvm::SmallSet<constCXXRecordDecl*,32>SeenVBase;llvm::Constant*rtti;llvm::LLVMContext&VMContext;CodeGenModule&CGM;// Per-module state./// Index - Maps a method decl into a vtable index. Useful for virtual/// dispatch codegen.llvm::DenseMap<GlobalDecl,Index_t>Index;llvm