diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-06-19 21:48:43 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-06-19 21:48:43 +0000 |
commit | 3532936f4f50c15fcec4d00f4cbb81a7a9dd9b7e (patch) | |
tree | 27c76f46c02cf1a8e1d802eeb38a449ab3d2e1ef /utils | |
parent | 5d7700ed7645698f3e5bea8f983e61a1ec2f423b (diff) |
Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/ClangAttrEmitter.cpp | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 61fd86f170..7e1eaf8541 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<Record*> Spellings = R.getValueAsListOfDefs("Spellings"); + std::vector<StringRef> Spellings = getValueAsListOfStrings(R, "Spellings"); std::vector<Argument*> Args; for (ri = ArgRecords.begin(), re = ArgRecords.end(); ri != re; ++ri) Args.push_back(createArgument(**ri, R.getName())); @@ -789,10 +789,9 @@ 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()) { - StringRef Spelling = (*Spellings.begin())->getValueAsString("Name"); - OS << " OS << \" __attribute__((" << Spelling; + OS << " OS << \" __attribute__((" << *Spellings.begin(); if (Args.size()) OS << "("; - if (Spelling == "availability") { + if (*Spellings.begin()=="availability") { writeAvailabilityValue(OS); } else { for (ai = Args.begin(); ai != ae; ++ai) { @@ -963,10 +962,11 @@ 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<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings"); + std::vector<StringRef> Spellings = getValueAsListOfStrings(Attr, "Spellings"); - for (std::vector<Record*>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", true)\n"; + for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { + StringRef Spelling = *I; + OS << ".Case(\"" << Spelling << "\", true)\n"; } } @@ -985,16 +985,12 @@ void EmitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { bool LateParsed = Attr.getValueAsBit("LateParsed"); if (LateParsed) { - std::vector<Record*> Spellings = - Attr.getValueAsListOfDefs("Spellings"); + std::vector<StringRef> Spellings = + getValueAsListOfStrings(Attr, "Spellings"); - // FIXME: Handle non-GNU attributes - for (std::vector<Record*>::const_iterator I = Spellings.begin(), + for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - if ((*I)->getValueAsString("Variety") != "GNU") - continue; - OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", " - << LateParsed << ")\n"; + OS << ".Case(\"" << (*I) << "\", " << LateParsed << ")\n"; } } } @@ -1073,9 +1069,6 @@ 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"; @@ -1085,6 +1078,7 @@ 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) { @@ -1094,21 +1088,24 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler) { - 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"); - - StringRef Spelling = NormalizeAttrName(AttrName); + 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; - OS << "PARSED_ATTR(" << Spelling << ")\n"; - } - } else { - StringRef AttrName = Attr.getName(); AttrName = NormalizeAttrName(AttrName); + // skip if a normalized version has been processed. + if (ProcessedAttrs.find(AttrName) != ProcessedAttrs.end()) + continue; + else + ProcessedAttrs.insert(AttrName); + OS << "PARSED_ATTR(" << AttrName << ")\n"; + + if (!DistinctSpellings) + break; } } } @@ -1130,31 +1127,46 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { bool Ignored = Attr.getValueAsBit("Ignored"); bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler || Ignored) { - std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings"); + std::vector<StringRef> Spellings = + getValueAsListOfStrings(Attr, "Spellings"); + std::vector<StringRef> Namespaces = + getValueAsListOfStrings(Attr, "Namespaces"); - for (std::vector<Record*>::const_iterator I = Spellings.begin(), + for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - std::string RawSpelling = (*I)->getValueAsString("Name"); StringRef AttrName = NormalizeAttrName(DistinctSpellings - ? StringRef(RawSpelling) - : StringRef(Attr.getName())); - - SmallString<64> Spelling; - if ((*I)->getValueAsString("Variety") == "CXX11") { - Spelling += (*I)->getValueAsString("Namespace"); - Spelling += "::"; + ? *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;")); } - Spelling += NormalizeAttrSpelling(RawSpelling); if (SemaHandler) Matches.push_back( StringMatcher::StringPair( - StringRef(Spelling), + Spelling, "return AttributeList::AT_" + AttrName.str() + ";")); else Matches.push_back( StringMatcher::StringPair( - StringRef(Spelling), + Spelling, "return AttributeList::IgnoredAttribute;")); } } |