[llvm] r191060 - DebugInfo: GDBIndexEntry*String conversion functions now return const char* for easy llvm::formating
David Blaikie
dblaikie at gmail.com
Thu Sep 19 17:33:16 PDT 2013
Author: dblaikie
Date: Thu Sep 19 19:33:15 2013
New Revision: 191060
URL: http://llvm.org/viewvc/llvm-project?rev=191060&view=rev
Log:
DebugInfo: GDBIndexEntry*String conversion functions now return const char* for easy llvm::formating
This was previously invoking UB by passing a user-defined type to
format. Thanks to Jordan Rose for pointing this out.
Modified:
llvm/trunk/include/llvm/Support/Dwarf.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/Support/Dwarf.cpp
Modified: llvm/trunk/include/llvm/Support/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=191060&r1=191059&r2=191060&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Dwarf.h (original)
+++ llvm/trunk/include/llvm/Support/Dwarf.h Thu Sep 19 19:33:15 2013
@@ -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:
///
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=191060&r1=191059&r2=191060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Sep 19 19:33:15 2013
@@ -2426,7 +2426,7 @@ void DwarfDebug::emitDebugPubNames(bool
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
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());
}
Modified: llvm/trunk/lib/Support/Dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=191060&r1=191059&r2=191060&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Dwarf.cpp (original)
+++ llvm/trunk/lib/Support/Dwarf.cpp Thu Sep 19 19:33:15 2013
@@ -742,7 +742,7 @@ const char *llvm::dwarf::AtomTypeString(
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::GDBIndexEntryKind
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";
More information about the llvm-commits
mailing list