[cfe-commits] [Review] [ubsan] Fix type reported in compound assignment operations

Richard Smith richard at metafoo.co.uk
Sun Dec 30 00:48:39 PST 2012


-      StaticData.push_back(CGF.EmitCheckTypeDescriptor(Info.E->getType()));
+      QualType ResTy = Info.E->getType();
+      if (const CompoundAssignOperator *C =
+            dyn_cast<CompoundAssignOperator>(Info.E))
+        ResTy = C->getComputationResultType();
+      StaticData.push_back(CGF.EmitCheckTypeDescriptor(ResTy));

Could you just use Info.Ty here?

Please add a test for Clang's test suite too. The tests in compiler-rt
are intended to test compiler-rt itself (the formatting of the
diagnostics, etc), not for testing that Clang produces correct data
blocks (in particular, we should have sufficient coverage that we can
refactor Clang's IRGen without running the compiler-rt tests).

On Sun, Dec 30, 2012 at 12:13 AM, Will Dietz <wdietz2 at uiuc.edu> wrote:
> See attached patches, thanks!
>
> Description:
>
> When checking "a += b" we were using the type of 'a' in the
> diagnostic, instead of the type of the overflowing expression "a+b".
> This was particularly problematic when 'a' was signed and 'b' was
> unsigned.
>
> Okay to commit?
>
> ~Will
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list