@@ -2525,11 +2525,13 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
25252525// existing information in the DWARF. The type is assumed to be 'void *'.
25262526void CGDebugInfo::emitVTableSymbol (llvm::GlobalVariable *VTable,
25272527 const CXXRecordDecl *RD) {
2528+ if (!CGM.getTarget ().getCXXABI ().isItaniumFamily ())
2529+ return ;
2530+
25282531 ASTContext &Context = CGM.getContext ();
25292532 SmallString<64 > Buffer;
2530- Twine SymbolName = internString (" _vtable$" );
2531- StringRef SymbolNameRef = SymbolName.toStringRef (Buffer);
2532- DeclContext *DC = static_cast <DeclContext *>(const_cast <CXXRecordDecl *>(RD));
2533+ StringRef SymbolName = " _vtable$" ;
2534+ const DeclContext *DC = static_cast <const DeclContext *>(RD);
25332535 SourceLocation Loc;
25342536 QualType VoidPtr = Context.getPointerType (Context.VoidTy );
25352537
@@ -2539,32 +2541,28 @@ void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
25392541 // - The DIGlobalVariable for the vtable is put in the DICompileUnitScope.
25402542
25412543 // The created non-member should be mark as 'artificial'. It will be
2542- // placed it inside the scope of the C++ class/structure.
2544+ // placed inside the scope of the C++ class/structure.
25432545 llvm::DIScope *DContext = getContextDescriptor (cast<Decl>(DC), TheCU);
25442546 auto *Ctxt = cast<llvm::DICompositeType>(DContext);
25452547 llvm::DIFile *Unit = getOrCreateFile (Loc);
25462548 llvm::DIType *VTy = getOrCreateType (VoidPtr, Unit);
2547- llvm::DINode::DIFlags Flags = getAccessFlag (AccessSpecifier::AS_private, RD);
2549+ llvm::DINode::DIFlags Flags = getAccessFlag (AccessSpecifier::AS_private, RD) |
2550+ llvm::DINode::FlagArtificial;
25482551 auto Tag = CGM.getCodeGenOpts ().DwarfVersion >= 5
25492552 ? llvm::dwarf::DW_TAG_variable
25502553 : llvm::dwarf::DW_TAG_member;
2551- llvm::DIDerivedType *OldDT = DBuilder.createStaticMemberType (
2552- Ctxt, SymbolNameRef , Unit, /* LineNumber=*/ 0 , VTy, Flags,
2554+ llvm::DIDerivedType *DT = DBuilder.createStaticMemberType (
2555+ Ctxt, SymbolName , Unit, /* LineNumber=*/ 0 , VTy, Flags,
25532556 /* Val=*/ nullptr , Tag);
2554- llvm::DIDerivedType *DT =
2555- static_cast <llvm::DIDerivedType *>(DBuilder.createArtificialType (OldDT));
25562557
25572558 // Use the same vtable pointer to global alignment for the symbol.
2558- LangAS AS = CGM.GetGlobalVarAddressSpace (nullptr );
2559- unsigned PAlign = CGM.getItaniumVTableContext ().isRelativeLayout ()
2560- ? 32
2561- : CGM.getTarget ().getPointerAlign (AS);
2559+ unsigned PAlign = CGM.getGlobalVarAlignment ();
25622560
25632561 // The global variable is in the CU scope, and links back to the type it's
25642562 // "within" via the declaration field.
25652563 llvm::DIGlobalVariableExpression *GVE =
25662564 DBuilder.createGlobalVariableExpression (
2567- TheCU, SymbolNameRef , VTable->getName (), Unit, /* LineNo=*/ 0 ,
2565+ TheCU, SymbolName , VTable->getName (), Unit, /* LineNo=*/ 0 ,
25682566 getOrCreateType (VoidPtr, Unit), VTable->hasLocalLinkage (),
25692567 /* isDefined=*/ true , nullptr , DT, /* TemplateParameters=*/ nullptr ,
25702568 PAlign);
0 commit comments