return create(Name, TokLoc, 0, TokLoc, 0, TokLoc, &IArg, 1, 0);
}
+#include "clang/Sema/AttrParsedAttrKinds.inc"
+
AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
StringRef AttrName = Name->getName();
AttrName.size() >= 4)
AttrName = AttrName.substr(2, AttrName.size() - 4);
- return llvm::StringSwitch<AttributeList::Kind>(AttrName)
- #include "clang/Sema/AttrParsedAttrKinds.inc"
- .Default(UnknownAttribute);
+ return ::getAttrKind(AttrName);
}
#include "ClangAttrEmitter.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
#include <algorithm>
#include <cctype>
#include <set>
void ClangAttrParsedAttrKindsEmitter::run(raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
-
+ OS << "\n";
+
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
+ std::vector<StringMatcher::StringPair> Matches;
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
I != E; ++I) {
Record &Attr = **I;
Spelling = NormalizeAttrSpelling(Spelling);
if (SemaHandler)
- OS << ".Case(\"" << Spelling << "\", " << "AT_" << AttrName << ")\n";
+ Matches.push_back(
+ StringMatcher::StringPair(Spelling,
+ std::string("return AttributeList::AT_") +
+ AttrName.str() + ";"));
else
- OS << ".Case(\"" << Spelling << "\", IgnoredAttribute)\n";
+ Matches.push_back(
+ StringMatcher::StringPair(
+ Spelling,
+ std::string("return AttributeList::IgnoredAttribute;")));
}
}
}
+
+ OS << "static AttributeList::Kind getAttrKind(StringRef Name) {\n";
+ StringMatcher("Name", Matches, OS).Emit();
+ OS << "return AttributeList::UnknownAttribute;\n"
+ << "}\n";
}