@@ -1215,14 +1215,14 @@ class SrcFileInfo {
12151215// /
12161216class DbgVariable {
12171217private:
1218- DIVariable * Var; // Variable Descriptor.
1218+ DIVariable Var; // Variable Descriptor.
12191219 unsigned FrameIndex; // Variable frame index.
12201220
12211221public:
1222- DbgVariable (DIVariable * V, unsigned I) : Var(V), FrameIndex(I) {}
1222+ DbgVariable (DIVariable V, unsigned I) : Var(V), FrameIndex(I) {}
12231223
12241224 // Accessors.
1225- DIVariable * getVariable () const { return Var; }
1225+ DIVariable getVariable () const { return Var; }
12261226 unsigned getFrameIndex () const { return FrameIndex; }
12271227};
12281228
@@ -1564,7 +1564,7 @@ class DwarfDebug : public Dwarf {
15641564
15651565 // / AddSourceLine - Add location information to specified debug information
15661566 // / entry.
1567- void AddSourceLine (DIE *Die, DIVariable *V) {
1567+ void AddSourceLine (DIE *Die, const DIVariable *V) {
15681568 unsigned FileID = 0 ;
15691569 unsigned Line = V->getLineNumber ();
15701570 if (V->getVersion () < DIDescriptor::Version7) {
@@ -1583,7 +1583,7 @@ class DwarfDebug : public Dwarf {
15831583
15841584 // / AddSourceLine - Add location information to specified debug information
15851585 // / entry.
1586- void AddSourceLine (DIE *Die, DIGlobal *G) {
1586+ void AddSourceLine (DIE *Die, const DIGlobal *G) {
15871587 unsigned FileID = 0 ;
15881588 unsigned Line = G->getLineNumber ();
15891589 if (G->getVersion () < DIDescriptor::Version7) {
@@ -1600,18 +1600,18 @@ class DwarfDebug : public Dwarf {
16001600 AddUInt (Die, DW_AT_decl_line, 0 , Line);
16011601 }
16021602
1603- void AddSourceLine (DIE *Die, DIType *G ) {
1603+ void AddSourceLine (DIE *Die, const DIType *Ty ) {
16041604 unsigned FileID = 0 ;
1605- unsigned Line = G ->getLineNumber ();
1606- if (G ->getVersion () < DIDescriptor::Version7) {
1605+ unsigned Line = Ty ->getLineNumber ();
1606+ if (Ty ->getVersion () < DIDescriptor::Version7) {
16071607 // Version6 or earlier. Use compile unit info to get file id.
1608- CompileUnit *Unit = FindCompileUnit (G ->getCompileUnit ());
1608+ CompileUnit *Unit = FindCompileUnit (Ty ->getCompileUnit ());
16091609 FileID = Unit->getID ();
16101610 } else {
1611- // Version7 or newer, use filename and directory info from DIGlobal
1611+ // Version7 or newer, use filename and directory info from DIType
16121612 // directly.
1613- unsigned DID = Directories.idFor (G ->getDirectory ());
1614- FileID = SrcFiles.idFor (SrcFileInfo (DID, G ->getFilename ()));
1613+ unsigned DID = Directories.idFor (Ty ->getDirectory ());
1614+ FileID = SrcFiles.idFor (SrcFileInfo (DID, Ty ->getFilename ()));
16151615 }
16161616 AddUInt (Die, DW_AT_decl_file, 0 , FileID);
16171617 AddUInt (Die, DW_AT_decl_line, 0 , Line);
@@ -1979,12 +1979,12 @@ class DwarfDebug : public Dwarf {
19791979 // /
19801980 DIE *NewDbgScopeVariable (DbgVariable *DV, CompileUnit *Unit) {
19811981 // Get the descriptor.
1982- DIVariable * VD = DV->getVariable ();
1982+ const DIVariable & VD = DV->getVariable ();
19831983
19841984 // Translate tag to proper Dwarf tag. The result variable is dropped for
19851985 // now.
19861986 unsigned Tag;
1987- switch (VD-> getTag ()) {
1987+ switch (VD. getTag ()) {
19881988 case DW_TAG_return_variable: return NULL ;
19891989 case DW_TAG_arg_variable: Tag = DW_TAG_formal_parameter; break ;
19901990 case DW_TAG_auto_variable: // fall thru
@@ -1993,13 +1993,13 @@ class DwarfDebug : public Dwarf {
19931993
19941994 // Define variable debug information entry.
19951995 DIE *VariableDie = new DIE (Tag);
1996- AddString (VariableDie, DW_AT_name, DW_FORM_string, VD-> getName ());
1996+ AddString (VariableDie, DW_AT_name, DW_FORM_string, VD. getName ());
19971997
19981998 // Add source line info if available.
1999- AddSourceLine (VariableDie, VD);
1999+ AddSourceLine (VariableDie, & VD);
20002000
20012001 // Add variable type.
2002- AddType (Unit, VariableDie, VD-> getType ());
2002+ AddType (Unit, VariableDie, VD. getType ());
20032003
20042004 // Add variable address.
20052005 MachineLocation Location;
@@ -2135,14 +2135,14 @@ class DwarfDebug : public Dwarf {
21352135 for (std::vector<GlobalVariable *>::iterator I = Result.begin (),
21362136 E = Result.end (); I != E; ++I) {
21372137
2138- DISubprogram * SPD = new DISubprogram (*I);
2138+ DISubprogram SPD (*I);
21392139
2140- if (SPD-> getName () == MF->getFunction ()->getName ()) {
2140+ if (SPD. getName () == MF->getFunction ()->getName ()) {
21412141 // Get the compile unit context.
2142- CompileUnit *Unit = FindCompileUnit (SPD-> getCompileUnit ());
2142+ CompileUnit *Unit = FindCompileUnit (SPD. getCompileUnit ());
21432143
21442144 // Get the subprogram die.
2145- DIE *SPDie = Unit->getDieMapSlotFor (SPD-> getGV ());
2145+ DIE *SPDie = Unit->getDieMapSlotFor (SPD. getGV ());
21462146 assert (SPDie && " Missing subprogram descriptor" );
21472147
21482148 // Add the function bounds.
@@ -2780,22 +2780,22 @@ class DwarfDebug : public Dwarf {
27802780 getGlobalVariablesUsing (*M, CUName, Result);
27812781 for (std::vector<GlobalVariable *>::iterator RI = Result.begin (),
27822782 RE = Result.end (); RI != RE; ++RI) {
2783- DICompileUnit * DIUnit = new DICompileUnit (*RI);
2784- unsigned ID = RecordSource (DIUnit-> getDirectory (),
2785- DIUnit-> getFilename ());
2783+ DICompileUnit DIUnit (*RI);
2784+ unsigned ID = RecordSource (DIUnit. getDirectory (),
2785+ DIUnit. getFilename ());
27862786
27872787 DIE *Die = new DIE (DW_TAG_compile_unit);
27882788 AddSectionOffset (Die, DW_AT_stmt_list, DW_FORM_data4,
27892789 DWLabel (" section_line" , 0 ), DWLabel (" section_line" , 0 ),
27902790 false );
2791- AddString (Die, DW_AT_producer, DW_FORM_string, DIUnit-> getProducer ());
2792- AddUInt (Die, DW_AT_language, DW_FORM_data1, DIUnit-> getLanguage ());
2793- AddString (Die, DW_AT_name, DW_FORM_string, DIUnit-> getFilename ());
2794- if (!DIUnit-> getDirectory ().empty ())
2795- AddString (Die, DW_AT_comp_dir, DW_FORM_string, DIUnit-> getDirectory ());
2791+ AddString (Die, DW_AT_producer, DW_FORM_string, DIUnit. getProducer ());
2792+ AddUInt (Die, DW_AT_language, DW_FORM_data1, DIUnit. getLanguage ());
2793+ AddString (Die, DW_AT_name, DW_FORM_string, DIUnit. getFilename ());
2794+ if (!DIUnit. getDirectory ().empty ())
2795+ AddString (Die, DW_AT_comp_dir, DW_FORM_string, DIUnit. getDirectory ());
27962796
27972797 CompileUnit *Unit = new CompileUnit (ID, Die);
2798- DW_CUs[DIUnit-> getGV ()] = Unit;
2798+ DW_CUs[DIUnit. getGV ()] = Unit;
27992799 }
28002800 }
28012801
@@ -2807,32 +2807,32 @@ class DwarfDebug : public Dwarf {
28072807 getGlobalVariablesUsing (*M, GVName, Result);
28082808 for (std::vector<GlobalVariable *>::iterator GVI = Result.begin (),
28092809 GVE = Result.end (); GVI != GVE; ++GVI) {
2810- DIGlobalVariable * DI_GV = new DIGlobalVariable (*GVI);
2811- CompileUnit *DW_Unit = FindCompileUnit (DI_GV-> getCompileUnit ());
2810+ DIGlobalVariable DI_GV (*GVI);
2811+ CompileUnit *DW_Unit = FindCompileUnit (DI_GV. getCompileUnit ());
28122812
28132813 // Check for pre-existence.
2814- DIE *&Slot = DW_Unit->getDieMapSlotFor (DI_GV-> getGV ());
2814+ DIE *&Slot = DW_Unit->getDieMapSlotFor (DI_GV. getGV ());
28152815 if (Slot) continue ;
28162816
28172817 DIE *VariableDie = new DIE (DW_TAG_variable);
2818- AddString (VariableDie, DW_AT_name, DW_FORM_string, DI_GV-> getName ());
2819- const std::string &LinkageName = DI_GV-> getLinkageName ();
2818+ AddString (VariableDie, DW_AT_name, DW_FORM_string, DI_GV. getName ());
2819+ const std::string &LinkageName = DI_GV. getLinkageName ();
28202820 if (!LinkageName.empty ())
28212821 AddString (VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
28222822 LinkageName);
2823- AddType (DW_Unit, VariableDie, DI_GV-> getType ());
2823+ AddType (DW_Unit, VariableDie, DI_GV. getType ());
28242824
2825- if (!DI_GV-> isLocalToUnit ())
2825+ if (!DI_GV. isLocalToUnit ())
28262826 AddUInt (VariableDie, DW_AT_external, DW_FORM_flag, 1 );
28272827
28282828 // Add source line info, if available.
2829- AddSourceLine (VariableDie, DI_GV);
2829+ AddSourceLine (VariableDie, & DI_GV);
28302830
28312831 // Add address.
28322832 DIEBlock *Block = new DIEBlock ();
28332833 AddUInt (Block, 0 , DW_FORM_data1, DW_OP_addr);
28342834 AddObjectLabel (Block, 0 , DW_FORM_udata,
2835- Asm->getGlobalLinkName (DI_GV-> getGV ()));
2835+ Asm->getGlobalLinkName (DI_GV. getGV ()));
28362836 AddBlock (VariableDie, DW_AT_location, 0 , Block);
28372837
28382838 // Add to map.
@@ -2842,7 +2842,7 @@ class DwarfDebug : public Dwarf {
28422842 DW_Unit->getDie ()->AddChild (VariableDie);
28432843
28442844 // Expose as global. FIXME - need to check external flag.
2845- DW_Unit->AddGlobal (DI_GV-> getName (), VariableDie);
2845+ DW_Unit->AddGlobal (DI_GV. getName (), VariableDie);
28462846 }
28472847 }
28482848
@@ -2856,32 +2856,32 @@ class DwarfDebug : public Dwarf {
28562856 for (std::vector<GlobalVariable *>::iterator RI = Result.begin (),
28572857 RE = Result.end (); RI != RE; ++RI) {
28582858
2859- DISubprogram *SP = new DISubprogram (*RI);
2860- CompileUnit *Unit = FindCompileUnit (SP-> getCompileUnit ());
2859+ DISubprogram SP (*RI);
2860+ CompileUnit *Unit = FindCompileUnit (SP. getCompileUnit ());
28612861
28622862 // Check for pre-existence.
2863- DIE *&Slot = Unit->getDieMapSlotFor (SP-> getGV ());
2863+ DIE *&Slot = Unit->getDieMapSlotFor (SP. getGV ());
28642864 if (Slot) continue ;
28652865
28662866 DIE *SubprogramDie = new DIE (DW_TAG_subprogram);
2867- AddString (SubprogramDie, DW_AT_name, DW_FORM_string, SP-> getName ());
2868- const std::string &LinkageName = SP-> getLinkageName ();
2867+ AddString (SubprogramDie, DW_AT_name, DW_FORM_string, SP. getName ());
2868+ const std::string &LinkageName = SP. getLinkageName ();
28692869 if (!LinkageName.empty ())
28702870 AddString (SubprogramDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
28712871 LinkageName);
2872- DIType SPTy = SP-> getType ();
2872+ DIType SPTy = SP. getType ();
28732873 AddType (Unit, SubprogramDie, SPTy);
2874- if (!SP-> isLocalToUnit ())
2874+ if (!SP. isLocalToUnit ())
28752875 AddUInt (SubprogramDie, DW_AT_external, DW_FORM_flag, 1 );
28762876 AddUInt (SubprogramDie, DW_AT_prototyped, DW_FORM_flag, 1 );
28772877
2878- AddSourceLine (SubprogramDie, SP);
2878+ AddSourceLine (SubprogramDie, & SP);
28792879 // Add to map.
28802880 Slot = SubprogramDie;
28812881 // Add to context owner.
28822882 Unit->getDie ()->AddChild (SubprogramDie);
28832883 // Expose as global.
2884- Unit->AddGlobal (SP-> getName (), SubprogramDie);
2884+ Unit->AddGlobal (SP. getName (), SubprogramDie);
28852885 }
28862886 }
28872887
@@ -3170,8 +3170,7 @@ class DwarfDebug : public Dwarf {
31703170 Scope = getOrCreateScope (DV.getContext ().getGV ());
31713171 }
31723172 assert (Scope && " Unable to find variable' scope" );
3173- DIVariable *VD = new DIVariable (GV);
3174- DbgVariable *DV = new DbgVariable (VD, FrameIndex);
3173+ DbgVariable *DV = new DbgVariable (DIVariable (GV), FrameIndex);
31753174 Scope->AddVariable (DV);
31763175 }
31773176};
0 commit comments