#include "ARMAttributeParser.h"
#include "StreamWriter.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/LEB128.h"
{ "Tag_Symbol", ARMBuildAttrs::Symbol },
};
-template <typename type_, size_t size_>
-size_t countof(const type_ (&)[size_]) {
- return size_;
-}
-
namespace llvm {
#define ATTRIBUTE_HANDLER(Attr_) \
{ ARMBuildAttrs::Attr_, &ARMAttributeParser::Attr_ }
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
case 'R': Profile = "Real-time"; break;
case 'M': Profile = "Microcontroller"; break;
case 'S': Profile = "Classic"; break;
- case '0': Profile = "None"; break;
+ case 0: Profile = "None"; break;
}
PrintAttribute(Tag, Encoded, Profile);
static const char *Strings[] = { "Not Permitted", "Permitted" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "Thumb-1", "Thumb-2" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "WMMXv1", "WMMXv2" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "v6", "Static Base", "TLS", "Unused" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Absolute", "PC-relative", "Not Permitted" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "Direct", "GOT-Indirect" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "IEEE-754", "Runtime" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Unsupported", "IEEE-754", "Sign Only" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "IEEE-754" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "IEEE-754" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
- Twine Description;
- if (Value < countof(Strings))
- Description = StringRef(Strings[Value]);
+ std::string Description;
+ if (Value < array_lengthof(Strings))
+ Description = std::string(Strings[Value]);
else if (Value <= 12)
- Description = Twine("8-byte alignment, ") + utostr(1 << Value)
- + Twine("-byte extended alignment");
+ Description = std::string("8-byte alignment, ") + utostr(1 << Value)
+ + std::string("-byte extended alignment");
else
Description = "Invalid";
- PrintAttribute(Tag, Value, Description.str());
+ PrintAttribute(Tag, Value, Description);
}
void ARMAttributeParser::ABI_align_preserved(AttrType Tag, const uint8_t *Data,
uint64_t Value = ParseInteger(Data, Offset);
- Twine Description;
- if (Value < countof(Strings))
- Description = StringRef(Strings[Value]);
+ std::string Description;
+ if (Value < array_lengthof(Strings))
+ Description = std::string(Strings[Value]);
else if (Value <= 12)
- Description = Twine("8-byte stack alignment, ") + utostr(1 << Value)
- + Twine("-byte data alignment");
+ Description = std::string("8-byte stack alignment, ") + utostr(1 << Value)
+ + std::string("-byte data alignment");
else
Description = "Invalid";
- PrintAttribute(Tag, Value, Description.str());
+ PrintAttribute(Tag, Value, Description);
}
void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data,
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "AAPCS", "iWMMX", "Custom" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "v6-style" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "If Available", "Permitted" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "IEEE-754", "VFPv3" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "Permitted" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
static const char *Strings[] = { "Not Permitted", "Permitted" };
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
};
uint64_t Value = ParseInteger(Data, Offset);
- StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
+ StringRef ValueDesc =
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
Offset += Length;
bool Handled = false;
- for (unsigned AHI = 0, AHE = countof(DisplayRoutines);
+ for (unsigned AHI = 0, AHE = array_lengthof(DisplayRoutines);
AHI != AHE && !Handled; ++AHI) {
if (DisplayRoutines[AHI].Attribute == Tag) {
(this->*DisplayRoutines[AHI].Routine)(ARMBuildAttrs::AttrType(Tag),