Stop abusing StringRef. Fixes the Windows build.
I've also removed the duplicate check for PARSED_ATTR since it seems
unnecessary, and would have made the code more complicated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158716 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp
index 61f07e2..0df566f 100644
--- a/utils/TableGen/ClangAttrEmitter.cpp
+++ b/utils/TableGen/ClangAttrEmitter.cpp
@@ -966,7 +966,8 @@
std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings");
for (std::vector<Record*>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) {
- StringRef Spelling = (*I)->getValueAsString("Name");
+ SmallString<64> Spelling;
+ Spelling += (*I)->getValueAsString("Name");
OS << ".Case(\"" << Spelling << "\", true)\n";
}
}
@@ -1074,6 +1075,9 @@
<< "} // end namespace clang\n";
}
+}
+#include <cstdio>
+namespace clang {
// Emits the list of parsed attributes.
void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
@@ -1083,7 +1087,6 @@
OS << "#endif\n\n";
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
- std::set<StringRef> ProcessedAttrs;
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
I != E; ++I) {
@@ -1098,16 +1101,12 @@
for (std::vector<Record*>::const_iterator I = Spellings.begin(),
E = Spellings.end(); I != E; ++I) {
- StringRef AttrName = (*I)->getValueAsString("Name");
+ SmallString<64> AttrName;
+ AttrName += (*I)->getValueAsString("Name");
- AttrName = NormalizeAttrName(AttrName);
- // skip if a normalized version has been processed.
- if (ProcessedAttrs.find(AttrName) != ProcessedAttrs.end())
- continue;
- else
- ProcessedAttrs.insert(AttrName);
+ StringRef Spelling = NormalizeAttrName(AttrName);
- OS << "PARSED_ATTR(" << AttrName << ")\n";
+ OS << "PARSED_ATTR(" << Spelling << ")\n";
}
} else {
StringRef AttrName = Attr.getName();
@@ -1138,9 +1137,10 @@
for (std::vector<Record*>::const_iterator I = Spellings.begin(),
E = Spellings.end(); I != E; ++I) {
- StringRef RawSpelling = (*I)->getValueAsString("Name");
+ SmallString<64> RawSpelling;
+ RawSpelling += (*I)->getValueAsString("Name");
StringRef AttrName = NormalizeAttrName(DistinctSpellings
- ? RawSpelling
+ ? StringRef(RawSpelling)
: StringRef(Attr.getName()));
SmallString<64> Spelling;