1. Support for c++ mangled names.
authorJim Laskey <jlaskey@mac.com>
Tue, 11 Jul 2006 15:58:09 +0000 (15:58 +0000)
committerJim Laskey <jlaskey@mac.com>
Tue, 11 Jul 2006 15:58:09 +0000 (15:58 +0000)
2. Support for private/protected class members.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29104 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineDebugInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/CodeGen/MachineDebugInfo.cpp
lib/VMCore/IntrinsicInst.cpp

index 70c8398656c9426f2e202c5c2740869684b69265..17d28d8c7b9b2203a597527c36c65ff45b3a0133 100644 (file)
@@ -57,7 +57,8 @@ class StructType;
 // Debug info constants.
 
 enum {
-  LLVMDebugVersion = (4 << 16),         // Current version of debug information.
+  LLVMDebugVersion = (5 << 16),         // Current version of debug information.
+  LLVMDebugVersion4 = (4 << 16),        // Constant for version 4.
   LLVMDebugVersionMask = 0xffff0000     // Mask for version number.
 };
 
@@ -276,6 +277,10 @@ public:
 ///
 class TypeDesc : public DebugInfoDesc {
 private:
+  enum {
+    FlagPrivate    = 1 << 0,
+    FlagProtected  = 1 << 1
+  };
   DebugInfoDesc *Context;               // Context debug descriptor.
   std::string Name;                     // Type name (may be empty.)
   DebugInfoDesc *File;                  // Defined compile unit (may be NULL.)
@@ -283,6 +288,7 @@ private:
   uint64_t Size;                        // Type bit size (may be zero.)
   uint64_t Align;                       // Type bit alignment (may be zero.)
   uint64_t Offset;                      // Type bit offset (may be zero.)
+  unsigned Flags;                       // Miscellaneous flags.
 
 public:
   TypeDesc(unsigned T);
@@ -297,6 +303,12 @@ public:
   uint64_t getSize()                         const { return Size; }
   uint64_t getAlign()                        const { return Align; }
   uint64_t getOffset()                       const { return Offset; }
+  bool isPrivate() const {
+    return (Flags & FlagPrivate) != 0;
+  }
+  bool isProtected() const {
+    return (Flags & FlagProtected) != 0;
+  }
   void setContext(DebugInfoDesc *C)                { Context = C; }
   void setName(const std::string &N)               { Name = N; }
   void setFile(CompileUnitDesc *U) {
@@ -306,6 +318,8 @@ public:
   void setSize(uint64_t S)                         { Size = S; }
   void setAlign(uint64_t A)                        { Align = A; }
   void setOffset(uint64_t O)                       { Offset = O; }
+  void setIsPrivate()                              { Flags |= FlagPrivate; }
+  void setIsProtected()                            { Flags |= FlagProtected; }
   
   /// ApplyToFields - Target the visitor to the fields of the TypeDesc.
   ///
@@ -572,6 +586,7 @@ class GlobalDesc : public AnchoredDesc {
 private:
   DebugInfoDesc *Context;               // Context debug descriptor.
   std::string Name;                     // Global name.
+  std::string DisplayName;              // C++ unmangled name.
   DebugInfoDesc *File;                  // Defined compile unit (may be NULL.)
   unsigned Line;                        // Defined line# (may be zero.)
   DebugInfoDesc *TyDesc;                // Type debug descriptor.
@@ -585,6 +600,7 @@ public:
   // Accessors
   DebugInfoDesc *getContext()                const { return Context; }
   const std::string &getName()               const { return Name; }
+  const std::string &getDisplayName()        const { return DisplayName; }
   CompileUnitDesc *getFile() const {
     return static_cast<CompileUnitDesc *>(File);
   }
@@ -596,6 +612,7 @@ public:
   bool isDefinition()                        const { return IsDefinition; }
   void setContext(DebugInfoDesc *C)                { Context = C; }
   void setName(const std::string &N)               { Name = N; }
+  void setDisplayName(const std::string &N)        { DisplayName = N; }
   void setFile(CompileUnitDesc *U) {
     File = static_cast<DebugInfoDesc *>(U);
   }
index 55bac8b11bcdb1d73df482896e04aa19cbbad7b5..14bb9622edb9e106ff8effe7c9d31d128cd181d5 100644 (file)
@@ -1383,6 +1383,12 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc, CompileUnit *Unit) {
         Block->AddUInt(DW_FORM_udata, FieldOffset >> 3);
         Block->ComputeSize(*this);
         Member->AddBlock(DW_AT_data_member_location, 0, Block);
+
+        if (MemberDesc->isProtected()) {
+          Member->AddUInt(DW_AT_accessibility, 0, DW_ACCESS_protected);
+        } else if (MemberDesc->isPrivate()) {
+          Member->AddUInt(DW_AT_accessibility, 0, DW_ACCESS_private);
+        }
         
         Ty->AddChild(Member);
       }
index c1aac50573a64aa7a3d292cde8b976a6e52a0e30..54fb1b923cad78ed1b72bd7e3238905b90ca54a9 100644 (file)
@@ -671,6 +671,7 @@ TypeDesc::TypeDesc(unsigned T)
 , Size(0)
 , Align(0)
 , Offset(0)
+, Flags(0)
 {}
 
 /// ApplyToFields - Target the visitor to the fields of the TypeDesc.
@@ -685,6 +686,7 @@ void TypeDesc::ApplyToFields(DIVisitor *Visitor) {
   Visitor->Apply(Size);
   Visitor->Apply(Align);
   Visitor->Apply(Offset);
+  if (getVersion() > LLVMDebugVersion4) Visitor->Apply(Flags);
 }
 
 /// getDescString - Return a string used to compose global names and labels.
@@ -710,7 +712,8 @@ void TypeDesc::dump() {
             << "Line(" << Line << "), "
             << "Size(" << Size << "), "
             << "Align(" << Align << "), "
-            << "Offset(" << Offset << ")\n";
+            << "Offset(" << Offset << "), "
+            << "Flags(" << Flags << ")\n";
 }
 #endif
 
@@ -1029,6 +1032,7 @@ GlobalDesc::GlobalDesc(unsigned T)
 : AnchoredDesc(T)
 , Context(0)
 , Name("")
+, DisplayName("")
 , File(NULL)
 , Line(0)
 , TyDesc(NULL)
@@ -1043,6 +1047,7 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) {
 
   Visitor->Apply(Context);
   Visitor->Apply(Name);
+  if (getVersion() > LLVMDebugVersion4) Visitor->Apply(DisplayName);
   Visitor->Apply(File);
   Visitor->Apply(Line);
   Visitor->Apply(TyDesc);
@@ -1096,6 +1101,7 @@ void GlobalVariableDesc::dump() {
             << "Tag(" << getTag() << "), "
             << "Anchor(" << getAnchor() << "), "
             << "Name(\"" << getName() << "\"), "
+            << "DisplayName(\"" << getDisplayName() << "\"), "
             << "File(" << getFile() << "),"
             << "Line(" << getLine() << "),"
             << "Type(\"" << getType() << "\"), "
@@ -1148,6 +1154,7 @@ void SubprogramDesc::dump() {
             << "Tag(" << getTag() << "), "
             << "Anchor(" << getAnchor() << "), "
             << "Name(\"" << getName() << "\"), "
+            << "DisplayName(\"" << getDisplayName() << "\"), "
             << "File(" << getFile() << "),"
             << "Line(" << getLine() << "),"
             << "Type(\"" << getType() << "\"), "
index 9c2efc3881686aa6aa0529a04073a28830b83f3d..a85d9a4b223fc65c87997780fe2ad92117544523 100644 (file)
@@ -61,7 +61,7 @@ Value *DbgInfoIntrinsic::StripCast(Value *C) {
 
 std::string DbgStopPointInst::getFileName() const {
   // Once the operand indices are verified, update this assert
-  assert(LLVMDebugVersion == (4 << 16) && "Verify operand indices");
+  assert(LLVMDebugVersion == (5 << 16) && "Verify operand indices");
   GlobalVariable *GV = cast<GlobalVariable>(getContext());
   ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
   return CS->getOperand(3)->getStringValue();
@@ -69,7 +69,7 @@ std::string DbgStopPointInst::getFileName() const {
 
 std::string DbgStopPointInst::getDirectory() const {
   // Once the operand indices are verified, update this assert
-  assert(LLVMDebugVersion == (4 << 16) && "Verify operand indices");
+  assert(LLVMDebugVersion == (5 << 16) && "Verify operand indices");
   GlobalVariable *GV = cast<GlobalVariable>(getContext());
   ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
   return CS->getOperand(4)->getStringValue();