summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp45
1 files changed, 12 insertions, 33 deletions
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 7d45d4beebb..6fd2f844b29 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -25,27 +25,6 @@
using namespace llvm;
-static const std::vector<StringRef>
-getValueAsListOfStrings(Record &R, StringRef FieldName) {
- ListInit *List = R.getValueAsListInit(FieldName);
- assert (List && "Got a null ListInit");
-
- std::vector<StringRef> Strings;
- Strings.reserve(List->getSize());
-
- for (ListInit::const_iterator i = List->begin(), e = List->end();
- i != e;
- ++i) {
- assert(*i && "Got a null element in a ListInit");
- if (StringInit *S = dyn_cast<StringInit>(*i))
- Strings.push_back(S->getValue());
- else
- assert(false && "Got a non-string, non-code element in a ListInit");
- }
-
- return Strings;
-}
-
static std::string ReadPCHRecord(StringRef type) {
return StringSwitch<std::string>(type)
.EndsWith("Decl *", "GetLocalDeclAs<"
@@ -555,12 +534,12 @@ namespace {
class EnumArgument : public Argument {
std::string type;
- std::vector<StringRef> values, enums, uniques;
+ std::vector<std::string> values, enums, uniques;
public:
EnumArgument(Record &Arg, StringRef Attr)
: Argument(Arg, Attr), type(Arg.getValueAsString("Type")),
- values(getValueAsListOfStrings(Arg, "Values")),
- enums(getValueAsListOfStrings(Arg, "Enums")),
+ values(Arg.getValueAsListOfStrings("Values")),
+ enums(Arg.getValueAsListOfStrings("Enums")),
uniques(enums)
{
// Calculate the various enum values
@@ -593,8 +572,8 @@ namespace {
OS << type << " " << getUpperName();
}
void writeDeclarations(raw_ostream &OS) const {
- std::vector<StringRef>::const_iterator i = uniques.begin(),
- e = uniques.end();
+ std::vector<std::string>::const_iterator i = uniques.begin(),
+ e = uniques.end();
// The last one needs to not have a comma.
--e;
@@ -623,7 +602,7 @@ namespace {
}
void writeDump(raw_ostream &OS) const {
OS << " switch(SA->get" << getUpperName() << "()) {\n";
- for (std::vector<StringRef>::const_iterator I = uniques.begin(),
+ for (std::vector<std::string>::const_iterator I = uniques.begin(),
E = uniques.end(); I != E; ++I) {
OS << " case " << getAttrName() << "Attr::" << *I << ":\n";
OS << " OS << \" " << *I << "\";\n";
@@ -651,13 +630,13 @@ namespace {
class VariadicEnumArgument: public VariadicArgument {
std::string type, QualifiedTypeName;
- std::vector<StringRef> values, enums, uniques;
+ std::vector<std::string> values, enums, uniques;
public:
VariadicEnumArgument(Record &Arg, StringRef Attr)
: VariadicArgument(Arg, Attr, Arg.getValueAsString("Type")),
type(Arg.getValueAsString("Type")),
- values(getValueAsListOfStrings(Arg, "Values")),
- enums(getValueAsListOfStrings(Arg, "Enums")),
+ values(Arg.getValueAsListOfStrings("Values")),
+ enums(Arg.getValueAsListOfStrings("Enums")),
uniques(enums)
{
// Calculate the various enum values
@@ -673,8 +652,8 @@ namespace {
bool isVariadicEnumArg() const { return true; }
void writeDeclarations(raw_ostream &OS) const {
- std::vector<StringRef>::const_iterator i = uniques.begin(),
- e = uniques.end();
+ std::vector<std::string>::const_iterator i = uniques.begin(),
+ e = uniques.end();
// The last one needs to not have a comma.
--e;
@@ -693,7 +672,7 @@ namespace {
<< "_iterator I = SA->" << getLowerName() << "_begin(), E = SA->"
<< getLowerName() << "_end(); I != E; ++I) {\n";
OS << " switch(*I) {\n";
- for (std::vector<StringRef>::const_iterator UI = uniques.begin(),
+ for (std::vector<std::string>::const_iterator UI = uniques.begin(),
UE = uniques.end(); UI != UE; ++UI) {
OS << " case " << getAttrName() << "Attr::" << *UI << ":\n";
OS << " OS << \" " << *UI << "\";\n";
OpenPOWER on IntegriCloud