[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 11 07:56:10 PST 2022


steakhal added a comment.

I think we could settle on something like this:

     APSIntType getAPSIntType(QualType T) const {
  +    if (T->isFixedPointType())
  +      return APSIntType(Ctx.getIntWidth(T), T->isUnsignedFixedPointType());
  +
       // For the purposes of the analysis and constraints, we treat atomics
       // as their underlying types.
       if (const AtomicType *AT = T->getAs<AtomicType>()) {
         T = AT->getValueType();
       }
   
       assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T));
       return APSIntType(Ctx.getIntWidth(T),
  -                      !T->isSignedIntegerOrEnumerationType());
  +                      T->isUnsignedIntegerOrEnumerationType());
     }

Your original test should be enough.
In a follow-up patch, you could extend the cases and maybe uncover more crashes.
I wouldn't want to block you. It's good enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759



More information about the cfe-commits mailing list