[llvm] r283277 - Use StringRef instead of raw pointers in ARMBuildAttrs (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 17:15:18 PDT 2016
Author: mehdi_amini
Date: Tue Oct 4 19:15:18 2016
New Revision: 283277
URL: http://llvm.org/viewvc/llvm-project?rev=283277&view=rev
Log:
Use StringRef instead of raw pointers in ARMBuildAttrs (NFC)
Modified:
llvm/trunk/lib/Support/ARMBuildAttrs.cpp
Modified: llvm/trunk/lib/Support/ARMBuildAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ARMBuildAttrs.cpp?rev=283277&r1=283276&r2=283277&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ARMBuildAttrs.cpp (original)
+++ llvm/trunk/lib/Support/ARMBuildAttrs.cpp Tue Oct 4 19:15:18 2016
@@ -15,7 +15,7 @@ using namespace llvm;
namespace {
const struct {
ARMBuildAttrs::AttrType Attr;
- const char *TagName;
+ StringRef TagName;
} ARMAttributeTags[] = {
{ ARMBuildAttrs::File, "Tag_File" },
{ ARMBuildAttrs::Section, "Tag_Section" },
@@ -78,17 +78,23 @@ StringRef AttrTypeAsString(unsigned Attr
StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix) {
for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
TI != TE; ++TI)
- if (ARMAttributeTags[TI].Attr == Attr)
- return ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4);
+ if (ARMAttributeTags[TI].Attr == Attr) {
+ auto TagName = ARMAttributeTags[TI].TagName;
+ return HasTagPrefix ? TagName : TagName.drop_front(4);
+ }
return "";
}
int AttrTypeFromString(StringRef Tag) {
bool HasTagPrefix = Tag.startswith("Tag_");
- for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
- TI != TE; ++TI)
- if (StringRef(ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4)) == Tag)
+ for (unsigned TI = 0,
+ TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
+ TI != TE; ++TI) {
+ auto TagName = ARMAttributeTags[TI].TagName;
+ if (TagName.drop_front(HasTagPrefix ? 0 : 4) == Tag) {
return ARMAttributeTags[TI].Attr;
+ }
+ }
return -1;
}
}
More information about the llvm-commits
mailing list