[llvm-commits] [llvm-gcc-4.2] r89868 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Devang Patel dpatel at apple.com
Wed Nov 25 09:38:44 PST 2009


Author: dpatel
Date: Wed Nov 25 11:38:43 2009
New Revision: 89868

URL: http://llvm.org/viewvc/llvm-project?rev=89868&view=rev
Log:
Use StringRef (again) in DebugInfo interface.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=89868&r1=89867&r2=89868&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Nov 25 11:38:43 2009
@@ -122,7 +122,7 @@
 
 /// GetNodeName - Returns the name stored in a node regardless of whether the
 /// node is a TYPE or DECL.
-static const char *GetNodeName(tree Node) {
+static StringRef GetNodeName(tree Node) {
   tree Name = NULL;
   
   if (DECL_P(Node)) {
@@ -136,11 +136,11 @@
       return IDENTIFIER_POINTER(Name);
     } else if (TREE_CODE(Name) == TYPE_DECL && DECL_NAME(Name) &&
                !DECL_IGNORED_P(Name)) {
-      return IDENTIFIER_POINTER(DECL_NAME(Name));
+      return StringRef(IDENTIFIER_POINTER(DECL_NAME(Name)));
     }
   }
   
-  return NULL;
+  return StringRef();
 }
 
 /// GetNodeLocation - Returns the location stored in a node  regardless of
@@ -181,12 +181,12 @@
   return Location;
 }
 
-static const char *getLinkageName(tree Node) {
+static StringRef getLinkageName(tree Node) {
 
   // Use llvm value name as linkage name if it is available.
   if (DECL_LLVM_SET_P(Node)) {
     Value *V = DECL_LLVM(Node);
-    return V->getName().data();
+    return V->getName();
   }
 
   tree decl_name = DECL_NAME(Node);
@@ -194,10 +194,10 @@
     if (TREE_PUBLIC(Node) &&
         DECL_ASSEMBLER_NAME(Node) != DECL_NAME(Node) && 
         !DECL_ABSTRACT(Node)) {
-      return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(Node));
+      return StringRef(IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(Node)));
     } 
   }
-  return NULL;
+  return StringRef();
 }
 
 DebugInfo::DebugInfo(Module *m)
@@ -234,7 +234,7 @@
                                   BasicBlock *CurBB) {
   // Gather location information.
   expanded_location Loc = GetNodeLocation(FnDecl, false);
-  const char *LinkageName = getLinkageName(FnDecl);
+  StringRef LinkageName = getLinkageName(FnDecl);
 
   unsigned lineno = CurLineNo;
   if (isCopyOrDestroyHelper(FnDecl))
@@ -396,8 +396,7 @@
   // Gather location information.
   expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl));
   DIType TyD = getOrCreateType(TREE_TYPE(decl));
