Index: include/clang/Sema/AttributeList.h =================================================================== --- include/clang/Sema/AttributeList.h +++ include/clang/Sema/AttributeList.h @@ -86,6 +86,8 @@ typedef llvm::SmallVector ArgsVector; struct ParsedAttrInfo { + /// Which spelling of the attribute this ParsedAttrInfo corresponds to + unsigned SpellingListIndex; /// Corresponds to the AttributeList::Kind enum unsigned AttrKind : 16; /// Corresponds to the AttributeList::Syntax enum @@ -115,10 +117,10 @@ unsigned IsLateParsed : 1; ParsedAttrInfo() - : AttrKind(0), Syntax(0), NumArgs(0), OptArgs(0), HasCustomParsing(0), - IsTargetSpecific(0), IsType(0), IsStmt(0), IsKnownToGCC(0), - IsUnevaluatedArgContext(0), IsIdentifierArg(0), IsTypeArg(0), - IsLateParsed(0) { } + : SpellingListIndex(0), AttrKind(0), Syntax(0), NumArgs(0), OptArgs(0), + HasCustomParsing(0), IsTargetSpecific(0), IsType(0), IsStmt(0), + IsKnownToGCC(0), IsUnevaluatedArgContext(0), IsIdentifierArg(0), + IsTypeArg(0), IsLateParsed(0) { } virtual ~ParsedAttrInfo() {} Index: include/clang/Sema/CMakeLists.txt =================================================================== --- include/clang/Sema/CMakeLists.txt +++ include/clang/Sema/CMakeLists.txt @@ -8,11 +8,6 @@ SOURCE ../Basic/Attr.td TARGET ClangAttrParsedAttrList) -clang_tablegen(AttrSpellingListIndex.inc -gen-clang-attr-spelling-index - -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ - SOURCE ../Basic/Attr.td - TARGET ClangAttrSpellingListIndex) - clang_tablegen(AttrParsedAttrImpl.inc -gen-clang-attr-parsed-attr-impl -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ SOURCE ../Basic/Attr.td Index: lib/Sema/AttributeList.cpp =================================================================== --- lib/Sema/AttributeList.cpp +++ lib/Sema/AttributeList.cpp @@ -163,15 +163,7 @@ } unsigned AttributeList::getAttributeSpellingListIndex() const { - // Both variables will be used in tablegen generated - // attribute spell list index matching code. - StringRef Scope = ScopeName ? ScopeName->getName() : ""; - StringRef Name = normalizeAttrName(AttrName->getName(), Scope, - (AttributeList::Syntax)SyntaxUsed); - Kind AttrKind = Kind(getInfo()->AttrKind); - -#include "clang/Sema/AttrSpellingListIndex.inc" - + return getInfo()->SpellingListIndex; } unsigned AttributeList::getMinArgs() const { Index: utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -2274,40 +2274,6 @@ OS << "}\n"; } -void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) { - emitSourceFileHeader("Code to translate different attribute spellings " - "into internal identifiers", OS); - - OS << " switch (AttrKind) {\n"; - - ParsedAttrMap Attrs = getParsedAttrList(Records); - for (const auto &I : Attrs) { - const Record &R = *I.second; - std::vector Spellings = GetFlattenedSpellings(R); - OS << " case AT_" << I.first << ": {\n"; - for (unsigned I = 0; I < Spellings.size(); ++ I) { - OS << " if (Name == \"" << Spellings[I].name() << "\" && " - << "SyntaxUsed == " - << StringSwitch(Spellings[I].variety()) - .Case("GNU", 0) - .Case("CXX11", 1) - .Case("Declspec", 2) - .Case("Microsoft", 3) - .Case("Keyword", 4) - .Case("Pragma", 5) - .Default(0) - << " && Scope == \"" << Spellings[I].nameSpace() << "\")\n" - << " return " << I << ";\n"; - } - - OS << " break;\n"; - OS << " }\n"; - } - - OS << " }\n"; - OS << " return 0;\n"; -} - // Emits code used by RecursiveASTVisitor to visit attributes void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) { emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS); @@ -2810,6 +2776,7 @@ std::string AttrInfoName = "AttrInfo" + std::to_string(SpellingIdx) + AttrName; OS << "struct " << AttrInfoName << " : public ParsedAttrInfo {\n"; OS << " " << AttrInfoName << "() {\n"; + OS << " SpellingListIndex = " << SpellingIdx << ";\n"; if (Attr.getValueAsBit("Ignored")) { OS << " AttrKind = AttributeList::IgnoredAttribute;\n"; } else { Index: utils/TableGen/TableGen.cpp =================================================================== --- utils/TableGen/TableGen.cpp +++ utils/TableGen/TableGen.cpp @@ -29,7 +29,6 @@ GenClangAttrPCHRead, GenClangAttrPCHWrite, GenClangAttrHasAttributeImpl, - GenClangAttrSpellingListIndex, GenClangAttrASTVisitor, GenClangAttrTemplateInstantiate, GenClangAttrParsedAttrList, @@ -72,9 +71,6 @@ clEnumValN(GenClangAttrHasAttributeImpl, "gen-clang-attr-has-attribute-impl", "Generate a clang attribute spelling list"), - clEnumValN(GenClangAttrSpellingListIndex, - "gen-clang-attr-spelling-index", - "Generate a clang attribute spelling index"), clEnumValN(GenClangAttrASTVisitor, "gen-clang-attr-ast-visitor", "Generate a recursive AST visitor for clang attributes"), @@ -157,9 +153,6 @@ case GenClangAttrHasAttributeImpl: EmitClangAttrHasAttrImpl(Records, OS); break; - case GenClangAttrSpellingListIndex: - EmitClangAttrSpellingListIndex(Records, OS); - break; case GenClangAttrASTVisitor: EmitClangAttrASTVisitor(Records, OS); break; Index: utils/TableGen/TableGenBackends.h =================================================================== --- utils/TableGen/TableGenBackends.h +++ utils/TableGen/TableGenBackends.h @@ -38,7 +38,6 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS); void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS); void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS); void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS); void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS); void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS);