[clang] [clang][tablegen][NFC]add static for internal linkage function (PR #117479)
Congcong Cai via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 24 03:49:59 PST 2024
https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/117479
Detected by misc-use-internal-linkage
>From c3c37db297c2db4e8e4d8009e30819cdabf05df8 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Sun, 24 Nov 2024 19:42:51 +0800
Subject: [PATCH] [clang][tablegen][NFC]add static for internal linkage
function
Detected by misc-use-internal-linkage
---
clang/utils/TableGen/ClangASTNodesEmitter.cpp | 5 +++--
clang/utils/TableGen/ClangAttrEmitter.cpp | 22 +++++++++----------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 16749d11836246..5971b0012305d9 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -207,8 +207,9 @@ void clang::EmitClangASTNodes(const RecordKeeper &RK, raw_ostream &OS,
ClangASTNodesEmitter(RK, N, S, PriorizeIfSubclassOf).run(OS);
}
-void printDeclContext(const std::multimap<const Record *, const Record *> &Tree,
- const Record *DeclContext, raw_ostream &OS) {
+static 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 [II, E] = Tree.equal_range(DeclContext);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 4aa7594ffa6eb7..534bf2d01d7957 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1821,9 +1821,9 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
return Ret;
}
-void WriteSemanticSpellingSwitch(StringRef VarName,
- const SemanticSpellingMap &Map,
- raw_ostream &OS) {
+static void WriteSemanticSpellingSwitch(StringRef VarName,
+ const SemanticSpellingMap &Map,
+ raw_ostream &OS) {
OS << " switch (" << VarName << ") {\n default: "
<< "llvm_unreachable(\"Unknown spelling list index\");\n";
for (const auto &I : Map)
@@ -2367,12 +2367,12 @@ template <typename Fn> static void forEachSpelling(const Record &Attr, Fn &&F) {
}
}
-std::map<StringRef, std::vector<const Record *>> NameToAttrsMap;
+static std::map<StringRef, 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(const RecordKeeper &Records) {
+static void generateNameToAttrsMap(const RecordKeeper &Records) {
for (const auto *A : Records.getAllDerivedDefinitions("Attr")) {
for (const FlattenedSpelling &S : GetFlattenedSpellings(*A)) {
auto [It, Inserted] = NameToAttrsMap.try_emplace(S.name());
@@ -3965,9 +3965,9 @@ void EmitClangAttrASTVisitor(const RecordKeeper &Records, raw_ostream &OS) {
OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n";
}
-void EmitClangAttrTemplateInstantiateHelper(ArrayRef<const Record *> Attrs,
- raw_ostream &OS,
- bool AppliesToDecl) {
+static void
+EmitClangAttrTemplateInstantiateHelper(ArrayRef<const Record *> Attrs,
+ raw_ostream &OS, bool AppliesToDecl) {
OS << " switch (At->getKind()) {\n";
for (const auto *Attr : Attrs) {
@@ -4622,7 +4622,7 @@ static bool isParamExpr(const Record *Arg) {
.Default(false);
}
-void GenerateIsParamExpr(const Record &Attr, raw_ostream &OS) {
+static void GenerateIsParamExpr(const Record &Attr, raw_ostream &OS) {
OS << "bool isParamExpr(size_t N) const override {\n";
OS << " return ";
auto Args = Attr.getValueAsListOfDefs("Args");
@@ -4633,8 +4633,8 @@ void GenerateIsParamExpr(const Record &Attr, raw_ostream &OS) {
OS << "}\n\n";
}
-void GenerateHandleAttrWithDelayedArgs(const RecordKeeper &Records,
- raw_ostream &OS) {
+static 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";
More information about the cfe-commits
mailing list