[clang] 6fc0857 - [CIR] Add some missing NYIs for WeakRefAttr/AliasAttr (#194913)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 29 11:55:01 PDT 2026
Author: Erich Keane
Date: 2026-04-29T18:54:56Z
New Revision: 6fc085725ac8c427193340084e8b7ff17898e4ba
URL: https://github.com/llvm/llvm-project/commit/6fc085725ac8c427193340084e8b7ff17898e4ba
DIFF: https://github.com/llvm/llvm-project/commit/6fc085725ac8c427193340084e8b7ff17898e4ba.diff
LOG: [CIR] Add some missing NYIs for WeakRefAttr/AliasAttr (#194913)
I found these while poking through something else, we should make sure
these don't get lost, particularly as alias has some significant
functionality.
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenExpr.cpp
clang/lib/CIR/CodeGen/CIRGenModule.cpp
clang/lib/Sema/SemaOpenACC.cpp
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 26ced070de8ba..ef1aacb9779f0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -989,6 +989,16 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) {
}
}
+ // FIXME: We should be able to assert this for FunctionDecls as well!
+ // FIXME: We should be able to assert this for all DeclRefExprs, not just
+ // those with a valid source location.
+ assert((nd->isUsed(false) || !isa<VarDecl>(nd) || e->isNonOdrUse() ||
+ !e->getLocation().isValid()) &&
+ "Should not use decl without marking it used!");
+
+ if (nd->hasAttr<WeakRefAttr>())
+ cgm.errorNYI(nd->getSourceRange(), "emitGlobal: WeakRefAttr");
+
if (const auto *vd = dyn_cast<VarDecl>(nd)) {
// Checks for omitted feature handling
assert(!cir::MissingFeatures::opAllocaStaticLocal());
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 354fae59b3807..26958cd5d39a8 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -464,6 +464,12 @@ void CIRGenModule::emitGlobal(clang::GlobalDecl gd) {
const auto *global = cast<ValueDecl>(gd.getDecl());
+ if (global->hasAttr<WeakRefAttr>())
+ errorNYI(global->getSourceRange(), "emitGlobal: WeakRefAttr");
+
+ if (global->hasAttr<AliasAttr>())
+ errorNYI(global->getSourceRange(), "emitGlobal: AliasAttr");
+
// If this is CUDA, be selective about which declarations we emit.
// Non-constexpr non-lambda implicit host device functions are not emitted
// unless they are used on device side.
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 15a8b293ac245..a228d224e2308 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -2748,8 +2748,10 @@ Expr *GenerateReductionInitRecipeExpr(ASTContext &Context,
VarDecl *CreateAllocaDecl(ASTContext &Ctx, DeclContext *DC,
SourceLocation BeginLoc, IdentifierInfo *VarName,
QualType VarTy) {
- return VarDecl::Create(Ctx, DC, BeginLoc, BeginLoc, VarName, VarTy,
- Ctx.getTrivialTypeSourceInfo(VarTy), SC_Auto);
+ auto *VD = VarDecl::Create(Ctx, DC, BeginLoc, BeginLoc, VarName, VarTy,
+ Ctx.getTrivialTypeSourceInfo(VarTy), SC_Auto);
+ VD->markUsed(Ctx);
+ return VD;
}
ExprResult FinishValueInit(Sema &S, InitializedEntity &Entity,
More information about the cfe-commits
mailing list