#include "TableGenBackends.h"
#include "ASTTableGen.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/StringMatcher.h"
#include "llvm/TableGen/TableGenBackend.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
usingnamespacellvm;
namespace {
class FlattenedSpelling { … };
struct FlattenedSpellingInfo { … };
FSIVecTy;
}
static bool GenerateTargetSpecificAttrChecks(const Record *R,
std::vector<StringRef> &Arches,
std::string &Test,
std::string *FnName);
static bool isStringLiteralArgument(const Record *Arg);
static bool isVariadicStringLiteralArgument(const Record *Arg);
static std::vector<FlattenedSpelling>
GetFlattenedSpellings(const Record &Attr) { … }
static std::string ReadPCHRecord(StringRef type) { … }
static StringRef getStorageType(StringRef type) { … }
static std::string WritePCHRecord(StringRef type, StringRef name) { … }
static StringRef NormalizeAttrName(StringRef AttrName) { … }
static StringRef NormalizeNameForSpellingComparison(StringRef Name) { … }
static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) { … }
ParsedAttrMap;
static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
ParsedAttrMap *Dupes = nullptr,
bool SemaOnly = true) { … }
namespace {
class Argument { … };
class SimpleArgument : public Argument { … };
class DefaultSimpleArgument : public SimpleArgument { … };
class StringArgument : public Argument { … };
class AlignedArgument : public Argument { … };
class VariadicArgument : public Argument { … };
class VariadicOMPInteropInfoArgument : public VariadicArgument { … };
class VariadicParamIdxArgument : public VariadicArgument { … };
struct VariadicParamOrParamIdxArgument : public VariadicArgument { … };
std::vector<StringRef>
uniqueEnumsInOrder(const std::vector<StringRef> &enums) { … }
class EnumArgument : public Argument { … };
class VariadicEnumArgument: public VariadicArgument { … };
class VersionArgument : public Argument { … };
class ExprArgument : public SimpleArgument { … };
class VariadicExprArgument : public VariadicArgument { … };
class VariadicIdentifierArgument : public VariadicArgument { … };
class VariadicStringArgument : public VariadicArgument { … };
class TypeArgument : public SimpleArgument { … };
class WrappedAttr : public SimpleArgument { … };
}
static std::unique_ptr<Argument>
createArgument(const Record &Arg, StringRef Attr,
const Record *Search = nullptr) { … }
static void writeAvailabilityValue(raw_ostream &OS) { … }
static void writeDeprecatedAttrValue(raw_ostream &OS, std::string &Variety) { … }
static void writeGetSpellingFunction(const Record &R, raw_ostream &OS) { … }
static void
writePrettyPrintFunction(const Record &R,
const std::vector<std::unique_ptr<Argument>> &Args,
raw_ostream &OS) { … }
static unsigned
getSpellingListIndex(const std::vector<FlattenedSpelling> &SpellingList,
const FlattenedSpelling &Spelling) { … }
static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) { … }
static bool
SpellingNamesAreCommon(const std::vector<FlattenedSpelling>& Spellings) { … }
SemanticSpellingMap;
static std::string
CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
SemanticSpellingMap &Map) { … }
void WriteSemanticSpellingSwitch(const std::string &VarName,
const SemanticSpellingMap &Map,
raw_ostream &OS) { … }
enum class LateAttrParseKind { … };
static LateAttrParseKind getLateAttrParseKind(const Record *Attr) { … }
static void emitClangAttrLateParsedListImpl(const RecordKeeper &Records,
raw_ostream &OS,
LateAttrParseKind LateParseMode) { … }
static void emitClangAttrLateParsedList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void emitClangAttrLateParsedExperimentalList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static bool hasGNUorCXX11Spelling(const Record &Attribute) { … }
namespace {
struct AttributeSubjectMatchRule { … };
const char *AttributeSubjectMatchRule::EnumName = …;
struct PragmaClangAttributeSupport { … };
}
static bool isSupportedPragmaClangAttributeSubject(const Record &Subject) { … }
static bool doesDeclDeriveFrom(const Record *D, const Record *Base) { … }
PragmaClangAttributeSupport::PragmaClangAttributeSupport(
const RecordKeeper &Records) { … }
static PragmaClangAttributeSupport &
getPragmaAttributeSupport(const RecordKeeper &Records) { … }
void PragmaClangAttributeSupport::emitMatchRuleList(raw_ostream &OS) { … }
bool PragmaClangAttributeSupport::isAttributedSupported(
const Record &Attribute) { … }
static std::string GenerateTestExpression(ArrayRef<Record *> LangOpts) { … }
void
PragmaClangAttributeSupport::generateStrictConformsTo(const Record &Attr,
raw_ostream &OS) { … }
void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) { … }
template <typename Fn> static void forEachSpelling(const Record &Attr, Fn &&F) { … }
std::map<std::string, std::vector<const Record *>> NameToAttrsMap;
void generateNameToAttrsMap(const RecordKeeper &Records) { … }
static void generateFlattenedSpellingInfo(const Record &Attr,
std::map<std::string, FSIVecTy> &Map,
uint32_t ArgMask = 0) { … }
static bool nameAppliesToOneAttribute(std::string Name) { … }
static bool emitIfSimpleValue(std::string Name, uint32_t ArgMask,
raw_ostream &OS) { … }
static void emitSingleCondition(const FlattenedSpellingInfo &FSI,
raw_ostream &OS) { … }
static void emitStringSwitchCases(std::map<std::string, FSIVecTy> &Map,
raw_ostream &OS) { … }
static bool isTypeArgument(const Record *Arg) { … }
static void emitClangAttrTypeArgList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void emitClangAttrArgContextList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static bool isIdentifierArgument(const Record *Arg) { … }
static bool isVariadicIdentifierArgument(const Record *Arg) { … }
static bool isVariadicExprArgument(const Record *Arg) { … }
static bool isStringLiteralArgument(const Record *Arg) { … }
static bool isVariadicStringLiteralArgument(const Record *Arg) { … }
static void emitClangAttrVariadicIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void
emitClangAttrUnevaluatedStringLiteralList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void emitClangAttrIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static bool keywordThisIsaIdentifierInArgument(const Record *Arg) { … }
static void emitClangAttrThisIsaIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) { … }
static void emitClangAttrAcceptsExprPack(const RecordKeeper &Records,
raw_ostream &OS) { … }
static bool isRegularKeywordAttribute(const FlattenedSpelling &S) { … }
static void emitFormInitializer(raw_ostream &OS,
const FlattenedSpelling &Spelling,
StringRef SpellingIndex) { … }
static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
bool Header) { … }
void clang::EmitClangAttrClass(const RecordKeeper &Records, raw_ostream &OS) { … }
void clang::EmitClangAttrImpl(const RecordKeeper &Records, raw_ostream &OS) { … }
static void emitAttrList(raw_ostream &OS, StringRef Class,
ArrayRef<const Record *> AttrList) { … }
static bool AttrHasPragmaSpelling(const Record *R) { … }
namespace {
struct AttrClassDescriptor { … };
}
static const AttrClassDescriptor AttrClassDescriptors[] = …;
static void emitDefaultDefine(raw_ostream &OS, StringRef name,
const char *superName) { … }
namespace {
struct AttrClass { … };
class AttrClassHierarchy { … };
}
namespace clang {
void EmitClangAttrList(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrSubjectMatchRuleList(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrPCHRead(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrPCHWrite(const RecordKeeper &Records, raw_ostream &OS) { … }
}
static bool GenerateTargetSpecificAttrCheck(const Record *R, std::string &Test,
std::string *FnName,
StringRef ListName,
StringRef CheckAgainst,
StringRef Scope) { … }
static bool GenerateTargetSpecificAttrChecks(const Record *R,
std::vector<StringRef> &Arches,
std::string &Test,
std::string *FnName) { … }
static void GenerateHasAttrSpellingStringSwitch(
const std::vector<std::pair<const Record *, FlattenedSpelling>> &Attrs,
raw_ostream &OS, const std::string &Variety,
const std::string &Scope = "") { … }
namespace clang {
void EmitClangRegularKeywordAttributeInfo(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrHasAttrImpl(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrSpellingListIndex(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrASTVisitor(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrTemplateInstantiateHelper(ArrayRef<const Record *> Attrs,
raw_ostream &OS,
bool AppliesToDecl) { … }
void EmitClangAttrTemplateInstantiate(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrParsedAttrList(const RecordKeeper &Records, raw_ostream &OS) { … }
static bool isArgVariadic(const Record &R, StringRef AttrName) { … }
static void emitArgInfo(const Record &R, raw_ostream &OS) { … }
static std::string GetDiagnosticSpelling(const Record &R) { … }
static std::string CalculateDiagnostic(const Record &S) { … }
static std::string GetSubjectWithSuffix(const Record *R) { … }
static std::string functionNameForCustomAppertainsTo(const Record &Subject) { … }
static void GenerateCustomAppertainsTo(const Record &Subject, raw_ostream &OS) { … }
static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { … }
static void GenerateMutualExclusionsChecks(const Record &Attr,
const RecordKeeper &Records,
raw_ostream &OS,
raw_ostream &MergeDeclOS,
raw_ostream &MergeStmtOS) { … }
static void
emitAttributeMatchRules(PragmaClangAttributeSupport &PragmaAttributeSupport,
raw_ostream &OS) { … }
static void GenerateLangOptRequirements(const Record &R,
raw_ostream &OS) { … }
static void GenerateTargetRequirements(const Record &Attr,
const ParsedAttrMap &Dupes,
raw_ostream &OS) { … }
static void
GenerateSpellingTargetRequirements(const Record &Attr,
const std::vector<Record *> &TargetSpellings,
raw_ostream &OS) { … }
static void GenerateSpellingIndexToSemanticSpelling(const Record &Attr,
raw_ostream &OS) { … }
static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) { … }
static bool isParamExpr(const Record *Arg) { … }
void GenerateIsParamExpr(const Record &Attr, raw_ostream &OS) { … }
void GenerateHandleAttrWithDelayedArgs(const RecordKeeper &Records,
raw_ostream &OS) { … }
static bool IsKnownToGCC(const Record &Attr) { … }
void EmitClangAttrParsedAttrImpl(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrParsedAttrKinds(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrTextNodeDump(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrNodeTraverse(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrParserStringSwitches(const RecordKeeper &Records,
raw_ostream &OS) { … }
void EmitClangAttrSubjectMatchRulesParserStringSwitches(
const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitClangAttrDocTable(const RecordKeeper &Records, raw_ostream &OS) { … }
enum class SpellingKind : size_t { … };
static const size_t NumSpellingKinds = …;
class SpellingList { … };
class DocumentationData { … };
static void WriteCategoryHeader(const Record *DocCategory,
raw_ostream &OS) { … }
static std::pair<std::string, SpellingList>
GetAttributeHeadingAndSpellings(const Record &Documentation,
const Record &Attribute,
StringRef Cat) { … }
static void WriteDocumentation(const RecordKeeper &Records,
const DocumentationData &Doc, raw_ostream &OS) { … }
void EmitClangAttrDocs(const RecordKeeper &Records, raw_ostream &OS) { … }
void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
raw_ostream &OS) { … }
}