[clang] c2a4cb4 - [CIR] Delete the unused cir::VisibilityAttr (#220881)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 4 06:11:29 PDT 2026
Author: Henrich Lauko
Date: 2026-09-04T15:11:22+02:00
New Revision: c2a4cb4e68ca5e1d4ba9f7ce3bd31f54c25da828
URL: https://github.com/llvm/llvm-project/commit/c2a4cb4e68ca5e1d4ba9f7ce3bd31f54c25da828
DIFF: https://github.com/llvm/llvm-project/commit/c2a4cb4e68ca5e1d4ba9f7ce3bd31f54c25da828.diff
LOG: [CIR] Delete the unused cir::VisibilityAttr (#220881)
This removes CIR_VisibilityAttr that had no users. `cir.global` and
`cir.func` carry visibility
as `EnumProp<CIR_VisibilityKind>`, a property rather than an attribute,
so
nothing ever built or printed the attribute.
Its only consumer was CIRGenModule::getGlobalVisibilityAttrFromDecl,
itself
never called, and that was the only caller of
getGlobalVisibilityKindFromClangVisibility, so all three go together.
Added:
Modified:
clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
clang/lib/CIR/CodeGen/CIRGenModule.cpp
clang/lib/CIR/CodeGen/CIRGenModule.h
Removed:
################################################################################
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 6a82b5d4b04d1..fa90ceba97115 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -1347,7 +1347,7 @@ def CIR_ConstComplexAttr : CIR_ValueLikeAttr<"ConstComplex", "const_complex"> {
}
//===----------------------------------------------------------------------===//
-// VisibilityAttr
+// VisibilityKind
//===----------------------------------------------------------------------===//
def CIR_VisibilityKind : CIR_I32EnumAttr<"VisibilityKind", "C/C++ visibility", [
@@ -1358,33 +1358,6 @@ def CIR_VisibilityKind : CIR_I32EnumAttr<"VisibilityKind", "C/C++ visibility", [
let genSpecializedAttr = 0;
}
-def CIR_VisibilityAttr : CIR_EnumAttr<CIR_VisibilityKind, "visibility"> {
- let summary = "Visibility attribute";
- let description = [{
- Visibility attributes.
- }];
-
- let cppClassName = "VisibilityAttr";
-
- let skipDefaultBuilders = 1;
- let builders = [
- AttrBuilder<(ins CArg<"VisibilityKind",
- "cir::VisibilityKind::Default">:$value), [{
- return $_get($_ctxt, value);
- }]>
- ];
-
- let assemblyFormat = [{
- $value
- }];
-
- let extraClassDeclaration = [{
- bool isDefault() const { return getValue() == VisibilityKind::Default; };
- bool isHidden() const { return getValue() == VisibilityKind::Hidden; };
- bool isProtected() const { return getValue() == VisibilityKind::Protected; };
- }];
-}
-
//===----------------------------------------------------------------------===//
// GloblCtorAttr
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index b70f4c0c0b043..17ed048ecbd2f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -3862,32 +3862,6 @@ CIRGenModule::getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind glk) {
llvm_unreachable("linkage should be handled above!");
}
-cir::VisibilityKind CIRGenModule::getGlobalVisibilityKindFromClangVisibility(
- clang::VisibilityAttr::VisibilityType visibility) {
- switch (visibility) {
- case clang::VisibilityAttr::VisibilityType::Default:
- return cir::VisibilityKind::Default;
- case clang::VisibilityAttr::VisibilityType::Hidden:
- return cir::VisibilityKind::Hidden;
- case clang::VisibilityAttr::VisibilityType::Protected:
- return cir::VisibilityKind::Protected;
- }
- llvm_unreachable("unexpected visibility value");
-}
-
-cir::VisibilityAttr
-CIRGenModule::getGlobalVisibilityAttrFromDecl(const Decl *decl) {
- const clang::VisibilityAttr *va = decl->getAttr<clang::VisibilityAttr>();
- cir::VisibilityAttr cirVisibility =
- cir::VisibilityAttr::get(&getMLIRContext());
- if (va) {
- cirVisibility = cir::VisibilityAttr::get(
- &getMLIRContext(),
- getGlobalVisibilityKindFromClangVisibility(va->getVisibility()));
- }
- return cirVisibility;
-}
-
void CIRGenModule::release() {
emitDeferred();
emitVTablesOpportunistically();
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h
index cf82906d6e6c0..5646db9503dc6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.h
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.h
@@ -877,9 +877,6 @@ class CIRGenModule : public CIRGenTypeCache {
static mlir::SymbolTable::Visibility
getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK);
- static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility(
- clang::VisibilityAttr::VisibilityType visibility);
- cir::VisibilityAttr getGlobalVisibilityAttrFromDecl(const Decl *decl);
cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd);
static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op);
cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
More information about the cfe-commits
mailing list