[PATCH] D140059: [APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Peter Rong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 7 12:22:43 PST 2023


Peter marked an inline comment as done.
Peter added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:5386
+      if (InitInt)
+        InitExpr = DBuilder.createConstantValueExpression(InitInt.value());
+    } else if (Init.isFloat())
----------------
efriedma wrote:
> I think we actually want the existing behavior here.  Values embedded in debug info aren't really signed or unsigned; they're interpreted by the debugger based on the type of the value.
> 
> Maybe it makes sense to add a new APSInt API for that?  Or I guess we could explicitly write out `Init.getInt().isSigned() ? Init.getInt().getSExtValue() : Init.getInt().getZExtValue();` if we can't think of a reasonable name for the new API...
I have no problem with this proposed new API, we may even name it `uint64_t tryInt64Representaiton`. My main concern is that returning a value whose static type is unsigned while semantics can be signed OR unsigned is a bit inconsist.

I will use something like `Init.getInt().isSigned() ? Init.getInt().getSExtValue() : Init.getInt().getZExtValue();` for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140059



More information about the cfe-commits mailing list