mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
Add a way to emit StringSwitch of clang attribute spellings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116899 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b8e67fc92b
commit
238777eb58
@ -637,3 +637,21 @@ void ClangAttrPCHWriteEmitter::run(raw_ostream &OS) {
|
||||
}
|
||||
OS << " }\n";
|
||||
}
|
||||
|
||||
void ClangAttrSpellingListEmitter::run(raw_ostream &OS) {
|
||||
OS << "// This file is generated by TableGen. Do not edit.\n\n";
|
||||
|
||||
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
|
||||
|
||||
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end(); I != E; ++I) {
|
||||
Record &Attr = **I;
|
||||
|
||||
std::vector<StringRef> Spellings = getValueAsListOfStrings(Attr, "Spellings");
|
||||
|
||||
for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) {
|
||||
StringRef Spelling = *I;
|
||||
OS << ".Case(\"" << Spelling << "\", true)\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,19 @@ public:
|
||||
void run(raw_ostream &OS);
|
||||
};
|
||||
|
||||
/// ClangAttrSpellingListEmitter - class emits the list of spellings for attributes for
|
||||
/// clang.
|
||||
class ClangAttrSpellingListEmitter : public TableGenBackend {
|
||||
RecordKeeper &Records;
|
||||
|
||||
public:
|
||||
explicit ClangAttrSpellingListEmitter(RecordKeeper &R)
|
||||
: Records(R)
|
||||
{}
|
||||
|
||||
void run(raw_ostream &OS);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -59,6 +59,7 @@ enum ActionType {
|
||||
GenClangAttrList,
|
||||
GenClangAttrPCHRead,
|
||||
GenClangAttrPCHWrite,
|
||||
GenClangAttrSpellingList,
|
||||
GenClangDiagsDefs,
|
||||
GenClangDiagGroups,
|
||||
GenClangDeclNodes,
|
||||
@ -127,6 +128,8 @@ namespace {
|
||||
"Generate clang PCH attribute reader"),
|
||||
clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
|
||||
"Generate clang PCH attribute writer"),
|
||||
clEnumValN(GenClangAttrSpellingList, "gen-clang-attr-spelling-list",
|
||||
"Generate a clang attribute spelling list"),
|
||||
clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
|
||||
"Generate Clang diagnostics definitions"),
|
||||
clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
|
||||
@ -274,6 +277,9 @@ int main(int argc, char **argv) {
|
||||
case GenClangAttrPCHWrite:
|
||||
ClangAttrPCHWriteEmitter(Records).run(Out.os());
|
||||
break;
|
||||
case GenClangAttrSpellingList:
|
||||
ClangAttrSpellingListEmitter(Records).run(Out.os());
|
||||
break;
|
||||
case GenClangDiagsDefs:
|
||||
ClangDiagsDefsEmitter(Records, ClangComponent).run(Out.os());
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user