@@ -2525,11 +2525,13 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
2525
2525
// existing information in the DWARF. The type is assumed to be 'void *'.
2526
2526
void CGDebugInfo::emitVTableSymbol (llvm::GlobalVariable *VTable,
2527
2527
const CXXRecordDecl *RD) {
2528
+ if (!CGM.getTarget ().getCXXABI ().isItaniumFamily ())
2529
+ return ;
2530
+
2528
2531
ASTContext &Context = CGM.getContext ();
2529
2532
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);
2533
2535
SourceLocation Loc;
2534
2536
QualType VoidPtr = Context.getPointerType (Context.VoidTy );
2535
2537
@@ -2539,32 +2541,28 @@ void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
2539
2541
// - The DIGlobalVariable for the vtable is put in the DICompileUnitScope.
2540
2542
2541
2543
// 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.
2543
2545
llvm::DIScope *DContext = getContextDescriptor (cast<Decl>(DC), TheCU);
2544
2546
auto *Ctxt = cast<llvm::DICompositeType>(DContext);
2545
2547
llvm::DIFile *Unit = getOrCreateFile (Loc);
2546
2548
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;
2548
2551
auto Tag = CGM.getCodeGenOpts ().DwarfVersion >= 5
2549
2552
? llvm::dwarf::DW_TAG_variable
2550
2553
: 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,
2553
2556
/* Val=*/ nullptr , Tag);
2554
- llvm::DIDerivedType *DT =
2555
- static_cast <llvm::DIDerivedType *>(DBuilder.createArtificialType (OldDT));
2556
2557
2557
2558
// 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 ();
2562
2560
2563
2561
// The global variable is in the CU scope, and links back to the type it's
2564
2562
// "within" via the declaration field.
2565
2563
llvm::DIGlobalVariableExpression *GVE =
2566
2564
DBuilder.createGlobalVariableExpression (
2567
- TheCU, SymbolNameRef , VTable->getName (), Unit, /* LineNo=*/ 0 ,
2565
+ TheCU, SymbolName , VTable->getName (), Unit, /* LineNo=*/ 0 ,
2568
2566
getOrCreateType (VoidPtr, Unit), VTable->hasLocalLinkage (),
2569
2567
/* isDefined=*/ true , nullptr , DT, /* TemplateParameters=*/ nullptr ,
2570
2568
PAlign);
0 commit comments