================
@@ -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,
----------------
AaronBallman wrote:

Making sure we're all on the same page, I think the diagnostic should show up 
like:
```
extern void free(void *);
extern void *malloc(size_t size);
void t8(void) {
  void *p
  __attribute__((
          cleanup(
                  free // expected-warning{{attempt to call free on non-heap 
object 'p'}}
          )
        ))
  = malloc(10);
```
and
```
struct __attribute__((aligned(8))) S {};

void derp(struct S *ptr);

int main(void) {
  typedef __attribute__((aligned(4))) struct S TypedefAligned4;
  TypedefAligned4 s1;
  derp(&s1); // expected-warning {{passing 4-byte aligned argument to 8-byte 
aligned parameter 1 of 'derp' may result in an unaligned pointer access}}

  __attribute__((cleanup(derp))) // expected-warning {{passing 4-byte aligned 
argument to 8-byte aligned parameter 1 of 'derp' may result in an unaligned 
pointer access}}
  TypedefAligned4 s2;
}
```

https://github.com/llvm/llvm-project/pull/80040
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to