[clang] [clang][TableGen] Migrate clang-tblgen to use const RecordKeeper (PR #107533)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 6 07:18:31 PDT 2024
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/107533
>From e208abfde2e14e8ce743ca56a62d0b3d667edc89 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Thu, 29 Aug 2024 20:36:05 -0700
Subject: [PATCH] [clang][TableGen] Migrate clang-tblgen to use const
RecordKeeper
Migrate clang tablegen backends to use const RecordKeeper.
---
clang/utils/TableGen/ASTTableGen.cpp | 12 +-
clang/utils/TableGen/ASTTableGen.h | 37 +--
clang/utils/TableGen/ClangASTNodesEmitter.cpp | 35 +--
.../TableGen/ClangASTPropertiesEmitter.cpp | 193 +++++++--------
clang/utils/TableGen/ClangAttrEmitter.cpp | 228 ++++++++----------
clang/utils/TableGen/ClangBuiltinsEmitter.cpp | 9 +-
.../ClangCommentCommandInfoEmitter.cpp | 21 +-
...mentHTMLNamedCharacterReferenceEmitter.cpp | 16 +-
.../TableGen/ClangCommentHTMLTagsEmitter.cpp | 11 +-
.../TableGen/ClangDataCollectorsEmitter.cpp | 2 +-
.../TableGen/ClangDiagnosticsEmitter.cpp | 133 +++++-----
clang/utils/TableGen/ClangOpcodesEmitter.cpp | 8 +-
.../TableGen/ClangOpenCLBuiltinEmitter.cpp | 65 +++--
.../utils/TableGen/ClangOptionDocEmitter.cpp | 46 ++--
.../utils/TableGen/ClangSACheckersEmitter.cpp | 9 +-
clang/utils/TableGen/ClangSyntaxEmitter.cpp | 11 +-
.../utils/TableGen/ClangTypeNodesEmitter.cpp | 13 +-
clang/utils/TableGen/MveEmitter.cpp | 41 ++--
clang/utils/TableGen/NeonEmitter.cpp | 41 ++--
clang/utils/TableGen/RISCVVEmitter.cpp | 23 +-
clang/utils/TableGen/SveEmitter.cpp | 71 +++---
clang/utils/TableGen/TableGenBackends.h | 209 +++++++++-------
22 files changed, 607 insertions(+), 627 deletions(-)
diff --git a/clang/utils/TableGen/ASTTableGen.cpp b/clang/utils/TableGen/ASTTableGen.cpp
index 54288ff6a03be3..482c9e318a12f3 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -31,7 +31,8 @@ llvm::StringRef clang::tblgen::HasProperties::getName() const {
}
}
-static StringRef removeExpectedNodeNameSuffix(Record *node, StringRef suffix) {
+static StringRef removeExpectedNodeNameSuffix(const Record *node,
+ StringRef suffix) {
StringRef nodeName = node->getName();
if (!nodeName.ends_with(suffix)) {
PrintFatalError(node->getLoc(),
@@ -105,8 +106,7 @@ static void visitASTNodeRecursive(ASTNode node, ASTNode base,
}
}
-static void visitHierarchy(RecordKeeper &records,
- StringRef nodeClassName,
+static void visitHierarchy(const RecordKeeper &records, StringRef nodeClassName,
ASTNodeHierarchyVisitor<ASTNode> visit) {
// Check for the node class, just as a basic correctness check.
if (!records.getClass(nodeClassName)) {
@@ -136,8 +136,8 @@ static void visitHierarchy(RecordKeeper &records,
visitASTNodeRecursive(root, ASTNode(), hierarchy, visit);
}
-void clang::tblgen::visitASTNodeHierarchyImpl(RecordKeeper &records,
- StringRef nodeClassName,
- ASTNodeHierarchyVisitor<ASTNode> visit) {
+void clang::tblgen::visitASTNodeHierarchyImpl(
+ const RecordKeeper &records, StringRef nodeClassName,
+ ASTNodeHierarchyVisitor<ASTNode> visit) {
visitHierarchy(records, nodeClassName, visit);
}
diff --git a/clang/utils/TableGen/ASTTableGen.h b/clang/utils/TableGen/ASTTableGen.h
index 41f78a6a3bbcdd..143d779a8a64f8 100644
--- a/clang/utils/TableGen/ASTTableGen.h
+++ b/clang/utils/TableGen/ASTTableGen.h
@@ -87,18 +87,18 @@ namespace clang {
namespace tblgen {
class WrappedRecord {
- llvm::Record *Record;
+ const llvm::Record *Record;
protected:
- WrappedRecord(llvm::Record *record = nullptr) : Record(record) {}
+ WrappedRecord(const llvm::Record *record = nullptr) : Record(record) {}
- llvm::Record *get() const {
+ const llvm::Record *get() const {
assert(Record && "accessing null record");
return Record;
}
public:
- llvm::Record *getRecord() const { return Record; }
+ const llvm::Record *getRecord() const { return Record; }
explicit operator bool() const { return Record != nullptr; }
@@ -144,7 +144,7 @@ class HasProperties : public WrappedRecord {
public:
static constexpr llvm::StringRef ClassName = HasPropertiesClassName;
- HasProperties(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ HasProperties(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
llvm::StringRef getName() const;
@@ -157,7 +157,7 @@ class HasProperties : public WrappedRecord {
/// in one of Clang's AST hierarchies.
class ASTNode : public HasProperties {
public:
- ASTNode(llvm::Record *record = nullptr) : HasProperties(record) {}
+ ASTNode(const llvm::Record *record = nullptr) : HasProperties(record) {}
llvm::StringRef getName() const {
return get()->getName();
@@ -180,7 +180,7 @@ class ASTNode : public HasProperties {
class DeclNode : public ASTNode {
public:
- DeclNode(llvm::Record *record = nullptr) : ASTNode(record) {}
+ DeclNode(const llvm::Record *record = nullptr) : ASTNode(record) {}
llvm::StringRef getId() const;
std::string getClassName() const;
@@ -202,7 +202,7 @@ class DeclNode : public ASTNode {
class TypeNode : public ASTNode {
public:
- TypeNode(llvm::Record *record = nullptr) : ASTNode(record) {}
+ TypeNode(const llvm::Record *record = nullptr) : ASTNode(record) {}
llvm::StringRef getId() const;
llvm::StringRef getClassName() const;
@@ -224,7 +224,7 @@ class TypeNode : public ASTNode {
class StmtNode : public ASTNode {
public:
- StmtNode(llvm::Record *record = nullptr) : ASTNode(record) {}
+ StmtNode(const llvm::Record *record = nullptr) : ASTNode(record) {}
std::string getId() const;
llvm::StringRef getClassName() const;
@@ -247,7 +247,7 @@ class StmtNode : public ASTNode {
/// The type of a property.
class PropertyType : public WrappedRecord {
public:
- PropertyType(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ PropertyType(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
/// Is this a generic specialization (i.e. `Array<T>` or `Optional<T>`)?
bool isGenericSpecialization() const {
@@ -331,7 +331,7 @@ class PropertyType : public WrappedRecord {
/// A rule for returning the kind of a type.
class TypeKindRule : public WrappedRecord {
public:
- TypeKindRule(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ TypeKindRule(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
/// Return the type to which this applies.
PropertyType getParentType() const {
@@ -361,7 +361,7 @@ class TypeKindRule : public WrappedRecord {
/// An implementation case of a property type.
class TypeCase : public HasProperties {
public:
- TypeCase(llvm::Record *record = nullptr) : HasProperties(record) {}
+ TypeCase(const llvm::Record *record = nullptr) : HasProperties(record) {}
/// Return the name of this case.
llvm::StringRef getCaseName() const {
@@ -381,7 +381,7 @@ class TypeCase : public HasProperties {
/// A property of an AST node.
class Property : public WrappedRecord {
public:
- Property(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ Property(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
/// Return the name of this property.
llvm::StringRef getName() const {
@@ -417,7 +417,8 @@ class Property : public WrappedRecord {
/// a value (which is actually done when writing the value out).
class ReadHelperRule : public WrappedRecord {
public:
- ReadHelperRule(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ ReadHelperRule(const llvm::Record *record = nullptr)
+ : WrappedRecord(record) {}
/// Return the class for which this is a creation rule.
/// Should never be abstract.
@@ -437,7 +438,7 @@ class ReadHelperRule : public WrappedRecord {
/// A rule for how to create an AST node from its properties.
class CreationRule : public WrappedRecord {
public:
- CreationRule(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ CreationRule(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
/// Return the class for which this is a creation rule.
/// Should never be abstract.
@@ -457,7 +458,7 @@ class CreationRule : public WrappedRecord {
/// A rule which overrides the standard rules for serializing an AST node.
class OverrideRule : public WrappedRecord {
public:
- OverrideRule(llvm::Record *record = nullptr) : WrappedRecord(record) {}
+ OverrideRule(const llvm::Record *record = nullptr) : WrappedRecord(record) {}
/// Return the class for which this is an override rule.
/// Should never be abstract.
@@ -483,12 +484,12 @@ template <class NodeClass>
using ASTNodeHierarchyVisitor =
llvm::function_ref<void(NodeClass node, NodeClass base)>;
-void visitASTNodeHierarchyImpl(llvm::RecordKeeper &records,
+void visitASTNodeHierarchyImpl(const llvm::RecordKeeper &records,
llvm::StringRef nodeClassName,
ASTNodeHierarchyVisitor<ASTNode> visit);
template <class NodeClass>
-void visitASTNodeHierarchy(llvm::RecordKeeper &records,
+void visitASTNodeHierarchy(const llvm::RecordKeeper &records,
ASTNodeHierarchyVisitor<NodeClass> visit) {
visitASTNodeHierarchyImpl(records, NodeClass::getTableGenNodeClassName(),
[visit](ASTNode node, ASTNode base) {
diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 07ddafce329163..39cc8b87e6301f 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -34,7 +34,7 @@ class ClangASTNodesEmitter {
typedef ChildMap::const_iterator ChildIterator;
std::set<ASTNode> PrioritizedClasses;
- RecordKeeper &Records;
+ const RecordKeeper &Records;
ASTNode Root;
const std::string &NodeClassName;
const std::string &BaseSuffix;
@@ -70,14 +70,12 @@ class ClangASTNodesEmitter {
std::pair<ASTNode, ASTNode> EmitNode(raw_ostream& OS, ASTNode Base);
public:
- explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N,
+ explicit ClangASTNodesEmitter(const RecordKeeper &R, const std::string &N,
const std::string &S,
std::string_view PriorizeIfSubclassOf)
: Records(R), NodeClassName(N), BaseSuffix(S) {
auto vecPrioritized =
- PriorizeIfSubclassOf.empty()
- ? std::vector<Record *>{}
- : R.getAllDerivedDefinitions(PriorizeIfSubclassOf);
+ R.getAllDerivedDefinitionsIfDefined(PriorizeIfSubclassOf);
PrioritizedClasses =
std::set<ASTNode>(vecPrioritized.begin(), vecPrioritized.end());
}
@@ -169,8 +167,8 @@ void ClangASTNodesEmitter::deriveChildTree() {
assert(!Root && "already computed tree");
// Emit statements
- const std::vector<Record*> Stmts
- = Records.getAllDerivedDefinitions(NodeClassName);
+ const std::vector<const Record *> &Stmts =
+ Records.getAllDerivedDefinitions(NodeClassName);
for (auto *R : Stmts) {
if (auto B = R->getValueAsOptionalDef(BaseFieldName))
@@ -217,14 +215,14 @@ void ClangASTNodesEmitter::run(raw_ostream &OS) {
OS << "#undef ABSTRACT_" << macroHierarchyName() << "\n";
}
-void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS,
+void clang::EmitClangASTNodes(const RecordKeeper &RK, raw_ostream &OS,
const std::string &N, const std::string &S,
std::string_view PriorizeIfSubclassOf) {
ClangASTNodesEmitter(RK, N, S, PriorizeIfSubclassOf).run(OS);
}
-void printDeclContext(const std::multimap<Record *, Record *> &Tree,
- Record *DeclContext, raw_ostream &OS) {
+void printDeclContext(const std::multimap<const Record *, const Record *> &Tree,
+ const Record *DeclContext, raw_ostream &OS) {
if (!DeclContext->getValueAsBit(AbstractFieldName))
OS << "DECL_CONTEXT(" << DeclContext->getName() << ")\n";
auto i = Tree.lower_bound(DeclContext);
@@ -236,7 +234,7 @@ void printDeclContext(const std::multimap<Record *, Record *> &Tree,
// Emits and addendum to a .inc file to enumerate the clang declaration
// contexts.
-void clang::EmitClangDeclContext(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangDeclContext(const RecordKeeper &Records, raw_ostream &OS) {
// FIXME: Find a .td file format to allow for this to be represented better.
emitSourceFileHeader("List of AST Decl nodes", OS, Records);
@@ -245,22 +243,15 @@ void clang::EmitClangDeclContext(RecordKeeper &Records, raw_ostream &OS) {
OS << "# define DECL_CONTEXT(DECL)\n";
OS << "#endif\n";
- std::vector<Record *> DeclContextsVector =
- Records.getAllDerivedDefinitions(DeclContextNodeClassName);
- std::vector<Record *> Decls =
- Records.getAllDerivedDefinitions(DeclNodeClassName);
+ std::multimap<const Record *, const Record *> Tree;
- std::multimap<Record *, Record *> Tree;
-
- const std::vector<Record *> Stmts =
- Records.getAllDerivedDefinitions(DeclNodeClassName);
-
- for (auto *R : Stmts) {
+ for (auto *R : Records.getAllDerivedDefinitions(DeclNodeClassName)) {
if (auto *B = R->getValueAsOptionalDef(BaseFieldName))
Tree.insert(std::make_pair(B, R));
}
- for (auto *DeclContext : DeclContextsVector) {
+ for (const Record *DeclContext :
+ Records.getAllDerivedDefinitions(DeclContextNodeClassName)) {
printDeclContext(Tree, DeclContext, OS);
}
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index de8dda60681ff8..a967ecb6523252 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -89,95 +89,96 @@ struct CasedTypeInfo {
class ASTPropsEmitter {
raw_ostream &Out;
- RecordKeeper &Records;
- std::map<HasProperties, NodeInfo> NodeInfos;
- std::vector<PropertyType> AllPropertyTypes;
- std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
-
-public:
- ASTPropsEmitter(RecordKeeper &records, raw_ostream &out)
- : Out(out), Records(records) {
-
- // Find all the properties.
- for (Property property :
- records.getAllDerivedDefinitions(PropertyClassName)) {
- HasProperties node = property.getClass();
- NodeInfos[node].Properties.push_back(property);
- }
-
- // Find all the creation rules.
- for (CreationRule creationRule :
- records.getAllDerivedDefinitions(CreationRuleClassName)) {
- HasProperties node = creationRule.getClass();
-
- auto &info = NodeInfos[node];
- if (info.Creator) {
- PrintFatalError(creationRule.getLoc(),
- "multiple creator rules for \"" + node.getName()
- + "\"");
- }
- info.Creator = creationRule;
- }
-
- // Find all the override rules.
- for (OverrideRule overrideRule :
- records.getAllDerivedDefinitions(OverrideRuleClassName)) {
- HasProperties node = overrideRule.getClass();
-
- auto &info = NodeInfos[node];
- if (info.Override) {
- PrintFatalError(overrideRule.getLoc(),
- "multiple override rules for \"" + node.getName()
- + "\"");
- }
- info.Override = overrideRule;
- }
-
- // Find all the write helper rules.
- for (ReadHelperRule helperRule :
- records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
- HasProperties node = helperRule.getClass();
-
- auto &info = NodeInfos[node];
- if (info.ReadHelper) {
- PrintFatalError(helperRule.getLoc(),
- "multiple write helper rules for \"" + node.getName()
- + "\"");
- }
- info.ReadHelper = helperRule;
- }
-
- // Find all the concrete property types.
- for (PropertyType type :
- records.getAllDerivedDefinitions(PropertyTypeClassName)) {
- // Ignore generic specializations; they're generally not useful when
- // emitting basic emitters etc.
- if (type.isGenericSpecialization()) continue;
-
- AllPropertyTypes.push_back(type);
- }
-
- // Find all the type kind rules.
- for (TypeKindRule kindRule :
- records.getAllDerivedDefinitions(TypeKindClassName)) {
- PropertyType type = kindRule.getParentType();
- auto &info = CasedTypeInfos[type];
- if (info.KindRule) {
- PrintFatalError(kindRule.getLoc(),
- "multiple kind rules for \""
- + type.getCXXTypeName() + "\"");
- }
- info.KindRule = kindRule;
- }
-
- // Find all the type cases.
- for (TypeCase typeCase :
- records.getAllDerivedDefinitions(TypeCaseClassName)) {
- CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
- }
-
- Validator(*this).validate();
- }
+ const RecordKeeper &Records;
+ std::map<HasProperties, NodeInfo> NodeInfos;
+ std::vector<PropertyType> AllPropertyTypes;
+ std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
+
+ public:
+ ASTPropsEmitter(const RecordKeeper &records, raw_ostream &out)
+ : Out(out), Records(records) {
+
+ // Find all the properties.
+ for (Property property :
+ records.getAllDerivedDefinitions(PropertyClassName)) {
+ HasProperties node = property.getClass();
+ NodeInfos[node].Properties.push_back(property);
+ }
+
+ // Find all the creation rules.
+ for (CreationRule creationRule :
+ records.getAllDerivedDefinitions(CreationRuleClassName)) {
+ HasProperties node = creationRule.getClass();
+
+ auto &info = NodeInfos[node];
+ if (info.Creator) {
+ PrintFatalError(creationRule.getLoc(),
+ "multiple creator rules for \"" + node.getName() +
+ "\"");
+ }
+ info.Creator = creationRule;
+ }
+
+ // Find all the override rules.
+ for (OverrideRule overrideRule :
+ records.getAllDerivedDefinitions(OverrideRuleClassName)) {
+ HasProperties node = overrideRule.getClass();
+
+ auto &info = NodeInfos[node];
+ if (info.Override) {
+ PrintFatalError(overrideRule.getLoc(),
+ "multiple override rules for \"" +
+ node.getName() + "\"");
+ }
+ info.Override = overrideRule;
+ }
+
+ // Find all the write helper rules.
+ for (ReadHelperRule helperRule :
+ records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
+ HasProperties node = helperRule.getClass();
+
+ auto &info = NodeInfos[node];
+ if (info.ReadHelper) {
+ PrintFatalError(helperRule.getLoc(),
+ "multiple write helper rules for \"" +
+ node.getName() + "\"");
+ }
+ info.ReadHelper = helperRule;
+ }
+
+ // Find all the concrete property types.
+ for (PropertyType type :
+ records.getAllDerivedDefinitions(PropertyTypeClassName)) {
+ // Ignore generic specializations; they're generally not useful when
+ // emitting basic emitters etc.
+ if (type.isGenericSpecialization())
+ continue;
+
+ AllPropertyTypes.push_back(type);
+ }
+
+ // Find all the type kind rules.
+ for (TypeKindRule kindRule :
+ records.getAllDerivedDefinitions(TypeKindClassName)) {
+ PropertyType type = kindRule.getParentType();
+ auto &info = CasedTypeInfos[type];
+ if (info.KindRule) {
+ PrintFatalError(kindRule.getLoc(), "multiple kind rules for \"" +
+ type.getCXXTypeName() +
+ "\"");
+ }
+ info.KindRule = kindRule;
+ }
+
+ // Find all the type cases.
+ for (TypeCase typeCase :
+ records.getAllDerivedDefinitions(TypeCaseClassName)) {
+ CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
+ }
+
+ Validator(*this).validate();
+ }
void visitAllProperties(HasProperties derived, const NodeInfo &derivedInfo,
function_ref<void (Property)> visit) {
@@ -591,28 +592,28 @@ void ASTPropsEmitter::emitWriteOfProperty(StringRef writerName,
/// Emit an .inc file that defines the AbstractFooReader class
/// for the given AST class hierarchy.
template <class NodeClass>
-static void emitASTReader(RecordKeeper &records, raw_ostream &out,
+static void emitASTReader(const RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out, records);
ASTPropsEmitter(records, out).emitNodeReaderClass<NodeClass>();
}
-void clang::EmitClangTypeReader(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangTypeReader(const RecordKeeper &records, raw_ostream &out) {
emitASTReader<TypeNode>(records, out, "A CRTP reader for Clang Type nodes");
}
/// Emit an .inc file that defines the AbstractFooWriter class
/// for the given AST class hierarchy.
template <class NodeClass>
-static void emitASTWriter(RecordKeeper &records, raw_ostream &out,
+static void emitASTWriter(const RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out, records);
ASTPropsEmitter(records, out).emitNodeWriterClass<NodeClass>();
}
-void clang::EmitClangTypeWriter(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangTypeWriter(const RecordKeeper &records, raw_ostream &out) {
emitASTWriter<TypeNode>(records, out, "A CRTP writer for Clang Type nodes");
}
@@ -851,7 +852,8 @@ void ASTPropsEmitter::emitBasicReaderWriterFile(const ReaderWriterInfo &info) {
/// Emit an .inc file that defines some helper classes for reading
/// basic values.
-void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangBasicReader(const RecordKeeper &records,
+ raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicReaders", out, records);
// Use any property, we won't be using those properties.
@@ -861,7 +863,8 @@ void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
/// Emit an .inc file that defines some helper classes for writing
/// basic values.
-void clang::EmitClangBasicWriter(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangBasicWriter(const RecordKeeper &records,
+ raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicWriters", out, records);
// Use any property, we won't be using those properties.
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index d24215d10f17c7..fa231f8cea8dbb 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -189,13 +189,12 @@ static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
typedef std::vector<std::pair<std::string, const Record *>> ParsedAttrMap;
-static ParsedAttrMap getParsedAttrList(RecordKeeper &Records,
+static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
ParsedAttrMap *Dupes = nullptr,
bool SemaOnly = true) {
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::set<std::string> Seen;
ParsedAttrMap R;
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
if (!SemaOnly || Attr->getValueAsBit("SemaHandler")) {
std::string AN;
if (Attr->isSubClassOf("TargetSpecificAttr") &&
@@ -1911,12 +1910,10 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
}
// Emits the LateParsed property for attributes.
-static void emitClangAttrLateParsedListImpl(RecordKeeper &Records,
+static void emitClangAttrLateParsedListImpl(const RecordKeeper &Records,
raw_ostream &OS,
LateAttrParseKind LateParseMode) {
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
-
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
if (LateAttrParseKind LateParsed = getLateAttrParseKind(Attr);
LateParsed != LateParseMode)
continue;
@@ -1932,14 +1929,14 @@ static void emitClangAttrLateParsedListImpl(RecordKeeper &Records,
}
}
-static void emitClangAttrLateParsedList(RecordKeeper &Records,
+static void emitClangAttrLateParsedList(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n";
emitClangAttrLateParsedListImpl(Records, OS, LateAttrParseKind::Standard);
OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n";
}
-static void emitClangAttrLateParsedExperimentalList(RecordKeeper &Records,
+static void emitClangAttrLateParsedExperimentalList(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST)\n";
emitClangAttrLateParsedListImpl(Records, OS,
@@ -2066,7 +2063,7 @@ struct PragmaClangAttributeSupport {
};
llvm::DenseMap<const Record *, RuleOrAggregateRuleSet> SubjectsToRules;
- PragmaClangAttributeSupport(RecordKeeper &Records);
+ PragmaClangAttributeSupport(const RecordKeeper &Records);
bool isAttributedSupported(const Record &Attribute);
@@ -2105,9 +2102,7 @@ static bool doesDeclDeriveFrom(const Record *D, const Record *Base) {
}
PragmaClangAttributeSupport::PragmaClangAttributeSupport(
- RecordKeeper &Records) {
- std::vector<Record *> MetaSubjects =
- Records.getAllDerivedDefinitions("AttrSubjectMatcherRule");
+ const RecordKeeper &Records) {
auto MapFromSubjectsToRules = [this](const Record *SubjectContainer,
const Record *MetaSubject,
const Record *Constraint) {
@@ -2127,7 +2122,8 @@ PragmaClangAttributeSupport::PragmaClangAttributeSupport(
}
}
};
- for (const auto *MetaSubject : MetaSubjects) {
+ for (const Record *MetaSubject :
+ Records.getAllDerivedDefinitions("AttrSubjectMatcherRule")) {
MapFromSubjectsToRules(MetaSubject, MetaSubject, /*Constraints=*/nullptr);
std::vector<Record *> Constraints =
MetaSubject->getValueAsListOfDefs("Constraints");
@@ -2135,17 +2131,15 @@ PragmaClangAttributeSupport::PragmaClangAttributeSupport(
MapFromSubjectsToRules(Constraint, MetaSubject, Constraint);
}
- std::vector<Record *> Aggregates =
- Records.getAllDerivedDefinitions("AttrSubjectMatcherAggregateRule");
- std::vector<Record *> DeclNodes =
- Records.getAllDerivedDefinitions(DeclNodeClassName);
- for (const auto *Aggregate : Aggregates) {
+ for (const Record *Aggregate :
+ Records.getAllDerivedDefinitions("AttrSubjectMatcherAggregateRule")) {
Record *SubjectDecl = Aggregate->getValueAsDef("Subject");
// Gather sub-classes of the aggregate subject that act as attribute
// subject rules.
std::vector<AttributeSubjectMatchRule> Rules;
- for (const auto *D : DeclNodes) {
+ for (const Record *D :
+ Records.getAllDerivedDefinitions(DeclNodeClassName)) {
if (doesDeclDeriveFrom(D, SubjectDecl)) {
auto It = SubjectsToRules.find(D);
if (It == SubjectsToRules.end())
@@ -2169,7 +2163,7 @@ PragmaClangAttributeSupport::PragmaClangAttributeSupport(
}
static PragmaClangAttributeSupport &
-getPragmaAttributeSupport(RecordKeeper &Records) {
+getPragmaAttributeSupport(const RecordKeeper &Records) {
static PragmaClangAttributeSupport Instance(Records);
return Instance;
}
@@ -2403,9 +2397,8 @@ std::map<std::string, std::vector<const Record *>> NameToAttrsMap;
/// Build a map from the attribute name to the Attrs that use that name. If more
/// than one Attr use a name, the arguments could be different so a more complex
/// check is needed in the generated switch.
-void generateNameToAttrsMap(RecordKeeper &Records) {
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
- for (const auto *A : Attrs) {
+void generateNameToAttrsMap(const RecordKeeper &Records) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*A);
for (const auto &S : Spellings) {
auto It = NameToAttrsMap.find(S.name());
@@ -2510,12 +2503,12 @@ static bool isTypeArgument(const Record *Arg) {
}
/// Emits the first-argument-is-type property for attributes.
-static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) {
+static void emitClangAttrTypeArgList(const RecordKeeper &Records,
+ raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n";
std::map<std::string, FSIVecTy> FSIMap;
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
// Determine whether the first argument is a type.
std::vector<Record *> Args = Attr->getValueAsListOfDefs("Args");
if (Args.empty())
@@ -2531,7 +2524,8 @@ static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) {
/// Emits the parse-arguments-in-unevaluated-context property for
/// attributes.
-static void emitClangAttrArgContextList(RecordKeeper &Records, raw_ostream &OS) {
+static void emitClangAttrArgContextList(const RecordKeeper &Records,
+ raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_ARG_CONTEXT_LIST)\n";
std::map<std::string, FSIVecTy> FSIMap;
ParsedAttrMap Attrs = getParsedAttrList(Records);
@@ -2590,12 +2584,11 @@ static bool isVariadicStringLiteralArgument(const Record *Arg) {
return ArgKind == "VariadicStringArgument";
}
-static void emitClangAttrVariadicIdentifierArgList(RecordKeeper &Records,
+static void emitClangAttrVariadicIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n";
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::map<std::string, FSIVecTy> FSIMap;
- for (const auto *A : Attrs) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
// Determine whether the first argument is a variadic identifier.
std::vector<Record *> Args = A->getValueAsListOfDefs("Args");
if (Args.empty() || !isVariadicIdentifierArgument(Args[0]))
@@ -2608,8 +2601,9 @@ static void emitClangAttrVariadicIdentifierArgList(RecordKeeper &Records,
// Emits the list of arguments that should be parsed as unevaluated string
// literals for each attribute.
-static void emitClangAttrUnevaluatedStringLiteralList(RecordKeeper &Records,
- raw_ostream &OS) {
+static void
+emitClangAttrUnevaluatedStringLiteralList(const RecordKeeper &Records,
+ raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_STRING_LITERAL_ARG_LIST)\n";
auto MakeMask = [](ArrayRef<Record *> Args) {
@@ -2626,9 +2620,8 @@ static void emitClangAttrUnevaluatedStringLiteralList(RecordKeeper &Records,
return Bits;
};
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::map<std::string, FSIVecTy> FSIMap;
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
// Determine whether there are any string arguments.
uint32_t ArgMask = MakeMask(Attr->getValueAsListOfDefs("Args"));
if (!ArgMask)
@@ -2640,12 +2633,12 @@ static void emitClangAttrUnevaluatedStringLiteralList(RecordKeeper &Records,
}
// Emits the first-argument-is-identifier property for attributes.
-static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) {
+static void emitClangAttrIdentifierArgList(const RecordKeeper &Records,
+ raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
std::map<std::string, FSIVecTy> FSIMap;
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
// Determine whether the first argument is an identifier.
std::vector<Record *> Args = Attr->getValueAsListOfDefs("Args");
if (Args.empty() || !isIdentifierArgument(Args[0]))
@@ -2657,13 +2650,11 @@ static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &O
}
// Emits the list for attributes having StrictEnumParameters.
-static void emitClangAttrStrictIdentifierArgList(RecordKeeper &Records,
+static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST)\n";
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
-
std::map<std::string, FSIVecTy> FSIMap;
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
if (!Attr->getValueAsBit("StrictEnumParameters"))
continue;
// Check that there is really an identifier argument.
@@ -2684,12 +2675,11 @@ static bool keywordThisIsaIdentifierInArgument(const Record *Arg) {
.Default(false);
}
-static void emitClangAttrThisIsaIdentifierArgList(RecordKeeper &Records,
+static void emitClangAttrThisIsaIdentifierArgList(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST)\n";
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::map<std::string, FSIVecTy> FSIMap;
- for (const auto *A : Attrs) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
// Determine whether the first argument is a variadic identifier.
std::vector<Record *> Args = A->getValueAsListOfDefs("Args");
if (Args.empty() || !keywordThisIsaIdentifierInArgument(Args[0]))
@@ -2700,7 +2690,7 @@ static void emitClangAttrThisIsaIdentifierArgList(RecordKeeper &Records,
OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n";
}
-static void emitClangAttrAcceptsExprPack(RecordKeeper &Records,
+static void emitClangAttrAcceptsExprPack(const RecordKeeper &Records,
raw_ostream &OS) {
OS << "#if defined(CLANG_ATTR_ACCEPTS_EXPR_PACK)\n";
ParsedAttrMap Attrs = getParsedAttrList(Records);
@@ -2733,9 +2723,8 @@ static void emitFormInitializer(raw_ostream &OS,
<< " /*IsRegularKeywordAttribute*/}";
}
-static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
+static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
bool Header) {
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
ParsedAttrMap AttrMap = getParsedAttrList(Records);
// Helper to print the starting character of an attribute argument. If there
@@ -2750,7 +2739,7 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
<< " OS << \", \";\n"
<< "}\n";
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
// FIXME: Currently, documentation is generated as-needed due to the fact
@@ -3235,7 +3224,7 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
}
}
// Emits the class definitions for attributes.
-void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangAttrClass(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute classes' definitions", OS, Records);
OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
@@ -3247,19 +3236,17 @@ void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the class method definitions for attributes.
-void clang::EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangAttrImpl(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute classes' member function definitions", OS,
Records);
emitAttributes(Records, OS, false);
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
-
// Instead of relying on virtual dispatch we just create a huge dispatch
// switch. This is both smaller and faster than virtual functions.
auto EmitFunc = [&](const char *Method) {
OS << " switch (getKind()) {\n";
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
if (!R.getValueAsBit("ASTNode"))
continue;
@@ -3285,7 +3272,7 @@ void clang::EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
}
static void emitAttrList(raw_ostream &OS, StringRef Class,
- const std::vector<Record*> &AttrList) {
+ const std::vector<const Record *> &AttrList) {
for (auto Cur : AttrList) {
OS << Class << "(" << Cur->getName() << ")\n";
}
@@ -3333,13 +3320,13 @@ namespace {
/// A class of attributes.
struct AttrClass {
const AttrClassDescriptor &Descriptor;
- Record *TheRecord;
+ const Record *TheRecord;
AttrClass *SuperClass = nullptr;
std::vector<AttrClass*> SubClasses;
- std::vector<Record*> Attrs;
+ std::vector<const Record *> Attrs;
- AttrClass(const AttrClassDescriptor &Descriptor, Record *R)
- : Descriptor(Descriptor), TheRecord(R) {}
+ AttrClass(const AttrClassDescriptor &Descriptor, const Record *R)
+ : Descriptor(Descriptor), TheRecord(R) {}
void emitDefaultDefines(raw_ostream &OS) const {
// Default the macro unless this is a root class (i.e. Attr).
@@ -3361,7 +3348,7 @@ namespace {
::emitAttrList(OS, Descriptor.MacroName, Attrs);
}
- void classifyAttrOnRoot(Record *Attr) {
+ void classifyAttrOnRoot(const Record *Attr) {
bool result = classifyAttr(Attr);
assert(result && "failed to classify on root"); (void) result;
}
@@ -3373,7 +3360,7 @@ namespace {
}
private:
- bool classifyAttr(Record *Attr) {
+ bool classifyAttr(const Record *Attr) {
// Check all the subclasses.
for (auto SubClass : SubClasses) {
if (SubClass->classifyAttr(Attr))
@@ -3389,13 +3376,13 @@ namespace {
return false;
}
- Record *getFirstAttr() const {
+ const Record *getFirstAttr() const {
if (!SubClasses.empty())
return SubClasses.front()->getFirstAttr();
return Attrs.front();
}
- Record *getLastAttr() const {
+ const Record *getLastAttr() const {
if (!Attrs.empty())
return Attrs.back();
return SubClasses.back()->getLastAttr();
@@ -3407,7 +3394,7 @@ namespace {
std::vector<std::unique_ptr<AttrClass>> Classes;
public:
- AttrClassHierarchy(RecordKeeper &Records) {
+ AttrClassHierarchy(const RecordKeeper &Records) {
// Find records for all the classes.
for (auto &Descriptor : AttrClassDescriptors) {
Record *ClassRecord = Records.getClass(Descriptor.TableGenName);
@@ -3453,7 +3440,7 @@ namespace {
Class->emitAttrRange(OS);
}
- void classifyAttr(Record *Attr) {
+ void classifyAttr(const Record *Attr) {
// Add the attribute to the root class.
Classes[0]->classifyAttrOnRoot(Attr);
}
@@ -3467,7 +3454,7 @@ namespace {
return nullptr;
}
- AttrClass *findSuperClass(Record *R) const {
+ AttrClass *findSuperClass(const Record *R) const {
// TableGen flattens the superclass list, so we just need to walk it
// in reverse.
auto SuperClasses = R->getSuperClasses();
@@ -3484,7 +3471,7 @@ namespace {
namespace clang {
// Emits the enumeration list for attributes.
-void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrList(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
Records);
@@ -3494,9 +3481,8 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
Hierarchy.emitDefaultDefines(OS);
emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr);
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
- std::vector<Record *> PragmaAttrs;
- for (auto *Attr : Attrs) {
+ std::vector<const Record *> PragmaAttrs;
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
if (!Attr->getValueAsBit("ASTNode"))
continue;
@@ -3525,7 +3511,8 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the enumeration list for attributes.
-void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrSubjectMatchRuleList(const RecordKeeper &Records,
+ raw_ostream &OS) {
emitSourceFileHeader(
"List of all attribute subject matching rules that Clang recognizes", OS,
Records);
@@ -3537,17 +3524,16 @@ void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the code to read an attribute from a precompiled header.
-void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrPCHRead(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute deserialization code", OS, Records);
Record *InhClass = Records.getClass("InheritableAttr");
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"),
- ArgRecords;
+ std::vector<Record *> ArgRecords;
std::vector<std::unique_ptr<Argument>> Args;
std::unique_ptr<VariadicExprArgument> DelayedArgs;
OS << " switch (Kind) {\n";
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
if (!R.getValueAsBit("ASTNode"))
continue;
@@ -3592,14 +3578,14 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the code to write an attribute to a precompiled header.
-void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrPCHWrite(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute serialization code", OS, Records);
Record *InhClass = Records.getClass("InheritableAttr");
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
+ std::vector<Record *> Args;
OS << " switch (A->getKind()) {\n";
- for (const auto *Attr : Attrs) {
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
if (!R.getValueAsBit("ASTNode"))
continue;
@@ -3784,7 +3770,7 @@ static void GenerateHasAttrSpellingStringSwitch(
namespace clang {
// Emits list of regular keyword attributes with info about their arguments.
-void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
+void EmitClangRegularKeywordAttributeInfo(const RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader(
"A list of regular keyword attributes generated from the attribute"
@@ -3792,7 +3778,7 @@ void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
OS);
// Assume for now that the same token is not used in multiple regular
// keyword attributes.
- for (auto *R : Records.getAllDerivedDefinitions("Attr"))
+ for (const Record *R : Records.getAllDerivedDefinitions("Attr"))
for (const auto &S : GetFlattenedSpellings(*R)) {
if (!isRegularKeywordAttribute(S))
continue;
@@ -3808,13 +3794,12 @@ void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
}
// Emits the list of spellings for attributes.
-void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrHasAttrImpl(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Code to implement the __has_attribute logic", OS,
Records);
// Separate all of the attributes out into four group: generic, C++11, GNU,
// and declspecs. Then generate a big switch statement for each of them.
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::vector<std::pair<const Record *, FlattenedSpelling>> Declspec, Microsoft,
GNU, Pragma, HLSLAnnotation;
std::map<std::string,
@@ -3823,7 +3808,7 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
// Walk over the list of all attributes, and split them out based on the
// spelling variety.
- for (auto *R : Attrs) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Attr")) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
for (const auto &SI : Spellings) {
const std::string &Variety = SI.variety();
@@ -3895,7 +3880,8 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
OS << "}\n";
}
-void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrSpellingListIndex(const RecordKeeper &Records,
+ raw_ostream &OS) {
emitSourceFileHeader("Code to translate different attribute spellings into "
"internal identifiers",
OS, Records);
@@ -3927,11 +3913,11 @@ void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits code used by RecursiveASTVisitor to visit attributes
-void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrASTVisitor(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS,
Records);
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
+ ArrayRef<const Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
// Write method declarations for Traverse* methods.
// We emit this here because we only generate methods for attributes that
@@ -3999,7 +3985,7 @@ void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n";
}
-void EmitClangAttrTemplateInstantiateHelper(const std::vector<Record *> &Attrs,
+void EmitClangAttrTemplateInstantiateHelper(ArrayRef<const Record *> Attrs,
raw_ostream &OS,
bool AppliesToDecl) {
@@ -4053,11 +4039,12 @@ void EmitClangAttrTemplateInstantiateHelper(const std::vector<Record *> &Attrs,
}
// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrTemplateInstantiate(const RecordKeeper &Records,
+ raw_ostream &OS) {
emitSourceFileHeader("Template instantiation code for attributes", OS,
Records);
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
+ ArrayRef<const Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
OS << "namespace clang {\n"
<< "namespace sema {\n\n"
@@ -4076,7 +4063,7 @@ void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the list of parsed attributes.
-void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrParsedAttrList(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
Records);
@@ -4344,16 +4331,10 @@ static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
// written into OS and the checks for merging declaration attributes are
// written into MergeOS.
static void GenerateMutualExclusionsChecks(const Record &Attr,
- RecordKeeper &Records,
+ const RecordKeeper &Records,
raw_ostream &OS,
raw_ostream &MergeDeclOS,
raw_ostream &MergeStmtOS) {
- // Find all of the definitions that inherit from MutualExclusions and include
- // the given attribute in the list of exclusions to generate the
- // diagMutualExclusion() check.
- std::vector<Record *> ExclusionsList =
- Records.getAllDerivedDefinitions("MutualExclusions");
-
// We don't do any of this magic for type attributes yet.
if (Attr.isSubClassOf("TypeAttr"))
return;
@@ -4366,8 +4347,11 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
!CurAttrIsStmtAttr || Attr.isSubClassOf("DeclOrStmtAttr");
std::vector<std::string> DeclAttrs, StmtAttrs;
-
- for (const Record *Exclusion : ExclusionsList) {
+ // Find all of the definitions that inherit from MutualExclusions and include
+ // the given attribute in the list of exclusions to generate the
+ // diagMutualExclusion() check.
+ for (const Record *Exclusion :
+ Records.getAllDerivedDefinitions("MutualExclusions")) {
std::vector<Record *> MutuallyExclusiveAttrs =
Exclusion->getValueAsListOfDefs("Exclusions");
auto IsCurAttr = [Attr](const Record *R) {
@@ -4670,7 +4654,8 @@ void GenerateIsParamExpr(const Record &Attr, raw_ostream &OS) {
OS << "}\n\n";
}
-void GenerateHandleAttrWithDelayedArgs(RecordKeeper &Records, raw_ostream &OS) {
+void GenerateHandleAttrWithDelayedArgs(const RecordKeeper &Records,
+ raw_ostream &OS) {
OS << "static void handleAttrWithDelayedArgs(Sema &S, Decl *D, ";
OS << "const ParsedAttr &Attr) {\n";
OS << " SmallVector<Expr *, 4> ArgExprs;\n";
@@ -4708,7 +4693,7 @@ static bool IsKnownToGCC(const Record &Attr) {
}
/// Emits the parsed attribute helpers
-void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrParsedAttrImpl(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Parsed attribute helpers", OS, Records);
OS << "#if !defined(WANT_DECL_MERGE_LOGIC) && "
@@ -4872,14 +4857,14 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the kind list of parsed attributes
-void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrParsedAttrKinds(const RecordKeeper &Records,
+ raw_ostream &OS) {
emitSourceFileHeader("Attribute name matcher", OS, Records);
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::vector<StringMatcher::StringPair> GNU, Declspec, Microsoft, CXX11,
Keywords, Pragma, C23, HLSLAnnotation;
std::set<std::string> Seen;
- for (const auto *A : Attrs) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
const Record &Attr = *A;
bool SemaHandler = Attr.getValueAsBit("SemaHandler");
@@ -4973,11 +4958,11 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
}
// Emits the code to dump an attribute.
-void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrTextNodeDump(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute text node dumper", OS, Records);
- std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
- for (const auto *Attr : Attrs) {
+ std::vector<Record *> Args;
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
if (!R.getValueAsBit("ASTNode"))
continue;
@@ -5012,11 +4997,11 @@ void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) {
}
}
-void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrNodeTraverse(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute text node traverser", OS, Records);
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
- for (const auto *Attr : Attrs) {
+ std::vector<Record *> Args;
+ for (const Record *Attr : Records.getAllDerivedDefinitions("Attr")) {
const Record &R = *Attr;
if (!R.getValueAsBit("ASTNode"))
continue;
@@ -5024,7 +5009,7 @@ void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
std::string FunctionContent;
llvm::raw_string_ostream SS(FunctionContent);
- Args = R.getValueAsListOfDefs("Args");
+ std::vector<Record *> Args = R.getValueAsListOfDefs("Args");
for (const auto *Arg : Args)
createArgument(*Arg, R.getName())->writeDumpChildren(SS);
if (Attr->getValueAsBit("AcceptsExprPack"))
@@ -5041,7 +5026,8 @@ void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
}
}
-void EmitClangAttrParserStringSwitches(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrParserStringSwitches(const RecordKeeper &Records,
+ raw_ostream &OS) {
generateNameToAttrsMap(Records);
emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS, Records);
emitClangAttrArgContextList(Records, OS);
@@ -5056,16 +5042,15 @@ void EmitClangAttrParserStringSwitches(RecordKeeper &Records, raw_ostream &OS) {
emitClangAttrStrictIdentifierArgList(Records, OS);
}
-void EmitClangAttrSubjectMatchRulesParserStringSwitches(RecordKeeper &Records,
- raw_ostream &OS) {
+void EmitClangAttrSubjectMatchRulesParserStringSwitches(
+ const RecordKeeper &Records, raw_ostream &OS) {
getPragmaAttributeSupport(Records).generateParsingHelpers(OS);
}
-void EmitClangAttrDocTable(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrDocTable(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Clang attribute documentation", OS, Records);
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
- for (const auto *A : Attrs) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
if (!A->getValueAsBit("ASTNode"))
continue;
std::vector<Record *> Docs = A->getValueAsListOfDefs("Documentation");
@@ -5210,7 +5195,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
return std::make_pair(std::move(Heading), std::move(SupportedSpellings));
}
-static void WriteDocumentation(RecordKeeper &Records,
+static void WriteDocumentation(const RecordKeeper &Records,
const DocumentationData &Doc, raw_ostream &OS) {
OS << Doc.Heading << "\n" << std::string(Doc.Heading.length(), '-') << "\n";
@@ -5265,7 +5250,7 @@ static void WriteDocumentation(RecordKeeper &Records,
OS << "\n\n\n";
}
-void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
+void EmitClangAttrDocs(const RecordKeeper &Records, raw_ostream &OS) {
// Get the documentation introduction paragraph.
const Record *Documentation = Records.getDef("GlobalDocumentation");
if (!Documentation) {
@@ -5278,7 +5263,6 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
// Gather the Documentation lists from each of the attributes, based on the
// category provided.
- std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
struct CategoryLess {
bool operator()(const Record *L, const Record *R) const {
return L->getValueAsString("Name") < R->getValueAsString("Name");
@@ -5286,7 +5270,7 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
};
std::map<const Record *, std::vector<DocumentationData>, CategoryLess>
SplitDocs;
- for (const auto *A : Attrs) {
+ for (const Record *A : Records.getAllDerivedDefinitions("Attr")) {
const Record &Attr = *A;
std::vector<Record *> Docs = Attr.getValueAsListOfDefs("Documentation");
for (const auto *D : Docs) {
@@ -5325,7 +5309,7 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
}
}
-void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records,
+void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
raw_ostream &OS) {
PragmaClangAttributeSupport Support = getPragmaAttributeSupport(Records);
ParsedAttrMap Attrs = getParsedAttrList(Records);
diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index 94f12a08164fdc..0ccfba9ead32ff 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -345,7 +345,7 @@ void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
}
} // namespace
-void clang::EmitClangBuiltins(llvm::RecordKeeper &Records,
+void clang::EmitClangBuiltins(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
emitSourceFileHeader("List of builtins that Clang recognizes", OS);
@@ -371,16 +371,17 @@ void clang::EmitClangBuiltins(llvm::RecordKeeper &Records,
// AtomicBuiltins are order dependent
// emit them first to make manual checking easier
- for (const auto *Builtin : Records.getAllDerivedDefinitions("AtomicBuiltin"))
+ for (const Record *Builtin :
+ Records.getAllDerivedDefinitions("AtomicBuiltin"))
EmitBuiltin(OS, Builtin);
- for (const auto *Builtin : Records.getAllDerivedDefinitions("Builtin")) {
+ for (const Record *Builtin : Records.getAllDerivedDefinitions("Builtin")) {
if (Builtin->isSubClassOf("AtomicBuiltin"))
continue;
EmitBuiltin(OS, Builtin);
}
- for (const auto *Entry : Records.getAllDerivedDefinitions("CustomEntry")) {
+ for (const Record *Entry : Records.getAllDerivedDefinitions("CustomEntry")) {
OS << Entry->getValueAsString("Entry") << '\n';
}
diff --git a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
index aee7d38786a51c..90d44306c31e05 100644
--- a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
@@ -20,16 +20,17 @@
using namespace llvm;
-void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
+void clang::EmitClangCommentCommandInfo(const RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
OS << "namespace {\n"
"const CommandInfo Commands[] = {\n";
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
+ const std::vector<const Record *> &Tags =
+ Records.getAllDerivedDefinitions("Command");
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
+ const Record &Tag = *Tags[i];
OS << " { "
<< "\"" << Tag.getValueAsString("Name") << "\", "
<< "\"" << Tag.getValueAsString("EndCommandName") << "\", " << i << ", "
@@ -62,7 +63,7 @@ void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
std::vector<StringMatcher::StringPair> Matches;
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
+ const Record &Tag = *Tags[i];
std::string Name = std::string(Tag.getValueAsString("Name"));
std::string Return;
raw_string_ostream(Return) << "return &Commands[" << i << "];";
@@ -112,7 +113,7 @@ static std::string MangleName(StringRef Str) {
return Mangled;
}
-void clang::EmitClangCommentCommandList(RecordKeeper &Records,
+void clang::EmitClangCommentCommandList(const RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
@@ -121,11 +122,7 @@ void clang::EmitClangCommentCommandList(RecordKeeper &Records,
<< "# define COMMENT_COMMAND(NAME)\n"
<< "#endif\n";
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
- for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
- std::string MangledName = MangleName(Tag.getValueAsString("Name"));
-
- OS << "COMMENT_COMMAND(" << MangledName << ")\n";
- }
+ for (const Record *Tag : Records.getAllDerivedDefinitions("Command"))
+ OS << "COMMENT_COMMAND(" << MangleName(Tag->getValueAsString("Name"))
+ << ")\n";
}
diff --git a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
index f1cd9af0519d1b..bd75b3f6b652a1 100644
--- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
@@ -46,21 +46,17 @@ static bool translateCodePointToUTF8(unsigned CodePoint,
return true;
}
-void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
- raw_ostream &OS) {
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("NCR");
+void clang::EmitClangCommentHTMLNamedCharacterReferences(
+ const RecordKeeper &Records, raw_ostream &OS) {
std::vector<StringMatcher::StringPair> NameToUTF8;
SmallString<32> CLiteral;
- for (std::vector<Record *>::iterator I = Tags.begin(), E = Tags.end();
- I != E; ++I) {
- Record &Tag = **I;
- std::string Spelling = std::string(Tag.getValueAsString("Spelling"));
- uint64_t CodePoint = Tag.getValueAsInt("CodePoint");
+ for (const Record *Tag : Records.getAllDerivedDefinitions("NCR")) {
+ std::string Spelling = std::string(Tag->getValueAsString("Spelling"));
+ uint64_t CodePoint = Tag->getValueAsInt("CodePoint");
CLiteral.clear();
CLiteral.append("return ");
if (!translateCodePointToUTF8(CodePoint, CLiteral)) {
- SrcMgr.PrintMessage(Tag.getLoc().front(),
- SourceMgr::DK_Error,
+ SrcMgr.PrintMessage(Tag->getLoc().front(), SourceMgr::DK_Error,
Twine("invalid code point"));
continue;
}
diff --git a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
index 3dc1098753e0bf..e2fb7e2832e0b7 100644
--- a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
@@ -19,10 +19,10 @@
using namespace llvm;
-void clang::EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS) {
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag");
+void clang::EmitClangCommentHTMLTags(const RecordKeeper &Records,
+ raw_ostream &OS) {
std::vector<StringMatcher::StringPair> Matches;
- for (Record *Tag : Tags) {
+ for (const Record *Tag : Records.getAllDerivedDefinitions("Tag")) {
Matches.emplace_back(std::string(Tag->getValueAsString("Spelling")),
"return true;");
}
@@ -35,12 +35,11 @@ void clang::EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS) {
<< "}\n\n";
}
-void clang::EmitClangCommentHTMLTagsProperties(RecordKeeper &Records,
+void clang::EmitClangCommentHTMLTagsProperties(const RecordKeeper &Records,
raw_ostream &OS) {
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag");
std::vector<StringMatcher::StringPair> MatchesEndTagOptional;
std::vector<StringMatcher::StringPair> MatchesEndTagForbidden;
- for (Record *Tag : Tags) {
+ for (const Record *Tag : Records.getAllDerivedDefinitions("Tag")) {
std::string Spelling = std::string(Tag->getValueAsString("Spelling"));
StringMatcher::StringPair Match(Spelling, "return true;");
if (Tag->getValueAsBit("EndTagOptional"))
diff --git a/clang/utils/TableGen/ClangDataCollectorsEmitter.cpp b/clang/utils/TableGen/ClangDataCollectorsEmitter.cpp
index 45082935c1f794..dae6710d752358 100644
--- a/clang/utils/TableGen/ClangDataCollectorsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDataCollectorsEmitter.cpp
@@ -4,7 +4,7 @@
using namespace llvm;
-void clang::EmitClangDataCollectors(RecordKeeper &RK, raw_ostream &OS) {
+void clang::EmitClangDataCollectors(const RecordKeeper &RK, raw_ostream &OS) {
const auto &Defs = RK.getClasses();
for (const auto &Entry : Defs) {
Record &R = *Entry.second;
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 6ca24a8c74b2ff..809e2adb50ed6f 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -39,21 +39,19 @@ using namespace llvm;
namespace {
class DiagGroupParentMap {
- RecordKeeper &Records;
- std::map<const Record*, std::vector<Record*> > Mapping;
+ const RecordKeeper &Records;
+ std::map<const Record *, std::vector<const Record *>> Mapping;
+
public:
- DiagGroupParentMap(RecordKeeper &records) : Records(records) {
- std::vector<Record*> DiagGroups
- = Records.getAllDerivedDefinitions("DiagGroup");
- for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
- std::vector<Record*> SubGroups =
- DiagGroups[i]->getValueAsListOfDefs("SubGroups");
- for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
- Mapping[SubGroups[j]].push_back(DiagGroups[i]);
- }
+ DiagGroupParentMap(const RecordKeeper &records) : Records(records) {
+ for (const Record *DiagGroup :
+ Records.getAllDerivedDefinitions("DiagGroup"))
+ for (const Record *SubGroup :
+ DiagGroup->getValueAsListOfDefs("SubGroups"))
+ Mapping[SubGroup].push_back(DiagGroup);
}
- const std::vector<Record*> &getParents(const Record *Group) {
+ const std::vector<const Record *> &getParents(const Record *Group) {
return Mapping[Group];
}
};
@@ -68,7 +66,8 @@ getCategoryFromDiagGroup(const Record *Group,
// The diag group may the subgroup of one or more other diagnostic groups,
// check these for a category as well.
- const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
+ const std::vector<const Record *> &Parents =
+ DiagGroupParents.getParents(Group);
for (unsigned i = 0, e = Parents.size(); i != e; ++i) {
CatName = getCategoryFromDiagGroup(Parents[i], DiagGroupParents);
if (!CatName.empty()) return CatName;
@@ -81,7 +80,7 @@ getCategoryFromDiagGroup(const Record *Group,
static std::string getDiagnosticCategory(const Record *R,
DiagGroupParentMap &DiagGroupParents) {
// If the diagnostic is in a group, and that group has a category, use it.
- if (DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
+ if (const DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
// Check the diagnostic's diag group for a category.
std::string CatName = getCategoryFromDiagGroup(Group->getDef(),
DiagGroupParents);
@@ -94,21 +93,20 @@ static std::string getDiagnosticCategory(const Record *R,
namespace {
class DiagCategoryIDMap {
- RecordKeeper &Records;
+ const RecordKeeper &Records;
StringMap<unsigned> CategoryIDs;
std::vector<std::string> CategoryStrings;
public:
- DiagCategoryIDMap(RecordKeeper &records) : Records(records) {
+ DiagCategoryIDMap(const RecordKeeper &records) : Records(records) {
DiagGroupParentMap ParentInfo(Records);
// The zero'th category is "".
CategoryStrings.push_back("");
CategoryIDs[""] = 0;
- std::vector<Record*> Diags =
- Records.getAllDerivedDefinitions("Diagnostic");
- for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
- std::string Category = getDiagnosticCategory(Diags[i], ParentInfo);
+ for (const Record *Diag :
+ Records.getAllDerivedDefinitions("Diagnostic")) {
+ std::string Category = getDiagnosticCategory(Diag, ParentInfo);
if (Category.empty()) continue; // Skip diags with no category.
unsigned &ID = CategoryIDs[Category];
@@ -153,10 +151,9 @@ static bool diagGroupBeforeByName(const Record *LHS, const Record *RHS) {
/// Invert the 1-[0/1] mapping of diags to group into a one to many
/// mapping of groups to diags in the group.
-static void groupDiagnostics(const std::vector<Record*> &Diags,
- const std::vector<Record*> &DiagGroups,
+static void groupDiagnostics(ArrayRef<const Record *> Diags,
+ ArrayRef<const Record *> DiagGroups,
std::map<std::string, GroupInfo> &DiagsInGroup) {
-
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
const Record *R = Diags[i];
DefInit *DI = dyn_cast<DefInit>(R->getValueInit("Group"));
@@ -172,7 +169,7 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
// Add all DiagGroup's to the DiagsInGroup list to make sure we pick up empty
// groups (these are warnings that GCC supports that clang never produces).
for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
- Record *Group = DiagGroups[i];
+ const Record *Group = DiagGroups[i];
GroupInfo &GI =
DiagsInGroup[std::string(Group->getValueAsString("GroupName"))];
GI.GroupName = Group->getName();
@@ -255,20 +252,18 @@ class InferPedantic {
GMap;
DiagGroupParentMap &DiagGroupParents;
- const std::vector<Record*> &Diags;
- const std::vector<Record*> DiagGroups;
+ ArrayRef<const Record *> Diags;
+ ArrayRef<const Record *> DiagGroups;
std::map<std::string, GroupInfo> &DiagsInGroup;
llvm::DenseSet<const Record*> DiagsSet;
GMap GroupCount;
public:
InferPedantic(DiagGroupParentMap &DiagGroupParents,
- const std::vector<Record*> &Diags,
- const std::vector<Record*> &DiagGroups,
+ ArrayRef<const Record *> Diags,
+ ArrayRef<const Record *> DiagGroups,
std::map<std::string, GroupInfo> &DiagsInGroup)
- : DiagGroupParents(DiagGroupParents),
- Diags(Diags),
- DiagGroups(DiagGroups),
- DiagsInGroup(DiagsInGroup) {}
+ : DiagGroupParents(DiagGroupParents), Diags(Diags),
+ DiagGroups(DiagGroups), DiagsInGroup(DiagsInGroup) {}
/// Compute the set of diagnostics and groups that are immediately
/// in -Wpedantic.
@@ -302,7 +297,8 @@ bool InferPedantic::isSubGroupOfGroup(const Record *Group,
if (GName == GroupName)
return true;
- const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
+ const std::vector<const Record *> &Parents =
+ DiagGroupParents.getParents(Group);
for (unsigned i = 0, e = Parents.size(); i != e; ++i)
if (isSubGroupOfGroup(Parents[i], GName))
return true;
@@ -347,7 +343,8 @@ void InferPedantic::markGroup(const Record *Group) {
// group's count is equal to the number of subgroups and diagnostics in
// that group, we can safely add this group to -Wpedantic.
if (groupInPedantic(Group, /* increment */ true)) {
- const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
+ const std::vector<const Record *> &Parents =
+ DiagGroupParents.getParents(Group);
for (unsigned i = 0, e = Parents.size(); i != e; ++i)
markGroup(Parents[i]);
}
@@ -359,7 +356,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
// "pedantic" group. For those that aren't explicitly included in -Wpedantic,
// mark them for consideration to be included in -Wpedantic directly.
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
- Record *R = Diags[i];
+ const Record *R = Diags[i];
if (isExtension(R) && isOffByDefault(R)) {
DiagsSet.insert(R);
if (DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
@@ -375,7 +372,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
// march through Diags a second time to ensure the results are emitted
// in deterministic order.
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
- Record *R = Diags[i];
+ const Record *R = Diags[i];
if (!DiagsSet.count(R))
continue;
// Check if the group is implicitly in -Wpedantic. If so,
@@ -401,13 +398,14 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
// march through the groups to ensure the results are emitted
/// in a deterministc order.
for (unsigned i = 0, ei = DiagGroups.size(); i != ei; ++i) {
- Record *Group = DiagGroups[i];
+ const Record *Group = DiagGroups[i];
if (!groupInPedantic(Group))
continue;
- const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
- bool AllParentsInPedantic =
- llvm::all_of(Parents, [&](Record *R) { return groupInPedantic(R); });
+ const std::vector<const Record *> &Parents =
+ DiagGroupParents.getParents(Group);
+ bool AllParentsInPedantic = llvm::all_of(
+ Parents, [&](const Record *R) { return groupInPedantic(R); });
// If all the parents are in -Wpedantic, this means that this diagnostic
// group will be indirectly included by -Wpedantic already. In that
// case, do not add it directly to -Wpedantic. If the group has no
@@ -583,9 +581,10 @@ struct DiagnosticTextBuilder {
DiagnosticTextBuilder(DiagnosticTextBuilder const &) = delete;
DiagnosticTextBuilder &operator=(DiagnosticTextBuilder const &) = delete;
- DiagnosticTextBuilder(RecordKeeper &Records) {
+ DiagnosticTextBuilder(const RecordKeeper &Records) {
// Build up the list of substitution records.
- for (auto *S : Records.getAllDerivedDefinitions("TextSubstitution")) {
+ for (const Record *S :
+ Records.getAllDerivedDefinitions("TextSubstitution")) {
EvaluatingRecordGuard Guard(&EvaluatingRecord, S);
Substitutions.try_emplace(
S->getName(), DiagText(*this, S->getValueAsString("Substitution")));
@@ -593,7 +592,7 @@ struct DiagnosticTextBuilder {
// Check that no diagnostic definitions have the same name as a
// substitution.
- for (Record *Diag : Records.getAllDerivedDefinitions("Diagnostic")) {
+ for (const Record *Diag : Records.getAllDerivedDefinitions("Diagnostic")) {
StringRef Name = Diag->getName();
if (Substitutions.count(Name))
llvm::PrintFatalError(
@@ -1407,7 +1406,7 @@ static void verifyDiagnosticWording(const Record &Diag) {
/// ClangDiagsDefsEmitter - The top-level class emits .def files containing
/// declarations of Clang diagnostics.
-void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
+void clang::EmitClangDiagsDefs(const RecordKeeper &Records, raw_ostream &OS,
const std::string &Component) {
// Write the #if guard
if (!Component.empty()) {
@@ -1421,10 +1420,10 @@ void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
DiagnosticTextBuilder DiagTextBuilder(Records);
- std::vector<Record *> Diags = Records.getAllDerivedDefinitions("Diagnostic");
-
- std::vector<Record*> DiagGroups
- = Records.getAllDerivedDefinitions("DiagGroup");
+ ArrayRef<const Record *> Diags =
+ Records.getAllDerivedDefinitions("Diagnostic");
+ ArrayRef<const Record *> DiagGroups =
+ Records.getAllDerivedDefinitions("DiagGroup");
std::map<std::string, GroupInfo> DiagsInGroup;
groupDiagnostics(Diags, DiagGroups, DiagsInGroup);
@@ -1437,18 +1436,16 @@ void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
InferPedantic inferPedantic(DGParentMap, Diags, DiagGroups, DiagsInGroup);
inferPedantic.compute(&DiagsInPedantic, (RecordVec*)nullptr);
- for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
- const Record &R = *Diags[i];
-
- // Check if this is an error that is accidentally in a warning
- // group.
+ for (const Record *Diag : Diags) {
+ const Record &R = *Diag;
+ // Check if this is an error that is accidentally in a warning group.
if (isError(R)) {
if (DefInit *Group = dyn_cast<DefInit>(R.getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();
- const std::string &GroupName =
- std::string(GroupRec->getValueAsString("GroupName"));
- PrintFatalError(R.getLoc(), "Error " + R.getName() +
- " cannot be in a warning group [" + GroupName + "]");
+ StringRef GroupName = GroupRec->getValueAsString("GroupName");
+ PrintFatalError(R.getLoc(), Twine("Error ") + R.getName() +
+ " cannot be in a warning group [" +
+ GroupName + "]");
}
}
@@ -1764,7 +1761,7 @@ static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
/// CATEGORY("Lambda Issue", DiagCat_Lambda_Issue)
/// #endif
/// \endcode
-static void emitCategoryTable(RecordKeeper &Records, raw_ostream &OS) {
+static void emitCategoryTable(const RecordKeeper &Records, raw_ostream &OS) {
DiagCategoryIDMap CategoriesByID(Records);
OS << "\n#ifdef GET_CATEGORY_TABLE\n";
for (auto const &C : CategoriesByID)
@@ -1772,13 +1769,14 @@ static void emitCategoryTable(RecordKeeper &Records, raw_ostream &OS) {
OS << "#endif // GET_CATEGORY_TABLE\n\n";
}
-void clang::EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangDiagGroups(const RecordKeeper &Records, raw_ostream &OS) {
// Compute a mapping from a DiagGroup to all of its parents.
DiagGroupParentMap DGParentMap(Records);
- std::vector<Record *> Diags = Records.getAllDerivedDefinitions("Diagnostic");
+ ArrayRef<const Record *> Diags =
+ Records.getAllDerivedDefinitions("Diagnostic");
- std::vector<Record *> DiagGroups =
+ ArrayRef<const Record *> DiagGroups =
Records.getAllDerivedDefinitions("DiagGroup");
std::map<std::string, GroupInfo> DiagsInGroup;
@@ -1824,9 +1822,10 @@ struct RecordIndexElement
};
} // end anonymous namespace.
-void clang::EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS) {
- const std::vector<Record*> &Diags =
- Records.getAllDerivedDefinitions("Diagnostic");
+void clang::EmitClangDiagsIndexName(const RecordKeeper &Records,
+ raw_ostream &OS) {
+ ArrayRef<const Record *> Diags =
+ Records.getAllDerivedDefinitions("Diagnostic");
std::vector<RecordIndexElement> Index;
Index.reserve(Diags.size());
@@ -1915,7 +1914,7 @@ void writeDiagnosticText(DiagnosticTextBuilder &Builder, const Record *R,
} // namespace
} // namespace docs
-void clang::EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
using namespace docs;
// Get the documentation introduction paragraph.
@@ -1930,10 +1929,10 @@ void clang::EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
DiagnosticTextBuilder Builder(Records);
- std::vector<Record*> Diags =
+ ArrayRef<const Record *> Diags =
Records.getAllDerivedDefinitions("Diagnostic");
- std::vector<Record*> DiagGroups =
+ std::vector<const Record *> DiagGroups =
Records.getAllDerivedDefinitions("DiagGroup");
llvm::sort(DiagGroups, diagGroupBeforeByName);
diff --git a/clang/utils/TableGen/ClangOpcodesEmitter.cpp b/clang/utils/TableGen/ClangOpcodesEmitter.cpp
index 120e1e2efa32b4..86aa935247787b 100644
--- a/clang/utils/TableGen/ClangOpcodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpcodesEmitter.cpp
@@ -20,11 +20,11 @@ using namespace llvm;
namespace {
class ClangOpcodesEmitter {
- RecordKeeper &Records;
+ const RecordKeeper &Records;
unsigned NumTypes;
public:
- ClangOpcodesEmitter(RecordKeeper &R)
+ ClangOpcodesEmitter(const RecordKeeper &R)
: Records(R), NumTypes(Records.getAllDerivedDefinitions("Type").size()) {}
void run(raw_ostream &OS);
@@ -84,7 +84,7 @@ void Enumerate(const Record *R, StringRef N,
} // namespace
void ClangOpcodesEmitter::run(raw_ostream &OS) {
- for (const auto *Opcode : Records.getAllDerivedDefinitions("Opcode")) {
+ for (const Record *Opcode : Records.getAllDerivedDefinitions("Opcode")) {
// The name is the record name, unless overriden.
StringRef N = Opcode->getValueAsString("Name");
if (N.empty())
@@ -404,6 +404,6 @@ void ClangOpcodesEmitter::PrintTypes(raw_ostream &OS,
OS << ">";
}
-void clang::EmitClangOpcodes(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangOpcodes(const RecordKeeper &Records, raw_ostream &OS) {
ClangOpcodesEmitter(Records).run(OS);
}
diff --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 968b3e0661a8f3..9208556e421e79 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -87,7 +87,7 @@ struct BuiltinTableEntries {
//
class BuiltinNameEmitter {
public:
- BuiltinNameEmitter(RecordKeeper &Records, raw_ostream &OS)
+ BuiltinNameEmitter(const RecordKeeper &Records, raw_ostream &OS)
: Records(Records), OS(OS) {}
// Entrypoint to generate the functions and structures for checking
@@ -100,7 +100,7 @@ class BuiltinNameEmitter {
// Contains OpenCL builtin functions and related information, stored as
// Record instances. They are coming from the associated TableGen file.
- RecordKeeper &Records;
+ const RecordKeeper &Records;
// The output file.
raw_ostream &OS;
@@ -113,7 +113,7 @@ class BuiltinNameEmitter {
// \param Output (out) String containing the enums to emit in the output file.
// \param List (out) List containing the extracted Types, except the Types in
// TypesSeen.
- void ExtractEnumTypes(std::vector<Record *> &Types,
+ void ExtractEnumTypes(ArrayRef<const Record *> Types,
StringMap<bool> &TypesSeen, std::string &Output,
std::vector<const Record *> &List);
@@ -237,7 +237,7 @@ class BuiltinNameEmitter {
/// Base class for emitting a file (e.g. header or test) from OpenCLBuiltins.td
class OpenCLBuiltinFileEmitterBase {
public:
- OpenCLBuiltinFileEmitterBase(RecordKeeper &Records, raw_ostream &OS)
+ OpenCLBuiltinFileEmitterBase(const RecordKeeper &Records, raw_ostream &OS)
: Records(Records), OS(OS) {}
virtual ~OpenCLBuiltinFileEmitterBase() = default;
@@ -305,7 +305,7 @@ class OpenCLBuiltinFileEmitterBase {
// Contains OpenCL builtin functions and related information, stored as
// Record instances. They are coming from the associated TableGen file.
- RecordKeeper &Records;
+ const RecordKeeper &Records;
// The output file.
raw_ostream &OS;
@@ -316,7 +316,7 @@ class OpenCLBuiltinFileEmitterBase {
// builtin function described in the .td input.
class OpenCLBuiltinTestEmitter : public OpenCLBuiltinFileEmitterBase {
public:
- OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+ OpenCLBuiltinTestEmitter(const RecordKeeper &Records, raw_ostream &OS)
: OpenCLBuiltinFileEmitterBase(Records, OS) {}
// Entrypoint to generate the functions for testing all OpenCL builtin
@@ -329,7 +329,7 @@ class OpenCLBuiltinTestEmitter : public OpenCLBuiltinFileEmitterBase {
// prototype for each builtin function described in the .td input.
class OpenCLBuiltinHeaderEmitter : public OpenCLBuiltinFileEmitterBase {
public:
- OpenCLBuiltinHeaderEmitter(RecordKeeper &Records, raw_ostream &OS)
+ OpenCLBuiltinHeaderEmitter(const RecordKeeper &Records, raw_ostream &OS)
: OpenCLBuiltinFileEmitterBase(Records, OS) {}
// Entrypoint to generate the header.
@@ -362,13 +362,13 @@ void BuiltinNameEmitter::Emit() {
EmitQualTypeFinder();
}
-void BuiltinNameEmitter::ExtractEnumTypes(std::vector<Record *> &Types,
+void BuiltinNameEmitter::ExtractEnumTypes(ArrayRef<const Record *> Types,
StringMap<bool> &TypesSeen,
std::string &Output,
std::vector<const Record *> &List) {
raw_string_ostream SS(Output);
- for (const auto *T : Types) {
+ for (const Record *T : Types) {
if (!TypesSeen.contains(T->getValueAsString("Name"))) {
SS << " OCLT_" + T->getValueAsString("Name") << ",\n";
// Save the type names in the same order as their enum value. Note that
@@ -392,11 +392,11 @@ void BuiltinNameEmitter::EmitDeclarations() {
// Extract generic types and non-generic types separately, to keep
// gentypes at the end of the enum which simplifies the special handling
// for gentypes in SemaLookup.
- std::vector<Record *> GenTypes =
+ ArrayRef<const Record *> GenTypes =
Records.getAllDerivedDefinitions("GenericType");
ExtractEnumTypes(GenTypes, TypesSeen, GenTypeEnums, GenTypeList);
- std::vector<Record *> Types = Records.getAllDerivedDefinitions("Type");
+ ArrayRef<const Record *> Types = Records.getAllDerivedDefinitions("Type");
ExtractEnumTypes(Types, TypesSeen, TypeEnums, TypeList);
OS << TypeEnums;
@@ -499,16 +499,14 @@ static void VerifySignature(const std::vector<Record *> &Signature,
void BuiltinNameEmitter::GetOverloads() {
// Populate the TypeMap.
- std::vector<Record *> Types = Records.getAllDerivedDefinitions("Type");
unsigned I = 0;
- for (const auto &T : Types) {
+ for (const Record *T : Records.getAllDerivedDefinitions("Type")) {
TypeMap.insert(std::make_pair(T, I++));
}
// Populate the SignaturesList and the FctOverloadMap.
unsigned CumulativeSignIndex = 0;
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions("Builtin");
- for (const auto *B : Builtins) {
+ for (const Record *B : Records.getAllDerivedDefinitions("Builtin")) {
StringRef BName = B->getValueAsString("Name");
if (!FctOverloadMap.contains(BName)) {
FctOverloadMap.insert(std::make_pair(
@@ -538,10 +536,9 @@ void BuiltinNameEmitter::GetOverloads() {
void BuiltinNameEmitter::EmitExtensionTable() {
OS << "static const char *FunctionExtensionTable[] = {\n";
unsigned Index = 0;
- std::vector<Record *> FuncExtensions =
- Records.getAllDerivedDefinitions("FunctionExtension");
- for (const auto &FE : FuncExtensions) {
+ for (const Record *FE :
+ Records.getAllDerivedDefinitions("FunctionExtension")) {
// Emit OpenCL extension table entry.
OS << " // " << Index << ": " << FE->getName() << "\n"
<< " \"" << FE->getValueAsString("ExtName") << "\",\n";
@@ -793,7 +790,7 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
)";
// Generate list of vector sizes for each generic type.
- for (const auto *VectList : Records.getAllDerivedDefinitions("IntList")) {
+ for (const Record *VectList : Records.getAllDerivedDefinitions("IntList")) {
OS << " constexpr unsigned List"
<< VectList->getValueAsString("Name") << "[] = {";
for (const auto V : VectList->getValueAsListOfInts("List")) {
@@ -807,15 +804,12 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
OS << "\n switch (Ty.ID) {\n";
// Switch cases for image types (Image2d, Image3d, ...)
- std::vector<Record *> ImageTypes =
- Records.getAllDerivedDefinitions("ImageType");
-
// Map an image type name to its 3 access-qualified types (RO, WO, RW).
- StringMap<SmallVector<Record *, 3>> ImageTypesMap;
- for (auto *IT : ImageTypes) {
+ StringMap<SmallVector<const Record *, 3>> ImageTypesMap;
+ for (const Record *IT : Records.getAllDerivedDefinitions("ImageType")) {
auto Entry = ImageTypesMap.find(IT->getValueAsString("Name"));
if (Entry == ImageTypesMap.end()) {
- SmallVector<Record *, 3> ImageList;
+ SmallVector<const Record *, 3> ImageList;
ImageList.push_back(IT);
ImageTypesMap.insert(
std::make_pair(IT->getValueAsString("Name"), ImageList));
@@ -858,7 +852,8 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
}
// Switch cases for generic types.
- for (const auto *GenType : Records.getAllDerivedDefinitions("GenericType")) {
+ for (const Record *GenType :
+ Records.getAllDerivedDefinitions("GenericType")) {
OS << " case OCLT_" << GenType->getValueAsString("Name") << ": {\n";
// Build the Cartesian product of (vector sizes) x (types). Only insert
@@ -902,10 +897,9 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
// Switch cases for non generic, non image types (int, int4, float, ...).
// Only insert the plain scalar type; vector information and type qualifiers
// are added in step 2.
- std::vector<Record *> Types = Records.getAllDerivedDefinitions("Type");
StringMap<bool> TypesSeen;
- for (const auto *T : Types) {
+ for (const Record *T : Records.getAllDerivedDefinitions("Type")) {
// Check this is not an image type
if (ImageTypesMap.contains(T->getValueAsString("Name")))
continue;
@@ -1223,8 +1217,7 @@ void OpenCLBuiltinTestEmitter::emit() {
unsigned TestID = 0;
// Iterate over all builtins.
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions("Builtin");
- for (const auto *B : Builtins) {
+ for (const Record *B : Records.getAllDerivedDefinitions("Builtin")) {
StringRef Name = B->getValueAsString("Name");
SmallVector<SmallVector<std::string, 2>, 4> FTypes;
@@ -1286,7 +1279,10 @@ void OpenCLBuiltinHeaderEmitter::emit() {
)";
// Iterate over all builtins; sort to follow order of definition in .td file.
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions("Builtin");
+ // FIXME: getAllDerivedDefinitions() already returs records sorted by
+ // LessRecord order, and that's not the order of definitions in the .td file.
+ std::vector<const Record *> Builtins =
+ Records.getAllDerivedDefinitions("Builtin");
llvm::sort(Builtins, LessRecord());
for (const auto *B : Builtins) {
@@ -1331,18 +1327,19 @@ void OpenCLBuiltinHeaderEmitter::emit() {
"#pragma OPENCL EXTENSION all : disable\n";
}
-void clang::EmitClangOpenCLBuiltins(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangOpenCLBuiltins(const RecordKeeper &Records,
+ raw_ostream &OS) {
BuiltinNameEmitter NameChecker(Records, OS);
NameChecker.Emit();
}
-void clang::EmitClangOpenCLBuiltinHeader(RecordKeeper &Records,
+void clang::EmitClangOpenCLBuiltinHeader(const RecordKeeper &Records,
raw_ostream &OS) {
OpenCLBuiltinHeaderEmitter HeaderFileGenerator(Records, OS);
HeaderFileGenerator.emit();
}
-void clang::EmitClangOpenCLBuiltinTests(RecordKeeper &Records,
+void clang::EmitClangOpenCLBuiltinTests(const RecordKeeper &Records,
raw_ostream &OS) {
OpenCLBuiltinTestEmitter TestFileGenerator(Records, OS);
TestFileGenerator.emit();
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index 86835611b84218..8c32f0218e761b 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -24,8 +24,8 @@ using namespace llvm;
namespace {
struct DocumentedOption {
- Record *Option;
- std::vector<Record*> Aliases;
+ const Record *Option;
+ std::vector<const Record *> Aliases;
};
struct DocumentedGroup;
struct Documentation {
@@ -37,7 +37,7 @@ struct Documentation {
}
};
struct DocumentedGroup : Documentation {
- Record *Group;
+ const Record *Group;
};
static bool hasFlag(const Record *Option, StringRef OptionFlag,
@@ -63,25 +63,25 @@ static bool isOptionVisible(const Record *Option, const Record *DocInfo) {
}
// Reorganize the records into a suitable form for emitting documentation.
-Documentation extractDocumentation(RecordKeeper &Records,
+Documentation extractDocumentation(const RecordKeeper &Records,
const Record *DocInfo) {
Documentation Result;
// Build the tree of groups. The root in the tree is the fake option group
// (Record*)nullptr, which contains all top-level groups and options.
- std::map<Record*, std::vector<Record*> > OptionsInGroup;
- std::map<Record*, std::vector<Record*> > GroupsInGroup;
- std::map<Record*, std::vector<Record*> > Aliases;
+ std::map<const Record *, std::vector<const Record *>> OptionsInGroup;
+ std::map<const Record *, std::vector<const Record *>> GroupsInGroup;
+ std::map<const Record *, std::vector<const Record *>> Aliases;
- std::map<std::string, Record*> OptionsByName;
- for (Record *R : Records.getAllDerivedDefinitions("Option"))
+ std::map<std::string, const Record *> OptionsByName;
+ for (const Record *R : Records.getAllDerivedDefinitions("Option"))
OptionsByName[std::string(R->getValueAsString("Name"))] = R;
- auto Flatten = [](Record *R) {
+ auto Flatten = [](const Record *R) {
return R->getValue("DocFlatten") && R->getValueAsBit("DocFlatten");
};
- auto SkipFlattened = [&](Record *R) -> Record* {
+ auto SkipFlattened = [&](const Record *R) -> const Record * {
while (R && Flatten(R)) {
auto *G = dyn_cast<DefInit>(R->getValueInit("Group"));
if (!G)
@@ -91,17 +91,17 @@ Documentation extractDocumentation(RecordKeeper &Records,
return R;
};
- for (Record *R : Records.getAllDerivedDefinitions("OptionGroup")) {
+ for (const Record *R : Records.getAllDerivedDefinitions("OptionGroup")) {
if (Flatten(R))
continue;
- Record *Group = nullptr;
+ const Record *Group = nullptr;
if (auto *G = dyn_cast<DefInit>(R->getValueInit("Group")))
Group = SkipFlattened(G->getDef());
GroupsInGroup[Group].push_back(R);
}
- for (Record *R : Records.getAllDerivedDefinitions("Option")) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Option")) {
if (auto *A = dyn_cast<DefInit>(R->getValueInit("Alias"))) {
Aliases[A->getDef()].push_back(R);
continue;
@@ -120,33 +120,33 @@ Documentation extractDocumentation(RecordKeeper &Records,
}
}
- Record *Group = nullptr;
+ const Record *Group = nullptr;
if (auto *G = dyn_cast<DefInit>(R->getValueInit("Group")))
Group = SkipFlattened(G->getDef());
OptionsInGroup[Group].push_back(R);
}
- auto CompareByName = [](Record *A, Record *B) {
+ auto CompareByName = [](const Record *A, const Record *B) {
return A->getValueAsString("Name") < B->getValueAsString("Name");
};
- auto CompareByLocation = [](Record *A, Record *B) {
+ auto CompareByLocation = [](const Record *A, const Record *B) {
return A->getLoc()[0].getPointer() < B->getLoc()[0].getPointer();
};
- auto DocumentationForOption = [&](Record *R) -> DocumentedOption {
+ auto DocumentationForOption = [&](const Record *R) -> DocumentedOption {
auto &A = Aliases[R];
llvm::sort(A, CompareByName);
return {R, std::move(A)};
};
- std::function<Documentation(Record *)> DocumentationForGroup =
- [&](Record *R) -> Documentation {
+ std::function<Documentation(const Record *)> DocumentationForGroup =
+ [&](const Record *R) -> Documentation {
Documentation D;
auto &Groups = GroupsInGroup[R];
llvm::sort(Groups, CompareByLocation);
- for (Record *G : Groups) {
+ for (const Record *G : Groups) {
D.Groups.emplace_back();
D.Groups.back().Group = G;
Documentation &Base = D.Groups.back();
@@ -157,7 +157,7 @@ Documentation extractDocumentation(RecordKeeper &Records,
auto &Options = OptionsInGroup[R];
llvm::sort(Options, CompareByName);
- for (Record *O : Options)
+ for (const Record *O : Options)
if (isOptionVisible(O, DocInfo))
D.Options.push_back(DocumentationForOption(O));
@@ -444,7 +444,7 @@ void emitDocumentation(int Depth, const Documentation &Doc,
} // namespace
-void clang::EmitClangOptDocs(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitClangOptDocs(const RecordKeeper &Records, raw_ostream &OS) {
const Record *DocInfo = Records.getDef("GlobalDocumentation");
if (!DocInfo) {
PrintFatalError("The GlobalDocumentation top-level definition is missing, "
diff --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
index 2a2e466ae19797..a997ef2b5d5ecc 100644
--- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -174,10 +174,11 @@ static void printOption(llvm::raw_ostream &OS, StringRef FullName,
OS << "true";
}
-void clang::EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
- std::vector<Record*> checkers = Records.getAllDerivedDefinitions("Checker");
- std::vector<Record*> packages = Records.getAllDerivedDefinitions("Package");
-
+void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
+ ArrayRef<const Record *> packages =
+ Records.getAllDerivedDefinitions("Package");
+ ArrayRef<const Record *> checkers =
+ Records.getAllDerivedDefinitions("Checker");
using SortedRecords = llvm::StringMap<const Record *>;
OS << "// This file is automatically generated. Do not edit this file by "
diff --git a/clang/utils/TableGen/ClangSyntaxEmitter.cpp b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
index 2a69e4c353b6b4..fdd9986731186a 100644
--- a/clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -41,10 +41,11 @@ using llvm::formatv;
// stable and useful way, where abstract Node subclasses correspond to ranges.
class Hierarchy {
public:
- Hierarchy(llvm::RecordKeeper &Records) {
- for (llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
+ Hierarchy(const llvm::RecordKeeper &Records) {
+ for (const llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
add(T);
- for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
+ for (const llvm::Record *Derived :
+ Records.getAllDerivedDefinitions("NodeType"))
if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
link(Derived, Base);
for (NodeType &N : AllTypes) {
@@ -127,7 +128,7 @@ struct SyntaxConstraint {
} // namespace
-void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
+void clang::EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);
@@ -186,7 +187,7 @@ static void printDoc(llvm::StringRef Doc, llvm::raw_ostream &OS) {
}
}
-void clang::EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
+void clang::EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);
diff --git a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
index 66bdf5e67602ba..41a2d0cd066fef 100644
--- a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
@@ -74,16 +74,15 @@ using namespace clang::tblgen;
namespace {
class TypeNodeEmitter {
- RecordKeeper &Records;
+ const RecordKeeper &Records;
raw_ostream &Out;
- const std::vector<Record*> Types;
+ ArrayRef<const Record *> Types;
std::vector<StringRef> MacrosToUndef;
public:
- TypeNodeEmitter(RecordKeeper &records, raw_ostream &out)
- : Records(records), Out(out),
- Types(Records.getAllDerivedDefinitions(TypeNodeClassName)) {
- }
+ TypeNodeEmitter(const RecordKeeper &records, raw_ostream &out)
+ : Records(records), Out(out),
+ Types(Records.getAllDerivedDefinitions(TypeNodeClassName)) {}
void emit();
@@ -203,6 +202,6 @@ void TypeNodeEmitter::emitUndefs() {
}
}
-void clang::EmitClangTypeNodes(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangTypeNodes(const RecordKeeper &records, raw_ostream &out) {
TypeNodeEmitter(records, out).emit();
}
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index bb4f091604f5e4..4b37471f08ffac 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -958,7 +958,7 @@ class ACLEIntrinsic {
";\n";
}
- ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param);
+ ACLEIntrinsic(EmitterBase &ME, const Record *R, const Type *Param);
};
// -----------------------------------------------------------------------------
@@ -1046,7 +1046,7 @@ class EmitterBase {
// Constructor and top-level functions.
- EmitterBase(RecordKeeper &Records);
+ EmitterBase(const RecordKeeper &Records);
virtual ~EmitterBase() = default;
virtual void EmitHeader(raw_ostream &OS) = 0;
@@ -1328,7 +1328,8 @@ Result::Ptr EmitterBase::getCodeForArg(unsigned ArgNum, const Type *ArgType,
return V;
}
-ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
+ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
+ const Type *Param)
: ReturnType(ME.getType(R->getValueAsDef("ret"), Param)) {
// Derive the intrinsic's full name, by taking the name of the
// Tablegen record (or override) and appending the suffix from its
@@ -1464,7 +1465,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
}
}
-EmitterBase::EmitterBase(RecordKeeper &Records) {
+EmitterBase::EmitterBase(const RecordKeeper &Records) {
// Construct the whole EmitterBase.
// First, look up all the instances of PrimitiveType. This gives us the list
@@ -1472,12 +1473,12 @@ EmitterBase::EmitterBase(RecordKeeper &Records) {
// collect all the useful ScalarType instances into a big list so that we can
// use it for operations such as 'find the unsigned version of this signed
// integer type'.
- for (Record *R : Records.getAllDerivedDefinitions("PrimitiveType"))
+ for (const Record *R : Records.getAllDerivedDefinitions("PrimitiveType"))
ScalarTypes[std::string(R->getName())] = std::make_unique<ScalarType>(R);
// Now go through the instances of Intrinsic, and for each one, iterate
// through its list of type parameters making an ACLEIntrinsic for each one.
- for (Record *R : Records.getAllDerivedDefinitions("Intrinsic")) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Intrinsic")) {
for (Record *RParam : R->getValueAsListOfDefs("params")) {
const Type *Param = getType(RParam, getVoidType());
auto Intrinsic = std::make_unique<ACLEIntrinsic>(*this, R, Param);
@@ -1752,7 +1753,7 @@ void EmitterBase::GroupSemaChecks(
class MveEmitter : public EmitterBase {
public:
- MveEmitter(RecordKeeper &Records) : EmitterBase(Records){};
+ MveEmitter(const RecordKeeper &Records) : EmitterBase(Records) {}
void EmitHeader(raw_ostream &OS) override;
void EmitBuiltinDef(raw_ostream &OS) override;
void EmitBuiltinSema(raw_ostream &OS) override;
@@ -2010,14 +2011,14 @@ class CdeEmitter : public EmitterBase {
std::map<StringRef, FunctionMacro> FunctionMacros;
public:
- CdeEmitter(RecordKeeper &Records);
+ CdeEmitter(const RecordKeeper &Records);
void EmitHeader(raw_ostream &OS) override;
void EmitBuiltinDef(raw_ostream &OS) override;
void EmitBuiltinSema(raw_ostream &OS) override;
};
-CdeEmitter::CdeEmitter(RecordKeeper &Records) : EmitterBase(Records) {
- for (Record *R : Records.getAllDerivedDefinitions("FunctionMacro"))
+CdeEmitter::CdeEmitter(const RecordKeeper &Records) : EmitterBase(Records) {
+ for (const Record *R : Records.getAllDerivedDefinitions("FunctionMacro"))
FunctionMacros.emplace(R->getName(), FunctionMacro(*R));
}
@@ -2179,45 +2180,45 @@ namespace clang {
// MVE
-void EmitMveHeader(RecordKeeper &Records, raw_ostream &OS) {
+void EmitMveHeader(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitHeader(OS);
}
-void EmitMveBuiltinDef(RecordKeeper &Records, raw_ostream &OS) {
+void EmitMveBuiltinDef(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinDef(OS);
}
-void EmitMveBuiltinSema(RecordKeeper &Records, raw_ostream &OS) {
+void EmitMveBuiltinSema(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinSema(OS);
}
-void EmitMveBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
+void EmitMveBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinCG(OS);
}
-void EmitMveBuiltinAliases(RecordKeeper &Records, raw_ostream &OS) {
+void EmitMveBuiltinAliases(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinAliases(OS);
}
// CDE
-void EmitCdeHeader(RecordKeeper &Records, raw_ostream &OS) {
+void EmitCdeHeader(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitHeader(OS);
}
-void EmitCdeBuiltinDef(RecordKeeper &Records, raw_ostream &OS) {
+void EmitCdeBuiltinDef(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinDef(OS);
}
-void EmitCdeBuiltinSema(RecordKeeper &Records, raw_ostream &OS) {
+void EmitCdeBuiltinSema(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinSema(OS);
}
-void EmitCdeBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
+void EmitCdeBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinCG(OS);
}
-void EmitCdeBuiltinAliases(RecordKeeper &Records, raw_ostream &OS) {
+void EmitCdeBuiltinAliases(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinAliases(OS);
}
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index e0d7b0db7f5780..351e1ea34dcb1d 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -59,7 +59,7 @@ namespace {
// While globals are generally bad, this one allows us to perform assertions
// liberally and somehow still trace them back to the def they indirectly
// came from.
-static Record *CurrentRecord = nullptr;
+static const Record *CurrentRecord = nullptr;
static void assert_with_loc(bool Assertion, const std::string &Str) {
if (!Assertion) {
if (CurrentRecord)
@@ -308,7 +308,7 @@ class Variable {
/// a particular typespec and prototype.
class Intrinsic {
/// The Record this intrinsic was created from.
- Record *R;
+ const Record *R;
/// The unmangled name.
std::string Name;
/// The input and output typespecs. InTS == OutTS except when
@@ -371,7 +371,7 @@ class Intrinsic {
}
public:
- Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
+ Intrinsic(const Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
StringRef ArchGuard, StringRef TargetGuard, bool IsUnavailable,
bool BigEndianSafe)
@@ -442,7 +442,7 @@ class Intrinsic {
}
/// Get the Record that this intrinsic is based off.
- Record *getRecord() const { return R; }
+ const Record *getRecord() const { return R; }
/// Get the set of Intrinsics that this intrinsic calls.
/// this is the set of immediate dependencies, NOT the
/// transitive closure.
@@ -576,12 +576,12 @@ class Intrinsic {
//===----------------------------------------------------------------------===//
class NeonEmitter {
- RecordKeeper &Records;
+ const RecordKeeper &Records;
DenseMap<Record *, ClassKind> ClassMap;
std::map<std::string, std::deque<Intrinsic>> IntrinsicMap;
unsigned UniqueNumber;
- void createIntrinsic(Record *R, SmallVectorImpl<Intrinsic *> &Out);
+ void createIntrinsic(const Record *R, SmallVectorImpl<Intrinsic *> &Out);
void genBuiltinsDef(raw_ostream &OS, SmallVectorImpl<Intrinsic *> &Defs);
void genStreamingSVECompatibleList(raw_ostream &OS,
SmallVectorImpl<Intrinsic *> &Defs);
@@ -601,7 +601,7 @@ class NeonEmitter {
/// Called by Intrinsic - returns a globally-unique number.
unsigned getUniqueNumber() { return UniqueNumber++; }
- NeonEmitter(RecordKeeper &R) : Records(R), UniqueNumber(0) {
+ NeonEmitter(const RecordKeeper &R) : Records(R), UniqueNumber(0) {
Record *SI = R.getClass("SInst");
Record *II = R.getClass("IInst");
Record *WI = R.getClass("WInst");
@@ -1979,7 +1979,7 @@ Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types,
return *GoodVec.front();
}
-void NeonEmitter::createIntrinsic(Record *R,
+void NeonEmitter::createIntrinsic(const Record *R,
SmallVectorImpl<Intrinsic *> &Out) {
std::string Name = std::string(R->getValueAsString("Name"));
std::string Proto = std::string(R->getValueAsString("Prototype"));
@@ -2240,10 +2240,8 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
/// 2. the SemaChecking code for the type overload checking.
/// 3. the SemaChecking code for validation of intrinsic immediate arguments.
void NeonEmitter::runHeader(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
-
SmallVector<Intrinsic *, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
// Generate shared BuiltinsXXX.def
@@ -2402,8 +2400,7 @@ void NeonEmitter::run(raw_ostream &OS) {
"__nodebug__))\n\n";
SmallVector<Intrinsic *, 128> Defs;
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
for (auto *I : Defs)
@@ -2510,8 +2507,7 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
"__nodebug__))\n\n";
SmallVector<Intrinsic *, 128> Defs;
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
for (auto *I : Defs)
@@ -2619,8 +2615,7 @@ void NeonEmitter::runBF16(raw_ostream &OS) {
"__nodebug__))\n\n";
SmallVector<Intrinsic *, 128> Defs;
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
for (auto *I : Defs)
@@ -2674,26 +2669,26 @@ void NeonEmitter::runBF16(raw_ostream &OS) {
OS << "#endif\n";
}
-void clang::EmitNeon(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitNeon(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).run(OS);
}
-void clang::EmitFP16(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitFP16(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runFP16(OS);
}
-void clang::EmitBF16(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitBF16(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runBF16(OS);
}
-void clang::EmitNeonSema(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitNeonSema(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runHeader(OS);
}
-void clang::EmitVectorTypes(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitVectorTypes(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runVectorTypes(OS);
}
-void clang::EmitNeonTest(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitNeonTest(const RecordKeeper &Records, raw_ostream &OS) {
llvm_unreachable("Neon test generation no longer implemented!");
}
diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp
index d05236bb4e909a..58e225e878bbbf 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -95,11 +95,11 @@ class SemaSignatureTable {
class RVVEmitter {
private:
- RecordKeeper &Records;
+ const RecordKeeper &Records;
RVVTypeCache TypeCache;
public:
- RVVEmitter(RecordKeeper &R) : Records(R) {}
+ RVVEmitter(const RecordKeeper &R) : Records(R) {}
/// Emit riscv_vector.h
void createHeader(raw_ostream &o);
@@ -554,8 +554,7 @@ void RVVEmitter::createCodeGen(raw_ostream &OS) {
void RVVEmitter::createRVVIntrinsics(
std::vector<std::unique_ptr<RVVIntrinsic>> &Out,
std::vector<SemaRecord> *SemaRecords) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("RVVBuiltin");
- for (auto *R : RV) {
+ for (const Record *R : Records.getAllDerivedDefinitions("RVVBuiltin")) {
StringRef Name = R->getValueAsString("Name");
StringRef SuffixProto = R->getValueAsString("Suffix");
StringRef OverloadedName = R->getValueAsString("OverloadedName");
@@ -752,12 +751,8 @@ void RVVEmitter::createRVVIntrinsics(
}
void RVVEmitter::printHeaderCode(raw_ostream &OS) {
- std::vector<Record *> RVVHeaders =
- Records.getAllDerivedDefinitions("RVVHeader");
- for (auto *R : RVVHeaders) {
- StringRef HeaderCodeStr = R->getValueAsString("HeaderCode");
- OS << HeaderCodeStr.str();
- }
+ for (const Record *R : Records.getAllDerivedDefinitions("RVVHeader"))
+ OS << R->getValueAsString("HeaderCode");
}
void RVVEmitter::createRVVIntrinsicRecords(std::vector<RVVIntrinsicRecord> &Out,
@@ -822,19 +817,19 @@ void RVVEmitter::createSema(raw_ostream &OS) {
}
namespace clang {
-void EmitRVVHeader(RecordKeeper &Records, raw_ostream &OS) {
+void EmitRVVHeader(const RecordKeeper &Records, raw_ostream &OS) {
RVVEmitter(Records).createHeader(OS);
}
-void EmitRVVBuiltins(RecordKeeper &Records, raw_ostream &OS) {
+void EmitRVVBuiltins(const RecordKeeper &Records, raw_ostream &OS) {
RVVEmitter(Records).createBuiltins(OS);
}
-void EmitRVVBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
+void EmitRVVBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
RVVEmitter(Records).createCodeGen(OS);
}
-void EmitRVVBuiltinSema(RecordKeeper &Records, raw_ostream &OS) {
+void EmitRVVBuiltinSema(const RecordKeeper &Records, raw_ostream &OS) {
RVVEmitter(Records).createSema(OS);
}
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index b2e2db1a409904..9e99b7f876dbcf 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -280,7 +280,7 @@ class SVEEmitter {
static const std::array<ReinterpretTypeInfo, 12> Reinterprets;
- RecordKeeper &Records;
+ const RecordKeeper &Records;
llvm::StringMap<uint64_t> EltTypes;
llvm::StringMap<uint64_t> MemEltTypes;
llvm::StringMap<uint64_t> FlagTypes;
@@ -288,16 +288,16 @@ class SVEEmitter {
llvm::StringMap<uint64_t> ImmCheckTypes;
public:
- SVEEmitter(RecordKeeper &R) : Records(R) {
- for (auto *RV : Records.getAllDerivedDefinitions("EltType"))
+ SVEEmitter(const RecordKeeper &R) : Records(R) {
+ for (const Record *RV : Records.getAllDerivedDefinitions("EltType"))
EltTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
- for (auto *RV : Records.getAllDerivedDefinitions("MemEltType"))
+ for (const Record *RV : Records.getAllDerivedDefinitions("MemEltType"))
MemEltTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
- for (auto *RV : Records.getAllDerivedDefinitions("FlagType"))
+ for (const Record *RV : Records.getAllDerivedDefinitions("FlagType"))
FlagTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
- for (auto *RV : Records.getAllDerivedDefinitions("MergeType"))
+ for (const Record *RV : Records.getAllDerivedDefinitions("MergeType"))
MergeTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
- for (auto *RV : Records.getAllDerivedDefinitions("ImmCheckType"))
+ for (const Record *RV : Records.getAllDerivedDefinitions("ImmCheckType"))
ImmCheckTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
}
@@ -397,7 +397,7 @@ class SVEEmitter {
void createBuiltinZAState(raw_ostream &OS);
/// Create intrinsic and add it to \p Out
- void createIntrinsic(Record *R,
+ void createIntrinsic(const Record *R,
SmallVectorImpl<std::unique_ptr<Intrinsic>> &Out);
};
@@ -1151,7 +1151,7 @@ uint64_t SVEEmitter::encodeTypeFlags(const SVEType &T) {
}
void SVEEmitter::createIntrinsic(
- Record *R, SmallVectorImpl<std::unique_ptr<Intrinsic>> &Out) {
+ const Record *R, SmallVectorImpl<std::unique_ptr<Intrinsic>> &Out) {
StringRef Name = R->getValueAsString("Name");
StringRef Proto = R->getValueAsString("Prototype");
StringRef Types = R->getValueAsString("Types");
@@ -1225,8 +1225,7 @@ void SVEEmitter::createCoreHeaderIntrinsics(raw_ostream &OS,
SVEEmitter &Emitter,
ACLEKind Kind) {
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
// Sort intrinsics in header file by following order/priority:
@@ -1427,9 +1426,8 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
}
void SVEEmitter::createBuiltins(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
// The mappings must be sorted based on BuiltinID.
@@ -1469,9 +1467,8 @@ void SVEEmitter::createBuiltins(raw_ostream &OS) {
}
void SVEEmitter::createCodeGenMap(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
// The mappings must be sorted based on BuiltinID.
@@ -1502,9 +1499,8 @@ void SVEEmitter::createCodeGenMap(raw_ostream &OS) {
}
void SVEEmitter::createRangeChecks(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
// The mappings must be sorted based on BuiltinID.
@@ -1634,9 +1630,8 @@ void SVEEmitter::createSMEHeader(raw_ostream &OS) {
}
void SVEEmitter::createSMEBuiltins(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst")) {
createIntrinsic(R, Defs);
}
@@ -1662,9 +1657,8 @@ void SVEEmitter::createSMEBuiltins(raw_ostream &OS) {
}
void SVEEmitter::createSMECodeGenMap(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst")) {
createIntrinsic(R, Defs);
}
@@ -1696,9 +1690,8 @@ void SVEEmitter::createSMECodeGenMap(raw_ostream &OS) {
}
void SVEEmitter::createSMERangeChecks(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV) {
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst")) {
createIntrinsic(R, Defs);
}
@@ -1733,9 +1726,8 @@ void SVEEmitter::createSMERangeChecks(raw_ostream &OS) {
}
void SVEEmitter::createBuiltinZAState(raw_ostream &OS) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
std::map<std::string, std::set<std::string>> IntrinsicsPerState;
@@ -1773,9 +1765,8 @@ void SVEEmitter::createBuiltinZAState(raw_ostream &OS) {
}
void SVEEmitter::createStreamingAttrs(raw_ostream &OS, ACLEKind Kind) {
- std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
- for (auto *R : RV)
+ for (const Record *R : Records.getAllDerivedDefinitions("Inst"))
createIntrinsic(R, Defs);
StringRef ExtensionKind;
@@ -1826,55 +1817,55 @@ void SVEEmitter::createStreamingAttrs(raw_ostream &OS, ACLEKind Kind) {
}
namespace clang {
-void EmitSveHeader(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveHeader(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createHeader(OS);
}
-void EmitSveBuiltins(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveBuiltins(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createBuiltins(OS);
}
-void EmitSveBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createCodeGenMap(OS);
}
-void EmitSveRangeChecks(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveRangeChecks(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createRangeChecks(OS);
}
-void EmitSveTypeFlags(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveTypeFlags(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createTypeFlags(OS);
}
-void EmitImmCheckTypes(RecordKeeper &Records, raw_ostream &OS) {
+void EmitImmCheckTypes(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createImmCheckTypes(OS);
}
-void EmitSveStreamingAttrs(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSveStreamingAttrs(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createStreamingAttrs(OS, ACLEKind::SVE);
}
-void EmitSmeHeader(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeHeader(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createSMEHeader(OS);
}
-void EmitSmeBuiltins(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeBuiltins(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createSMEBuiltins(OS);
}
-void EmitSmeBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createSMECodeGenMap(OS);
}
-void EmitSmeRangeChecks(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeRangeChecks(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createSMERangeChecks(OS);
}
-void EmitSmeStreamingAttrs(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeStreamingAttrs(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createStreamingAttrs(OS, ACLEKind::SME);
}
-void EmitSmeBuiltinZAState(RecordKeeper &Records, raw_ostream &OS) {
+void EmitSmeBuiltinZAState(const RecordKeeper &Records, raw_ostream &OS) {
SVEEmitter(Records).createBuiltinZAState(OS);
}
} // End namespace clang
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 3a424c9c91fe71..f7527ac535a870 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -24,7 +24,7 @@ class RecordKeeper;
namespace clang {
-void EmitClangDeclContext(llvm::RecordKeeper &RK, llvm::raw_ostream &OS);
+void EmitClangDeclContext(const llvm::RecordKeeper &RK, llvm::raw_ostream &OS);
/**
@param PriorizeIfSubclassOf These classes should be prioritized in the output.
This is useful to force enum generation/jump tables/lookup tables to be more
@@ -32,130 +32,159 @@ void EmitClangDeclContext(llvm::RecordKeeper &RK, llvm::raw_ostream &OS);
in Decl for classes that inherit from DeclContext, for functions like
castFromDeclContext.
*/
-void EmitClangASTNodes(llvm::RecordKeeper &RK, llvm::raw_ostream &OS,
+void EmitClangASTNodes(const llvm::RecordKeeper &RK, llvm::raw_ostream &OS,
const std::string &N, const std::string &S,
std::string_view PriorizeIfSubclassOf = "");
-void EmitClangBasicReader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangBasicWriter(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangTypeNodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangTypeReader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangTypeWriter(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrParserStringSwitches(llvm::RecordKeeper &Records,
+void EmitClangBasicReader(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangBasicWriter(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangTypeNodes(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangTypeReader(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangTypeWriter(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangAttrParserStringSwitches(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangAttrSubjectMatchRulesParserStringSwitches(
- llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrClass(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrSubjectMatchRuleList(llvm::RecordKeeper &Records,
+ const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangAttrClass(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangAttrImpl(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangAttrList(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangAttrSubjectMatchRuleList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrPCHRead(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrPCHWrite(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangRegularKeywordAttributeInfo(llvm::RecordKeeper &Records,
+void EmitClangAttrPCHRead(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangAttrPCHWrite(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangRegularKeywordAttributeInfo(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrHasAttrImpl(llvm::RecordKeeper &Records,
+void EmitClangAttrHasAttrImpl(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrSpellingListIndex(llvm::RecordKeeper &Records,
+void EmitClangAttrSpellingListIndex(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrASTVisitor(llvm::RecordKeeper &Records,
+void EmitClangAttrASTVisitor(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrTemplateInstantiate(llvm::RecordKeeper &Records,
+void EmitClangAttrTemplateInstantiate(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrParsedAttrList(llvm::RecordKeeper &Records,
+void EmitClangAttrParsedAttrList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper &Records,
+void EmitClangAttrParsedAttrImpl(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper &Records,
+void EmitClangAttrParsedAttrKinds(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrTextNodeDump(llvm::RecordKeeper &Records,
+void EmitClangAttrTextNodeDump(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrNodeTraverse(llvm::RecordKeeper &Records,
+void EmitClangAttrNodeTraverse(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangAttrDocTable(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangAttrDocTable(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
-void EmitClangBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangBuiltins(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
-void EmitClangDiagsDefs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS,
- const std::string &Component);
-void EmitClangDiagGroups(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangDiagsIndexName(llvm::RecordKeeper &Records,
+void EmitClangDiagsDefs(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS, const std::string &Component);
+void EmitClangDiagGroups(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangDiagsIndexName(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangSACheckers(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangSACheckers(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
-void EmitClangCommentHTMLTags(llvm::RecordKeeper &Records,
+void EmitClangCommentHTMLTags(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records,
+void EmitClangCommentHTMLTagsProperties(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records,
- llvm::raw_ostream &OS);
+void EmitClangCommentHTMLNamedCharacterReferences(
+ const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangCommentCommandInfo(llvm::RecordKeeper &Records,
+void EmitClangCommentCommandInfo(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentCommandList(llvm::RecordKeeper &Records,
+void EmitClangCommentCommandList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangOpcodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangOpcodes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
+void EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
+void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitBF16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitNeonSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitVectorTypes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitNeonTest(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitImmCheckTypes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveTypeFlags(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSveStreamingAttrs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitSmeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSmeBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSmeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSmeRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSmeStreamingAttrs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitSmeBuiltinZAState(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMveBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMveBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitCdeBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitCdeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitCdeBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitClangAttrDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangDiagDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangOptDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-
-void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
+void EmitNeon(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitFP16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitBF16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitNeonSema(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitVectorTypes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitNeonTest(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
+void EmitImmCheckTypes(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitSveHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveBuiltins(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveTypeFlags(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveRangeChecks(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitSveStreamingAttrs(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+
+void EmitSmeHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeBuiltins(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeRangeChecks(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitSmeStreamingAttrs(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitSmeBuiltinZAState(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+
+void EmitMveHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitMveBuiltinDef(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitMveBuiltinSema(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitMveBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitMveBuiltinAliases(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+
+void EmitRVVHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltins(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+
+void EmitCdeHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinDef(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitCdeBuiltinSema(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitCdeBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinAliases(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+
+void EmitClangAttrDocs(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangDiagDocs(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
+void EmitClangOptDocs(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
+void EmitClangOpenCLBuiltins(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangOpenCLBuiltinHeader(llvm::RecordKeeper &Records,
+void EmitClangOpenCLBuiltinHeader(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
+void EmitClangOpenCLBuiltinTests(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangDataCollectors(llvm::RecordKeeper &Records,
+void EmitClangDataCollectors(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitTestPragmaAttributeSupportedAttributes(llvm::RecordKeeper &Records,
- llvm::raw_ostream &OS);
+void EmitTestPragmaAttributeSupportedAttributes(
+ const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
} // end namespace clang
More information about the cfe-commits
mailing list