DebugInfo: GDBIndexEntry*String conversion functions now return const char* for easy...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 20 Sep 2013 00:33:15 +0000 (00:33 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 20 Sep 2013 00:33:15 +0000 (00:33 +0000)
This was previously invoking UB by passing a user-defined type to
format. Thanks to Jordan Rose for pointing this out.

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

include/llvm/Support/Dwarf.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/Support/Dwarf.cpp

index 868669987c801ca1b30a2509396d4f52550ee234..70c46db0e97b531f9ddb0278a2857e5160d2fd04 100644 (file)
@@ -17,7 +17,6 @@
 #define LLVM_SUPPORT_DWARF_H
 
 #include "llvm/Support/DataTypes.h"
-#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 
@@ -803,14 +802,14 @@ enum GDBIndexEntryKind {
   GIEK_UNUSED7
 };
 
-StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
+const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind);
 
 enum GDBIndexEntryLinkage {
   GIEL_EXTERNAL,
   GIEL_STATIC
 };
 
-StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
+const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
 
 /// The gnu_pub* kind looks like:
 ///
index f45e2f243100afabb05c289095b7397c1e2b7ded..76d63c722b314e246837beda9bb3465f2534769c 100644 (file)
@@ -2426,7 +2426,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
       if (GnuStyle) {
         dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
         Asm->OutStreamer.AddComment(
-            "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
+            Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
             dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
         Asm->EmitInt8(Desc.toBits());
       }
@@ -2488,7 +2488,7 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
       if (GnuStyle) {
         dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
         Asm->OutStreamer.AddComment(
-            "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
+            Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
             dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
         Asm->EmitInt8(Desc.toBits());
       }
index 0e64035c0bded00b86584bca31ae4e8d54572a3d..f4993454b68fe8b6ce0f387d7ebe6579b2198b45 100644 (file)
@@ -742,7 +742,7 @@ const char *llvm::dwarf::AtomTypeString(unsigned AT) {
   return 0;
 }
 
-StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
+const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
   switch (Kind) {
   case GIEK_NONE:
     return "NONE";
@@ -764,7 +764,7 @@ StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
   llvm_unreachable("Unknown GDBIndexEntryKind value");
 }
 
-StringRef llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
+const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
   switch (Linkage) {
   case GIEL_EXTERNAL:
     return "EXTERNAL";