aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSean Hunt <scshunt@csclub.uwaterloo.ca>2012-06-19 23:57:03 +0000
committerSean Hunt <scshunt@csclub.uwaterloo.ca>2012-06-19 23:57:03 +0000
commit8e083e71d48f7f4d6ef40c00531c2e14df745486 (patch)
tree5ffbac1a9faf271bf15b49461210abedaeda2926 /utils
parent5ca8639f97663255880f0da81f1026a06a14d003 (diff)
Reapply r158700 and fixup patches, minus one hunk that slipped through and
caused a crash in an obscure case. On the plus side, it caused me to catch another bug by inspection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/ClangAttrEmitter.cpp98
1 files changed, 43 insertions, 55 deletions
diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp
index 7e1eaf8541..61fd86f170 100644
--- a/utils/TableGen/ClangAttrEmitter.cpp
+++ b/utils/TableGen/ClangAttrEmitter.cpp
@@ -769,7 +769,7 @@ void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
continue;
std::vector<Record*> ArgRecords = R.getValueAsListOfDefs("Args");
- std::vector<StringRef> Spellings = getValueAsListOfStrings(R, "Spellings");
+ std::vector<Record*> Spellings = R.getValueAsListOfDefs("Spellings");
std::vector<Argument*> Args;
for (ri = ArgRecords.begin(), re = ArgRecords.end(); ri != re; ++ri)
Args.push_back(createArgument(**ri, R.getName()));
@@ -789,9 +789,10 @@ void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
OS << "void " << R.getName() << "Attr::printPretty("
<< "llvm::raw_ostream &OS, ASTContext &Ctx) const {\n";
if (Spellings.begin() != Spellings.end()) {
- OS << " OS << \" __attribute__((" << *Spellings.begin();
+ StringRef Spelling = (*Spellings.begin())->getValueAsString("Name");
+ OS << " OS << \" __attribute__((" << Spelling;
if (Args.size()) OS << "(";
- if (*Spellings.begin()=="availability") {
+ if (Spelling == "availability") {
writeAvailabilityValue(OS);
} else {
for (ai = Args.begin(); ai != ae; ++ai) {
@@ -962,11 +963,10 @@ void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS) {
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end(); I != E; ++I) {
Record &Attr = **I;
- std::vector<StringRef> Spellings = getValueAsListOfStrings(Attr, "Spellings");
+ std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings");
- for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) {
- StringRef Spelling = *I;
- OS << ".Case(\"" << Spelling << "\", true)\n";
+ for (std::vector<Record*>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) {
+ OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", true)\n";
}
}
@@ -985,12 +985,16 @@ void EmitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) {
bool LateParsed = Attr.getValueAsBit("LateParsed");
if (LateParsed) {
- std::vector<StringRef> Spellings =
- getValueAsListOfStrings(Attr, "Spellings");
+ std::vector<Record*> Spellings =
+ Attr.getValueAsListOfDefs("Spellings");
- for (std::vector<StringRef>::const_iterator I = Spellings.begin(),
+ // FIXME: Handle non-GNU attributes
+ for (std::vector<Record*>::const_iterator I = Spellings.begin(),
E = Spellings.end(); I != E; ++I) {
- OS << ".Case(\"" << (*I) << "\", " << LateParsed << ")\n";
+ if ((*I)->getValueAsString("Variety") != "GNU")
+ continue;
+ OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", "
+ << LateParsed << ")\n";
}
}
}
@@ -1069,6 +1073,9 @@ void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
<< "} // 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";
@@ -1078,7 +1085,6 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
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) {
@@ -1088,24 +1094,21 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings");
if (SemaHandler) {
- std::vector<StringRef> Spellings =
- getValueAsListOfStrings(Attr, "Spellings");
-
- for (std::vector<StringRef>::const_iterator I = Spellings.begin(),
- E = Spellings.end(); I != E; ++I) {
- StringRef AttrName = *I;
+ if (DistinctSpellings) {
+ std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings");
+
+ for (std::vector<Record*>::const_iterator I = Spellings.begin(),
+ E = Spellings.end(); I != E; ++I) {
+ std::string 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(" << Spelling << ")\n";
+ }
+ } else {
+ StringRef AttrName = Attr.getName();
+ AttrName = NormalizeAttrName(AttrName);
OS << "PARSED_ATTR(" << AttrName << ")\n";
-
- if (!DistinctSpellings)
- break;
}
}
}
@@ -1127,46 +1130,31 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
bool Ignored = Attr.getValueAsBit("Ignored");
bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings");
if (SemaHandler || Ignored) {
- std::vector<StringRef> Spellings =
- getValueAsListOfStrings(Attr, "Spellings");
- std::vector<StringRef> Namespaces =
- getValueAsListOfStrings(Attr, "Namespaces");
+ std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings");
- for (std::vector<StringRef>::const_iterator I = Spellings.begin(),
+ for (std::vector<Record*>::const_iterator I = Spellings.begin(),
E = Spellings.end(); I != E; ++I) {
+ std::string RawSpelling = (*I)->getValueAsString("Name");
StringRef AttrName = NormalizeAttrName(DistinctSpellings
- ? *I
- : Spellings.front());
- StringRef Spelling = NormalizeAttrSpelling(*I);
-
- for (std::vector<StringRef>::const_iterator NI = Namespaces.begin(),
- NE = Namespaces.end(); NI != NE; ++NI) {
- SmallString<64> Buf;
- Buf += *NI;
- Buf += "::";
- Buf += Spelling;
-
- if (SemaHandler)
- Matches.push_back(
- StringMatcher::StringPair(
- Buf.str(),
- "return AttributeList::AT_" + AttrName.str() + ";"));
- else
- Matches.push_back(
- StringMatcher::StringPair(
- Buf.str(),
- "return AttributeList::IgnoredAttribute;"));
+ ? StringRef(RawSpelling)
+ : StringRef(Attr.getName()));
+
+ SmallString<64> Spelling;
+ if ((*I)->getValueAsString("Variety") == "CXX11") {
+ Spelling += (*I)->getValueAsString("Namespace");
+ Spelling += "::";
}
+ Spelling += NormalizeAttrSpelling(RawSpelling);
if (SemaHandler)
Matches.push_back(
StringMatcher::StringPair(
- Spelling,
+ StringRef(Spelling),
"return AttributeList::AT_" + AttrName.str() + ";"));
else
Matches.push_back(
StringMatcher::StringPair(
- Spelling,
+ StringRef(Spelling),
"return AttributeList::IgnoredAttribute;"));
}
}