[Lldb-commits] [lldb] r283298 - Re-commit "Use StringRef in Support/Darf APIs (NFC)"

Mehdi Amini via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 4 22:59:29 PDT 2016


Author: mehdi_amini
Date: Wed Oct  5 00:59:29 2016
New Revision: 283298

URL: http://llvm.org/viewvc/llvm-project?rev=283298&view=rev
Log:
Re-commit "Use StringRef in Support/Darf APIs (NFC)"

This reverts commit r283285 and re-commit r283275 with
a fix for format("%s", Str); where Str is a StringRef.

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp?rev=283298&r1=283297&r2=283298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp Wed Oct  5 00:59:29 2016
@@ -21,53 +21,53 @@ const char *DW_TAG_value_to_name(uint32_
   if (val == 0)
     return "NULL";
 
-  const char *llvmstr = llvm::dwarf::TagString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::TagString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_TAG constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_CHILDREN_value_to_name(uint8_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::ChildrenString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::ChildrenString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_CHILDREN constant: 0x%x",
              val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_AT_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_FORM_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::FormEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_OP_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::OperationEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 DRC_class DW_OP_value_to_class(uint32_t val) {
@@ -383,145 +383,145 @@ DRC_class DW_OP_value_to_class(uint32_t
 
 const char *DW_ATE_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_ACCESS_value_to_name(uint32_t val) {
   static char invalid[100];
 
-  const char *llvmstr = llvm::dwarf::AccessibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AccessibilityString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_ACCESS constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIS_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VisibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VisibilityString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_VIS constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIRTUALITY_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VirtualityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VirtualityString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_VIRTUALITY constant: 0x%x",
              val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_LANG_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::LanguageString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_LANG constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_ID_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::CaseString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::CaseString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_ID constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_CC_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::ConventionString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::ConventionString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_CC constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_INL_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::InlineCodeString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::InlineCodeString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_INL constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_ORD_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::ArrayOrderString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::ArrayOrderString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_ORD constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_DSC_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::DiscriminantString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::DiscriminantString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_DSC constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_LNS_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::LNStandardString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::LNStandardString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_LNS constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_LNE_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::LNExtendedString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::LNExtendedString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_LNE constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_MACINFO_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::MacinfoString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::MacinfoString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_MACINFO constant: 0x%x",
              val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_CFA_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::CallFrameString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::CallFrameString(val);
+  if (llvmstr.empty()) {
     snprintf(invalid, sizeof(invalid), "Unknown DW_CFA constant: 0x%x", val);
     return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 DW_TAG_CategoryEnum get_tag_category(uint16_t tag) {




More information about the lldb-commits mailing list