[clang] Diagnose misuse of the cleanup attribute (PR #80040)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 06:33:43 PST 2024
================
@@ -3780,6 +3780,30 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
<< NI.getName() << ParamTy << Ty;
return;
}
+ VarDecl *VD = cast<VarDecl>(D);
+ // Create a reference to the variable declaration. This is a fake/dummy
+ // reference.
+ DeclRefExpr *VariableReference = DeclRefExpr::Create(
+ S.Context, NestedNameSpecifierLoc{}, SourceLocation{Loc}, VD, false,
+ DeclarationNameInfo{VD->getDeclName(), VD->getLocation()}, VD->getType(),
+ VK_LValue);
+
+ // Create a unary operator expression that represents taking the address of
+ // the variable. This is a fake/dummy expression.
+ Expr *AddressOfVariable = UnaryOperator::Create(
+ S.Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
+ S.Context.getPointerType(VD->getType()), VK_PRValue, OK_Ordinary,
+ SourceLocation{Loc}, false, FPOptionsOverride{});
----------------
erichkeane wrote:
```suggestion
Loc, false, FPOptionsOverride{});
```
https://github.com/llvm/llvm-project/pull/80040
More information about the cfe-commits
mailing list