-  std::string DispNameStr = GV->getNameStr();
-  const char *DispName = DispNameStr.c_str();
+  StringRef DispName = GV->getName();
   if (DECL_NAME(decl)) {
     if (IDENTIFIER_POINTER(DECL_NAME(decl)))
       DispName = IDENTIFIER_POINTER(DECL_NAME(decl));
@@ -414,7 +413,7 @@
 /// createBasicType - Create BasicType.
 DIType DebugInfo::createBasicType(tree type) {
 
-  const char *TypeName = GetNodeName(type);
+  StringRef TypeName = GetNodeName(type);
   uint64_t Size = NodeSizeInBits(type);
   uint64_t Align = NodeAlignInBits(type);
 
@@ -479,7 +478,7 @@
     DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
 
   return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
-                                          findRegion(type), NULL,
+                                          findRegion(type), StringRef(),
                                           getOrCreateCompileUnit(NULL), 
                                           0, 0, 0, 0, 0,
                                           llvm::DIType(), EltTypeArray);
@@ -500,7 +499,7 @@
     Flags |= llvm::DIType::FlagBlockByrefStruct;
   expanded_location Loc = GetNodeLocation(type);
 
-  const char *PName = FromTy.getName();
+  StringRef PName = FromTy.getName();
   return  DebugFactory.CreateDerivedType(Tag, findRegion(type), PName,
                                          getOrCreateCompileUnit(NULL), 
                                          0 /*line no*/, 
@@ -557,7 +556,7 @@
     DebugFactory.GetOrCreateArray(Subscripts.data(), Subscripts.size());
   expanded_location Loc = GetNodeLocation(type);
   return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
-                                          findRegion(type), NULL,
+                                          findRegion(type), StringRef(),
                                           getOrCreateCompileUnit(Loc.file), 0, 
                                           NodeSizeInBits(type), 
                                           NodeAlignInBits(type), 0, 0,
@@ -638,13 +637,13 @@
   /// also while creating FwdDecl for now.
   std::string FwdName;
   if (TYPE_CONTEXT(type)) {
-    const char *TypeContextName = GetNodeName(TYPE_CONTEXT(type));
-    if (TypeContextName)
+    StringRef TypeContextName = GetNodeName(TYPE_CONTEXT(type));
+    if (!TypeContextName.empty())
       FwdName = TypeContextName;
   }
-  const char *TypeName = GetNodeName(type);
-  if (TypeName)
-    FwdName = FwdName + TypeName;
+  StringRef TypeName = GetNodeName(type);
+  if (!TypeName.empty())
+    FwdName = FwdName + TypeName.data();
   unsigned Flags = llvm::DIType::FlagFwdDecl;
   if (TYPE_BLOCK_IMPL_STRUCT(type))
     Flags |= llvm::DIType::FlagAppleBlock;
@@ -680,7 +679,7 @@
       // FIXME : name, size, align etc...
       DIType DTy = 
         DebugFactory.CreateDerivedType(DW_TAG_inheritance, 
-                                       findRegion(type), NULL,
+                                       findRegion(type), StringRef(),
                                        llvm::DICompileUnit(), 0,0,0, 
                                        getINTEGER_CSTVal(BINFO_OFFSET(BInfo)),
                                        0, BaseClass);
@@ -711,7 +710,7 @@
       // Field type is the declared type of the field.
       tree FieldNodeType = FieldType(Member);
       DIType MemberType = getOrCreateType(FieldNodeType);
-      const char *MemberName = GetNodeName(Member);
+      StringRef MemberName = GetNodeName(Member);
       unsigned Flags = 0;
       if (TREE_PROTECTED(Member))
         Flags = llvm::DIType::FlagProtected;
@@ -744,7 +743,7 @@
     expanded_location MemLoc = GetNodeLocation(Member, false);
     
     const char *MemberName = lang_hooks.dwarf_name(Member, 0);        
-    const char *LinkageName = getLinkageName(Member);
+    StringRef LinkageName = getLinkageName(Member);
     DIType SPTy = getOrCreateType(TREE_TYPE(Member));
     DISubprogram SP = 
       DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
@@ -799,7 +798,7 @@
 
   if (TYPE_VOLATILE(type)) {
     Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type, 
-                                        findRegion(type), NULL,
+                                        findRegion(type), StringRef(),
                                         getOrCreateCompileUnit(NULL), 
                                         0 /*line no*/, 
                                         NodeSizeInBits(type),
@@ -812,7 +811,7 @@
 
   if (TYPE_READONLY(type)) 
     Ty =  DebugFactory.CreateDerivedType(DW_TAG_const_type, 
-                                         findRegion(type), NULL,
+                                         findRegion(type), StringRef(),
                                          getOrCreateCompileUnit(NULL), 
                                          0 /*line no*/, 
                                          NodeSizeInBits(type),
@@ -979,7 +978,7 @@
   else
     LangTag = DW_LANG_C89;
 
-  const char *Flags = NULL;
+  StringRef Flags;
   // Do this only when RC_DEBUG_OPTIONS environment variable is set to
   // a nonempty string. This is intended only for internal Apple use.
   char * debugopt = getenv("RC_DEBUG_OPTIONS");





More information about the llvm-commits mailing list