[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 13:13:38 PST 2020


aaron.ballman added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2524
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && Ty->getPointeeType().isVolatileQualified())
     return;
----------------
lebedev.ri wrote:
> vsk wrote:
> > Is the pointee type associated with a PointerType QualType ever supposed to be null? I wonder why this happens, and whether it can cause problems in other places.
> Basically, we can't just use `getPointeeType()` here, but i'm not sure what should be used instead.
I'm not super familiar with `__builtin_assume_aligned` but from the GCC docs, it looks like the code from the test case is valid code (so we don't need to add semantic checking that would ensure we don't reach this code path). However, it seems a bit odd to me that we'd get an array type here as opposed to a decayed type which would actually be a pointer.

I think the issue is further up the call chain, perhaps. `EmitBuiltinExpr()` gets the argument expression and passes it to `emitAlignmentAssumption()` which pulls the type directly out of the expression. It seems like there's an lvalue to rvalue conversion step missing to adjust the type.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92001/new/

https://reviews.llvm.org/D92001



More information about the cfe-commits mailing list