};
// Unique the enums, but maintain the original declaration ordering.
- std::vector<std::string>
- uniqueEnumsInOrder(const std::vector<std::string> &enums) {
- std::vector<std::string> uniques;
+ std::vector<StringRef>
+ uniqueEnumsInOrder(const std::vector<StringRef> &enums) {
+ std::vector<StringRef> uniques;
SmallDenseSet<StringRef, 8> unique_set;
for (const auto &i : enums) {
if (unique_set.insert(i).second)
class EnumArgument : public Argument {
std::string type;
- std::vector<std::string> values, enums, uniques;
+ std::vector<StringRef> values, enums, uniques;
+
public:
EnumArgument(const Record &Arg, StringRef Attr)
: Argument(Arg, Attr), type(Arg.getValueAsString("Type")),
class VariadicEnumArgument: public VariadicArgument {
std::string type, QualifiedTypeName;
- std::vector<std::string> values, enums, uniques;
+ std::vector<StringRef> values, enums, uniques;
protected:
void writeValueImpl(raw_ostream &OS) const override {
}
std::string getEnumValueName() const {
- std::string Result =
- "SubjectMatchRule_" + MetaSubject->getValueAsString("Name");
+ SmallString<128> Result;
+ Result += "SubjectMatchRule_";
+ Result += MetaSubject->getValueAsString("Name");
if (isSubRule()) {
Result += "_";
if (isNegatedSubRule())
}
if (isAbstractRule())
Result += "_abstract";
- return Result;
+ return Result.str();
}
std::string getEnumValue() const { return "attr::" + getEnumValueName(); }
// append a unique suffix to distinguish this set of target checks from other
// TargetSpecificAttr records.
static void GenerateTargetSpecificAttrChecks(const Record *R,
- std::vector<std::string> &Arches,
+ std::vector<StringRef> &Arches,
std::string &Test,
std::string *FnName) {
// It is assumed that there will be an llvm::Triple object
Test += "(";
for (auto I = Arches.begin(), E = Arches.end(); I != E; ++I) {
- std::string Part = *I;
- Test += "T.getArch() == llvm::Triple::" + Part;
+ StringRef Part = *I;
+ Test += "T.getArch() == llvm::Triple::";
+ Test += Part;
if (I + 1 != E)
Test += " || ";
if (FnName)
// We know that there was at least one arch test, so we need to and in the
// OS tests.
Test += " && (";
- std::vector<std::string> OSes = R->getValueAsListOfStrings("OSes");
+ std::vector<StringRef> OSes = R->getValueAsListOfStrings("OSes");
for (auto I = OSes.begin(), E = OSes.end(); I != E; ++I) {
- std::string Part = *I;
+ StringRef Part = *I;
- Test += "T.getOS() == llvm::Triple::" + Part;
+ Test += "T.getOS() == llvm::Triple::";
+ Test += Part;
if (I + 1 != E)
Test += " || ";
if (FnName)
// If one or more CXX ABIs are specified, check those as well.
if (!R->isValueUnset("CXXABIs")) {
Test += " && (";
- std::vector<std::string> CXXABIs = R->getValueAsListOfStrings("CXXABIs");
+ std::vector<StringRef> CXXABIs = R->getValueAsListOfStrings("CXXABIs");
for (auto I = CXXABIs.begin(), E = CXXABIs.end(); I != E; ++I) {
- std::string Part = *I;
- Test += "Target.getCXXABI().getKind() == TargetCXXABI::" + Part;
+ StringRef Part = *I;
+ Test += "Target.getCXXABI().getKind() == TargetCXXABI::";
+ Test += Part;
if (I + 1 != E)
Test += " || ";
if (FnName)
std::string Test;
if (Attr->isSubClassOf("TargetSpecificAttr")) {
const Record *R = Attr->getValueAsDef("Target");
- std::vector<std::string> Arches = R->getValueAsListOfStrings("Arches");
+ std::vector<StringRef> Arches = R->getValueAsListOfStrings("Arches");
GenerateTargetSpecificAttrChecks(R, Arches, Test, nullptr);
// If this is the C++11 variety, also add in the LangOpts test.
// Get the list of architectures to be tested for.
const Record *R = Attr.getValueAsDef("Target");
- std::vector<std::string> Arches = R->getValueAsListOfStrings("Arches");
+ std::vector<StringRef> Arches = R->getValueAsListOfStrings("Arches");
if (Arches.empty()) {
PrintError(Attr.getLoc(), "Empty list of target architectures for a "
"target-specific attr");
std::string APK = Attr.getValueAsString("ParseKind");
for (const auto &I : Dupes) {
if (I.first == APK) {
- std::vector<std::string> DA = I.second->getValueAsDef("Target")
- ->getValueAsListOfStrings("Arches");
- std::move(DA.begin(), DA.end(), std::back_inserter(Arches));
+ std::vector<StringRef> DA =
+ I.second->getValueAsDef("Target")->getValueAsListOfStrings(
+ "Arches");
+ Arches.insert(Arches.end(), DA.begin(), DA.end());
}
}
}
}
// Pretend no-X and Xno-Y options are aliases of X and XY.
- auto Name = R->getValueAsString("Name");
+ std::string Name = R->getValueAsString("Name");
if (Name.size() >= 4) {
if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
Aliases[OptionsByName[Name.substr(3)]].push_back(R);
}
void emitOptionWithArgs(StringRef Prefix, const Record *Option,
- ArrayRef<std::string> Args, raw_ostream &OS) {
+ ArrayRef<StringRef> Args, raw_ostream &OS) {
OS << Prefix << escapeRST(Option->getValueAsString("Name"));
std::pair<StringRef, StringRef> Separators =
}
}
- emitOptionWithArgs(Prefix, Option, Args, OS);
+ emitOptionWithArgs(Prefix, Option, std::vector<StringRef>(Args.begin(), Args.end()), OS);
auto AliasArgs = Option->getValueAsListOfStrings("AliasArgs");
if (!AliasArgs.empty()) {
Record *Alias = Option->getValueAsDef("Alias");
OS << " (equivalent to ";
- emitOptionWithArgs(Alias->getValueAsListOfStrings("Prefixes").front(),
- Alias, Option->getValueAsListOfStrings("AliasArgs"), OS);
+ emitOptionWithArgs(
+ Alias->getValueAsListOfStrings("Prefixes").front(), Alias,
+ AliasArgs, OS);
OS << ")";
}
}
forEachOptionName(Option, DocInfo, [&](const Record *Option) {
for (auto &Prefix : Option->getValueAsListOfStrings("Prefixes"))
SphinxOptionIDs.push_back(
- getSphinxOptionID(Prefix + Option->getValueAsString("Name")));
+ getSphinxOptionID((Prefix + Option->getValueAsString("Name")).str()));
});
assert(!SphinxOptionIDs.empty() && "no flags for option");
static std::map<std::string, int> NextSuffix;