[clang] [analyzer] Model concrete floating-point values (PR #214098)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 21 10:01:28 PDT 2026


================
@@ -121,6 +124,26 @@ APSIntPtr BasicValueFactory::getValue(uint64_t X, QualType T) {
   return getValue(getAPSIntType(T).getValue(X));
 }
 
+APFloatPtr BasicValueFactory::getFloatValue(const llvm::APFloat &X) {
+  llvm::FoldingSetNodeID ID;
+  void *InsertPos;
+
+  using FoldNodeTy = llvm::FoldingSetNodeWrapper<llvm::APFloat>;
+
+  // ID must be unique to differentiate between nodes. Unlike integers, bit
+  // size and pattern are not sufficient, so add semantics to the ID as well.
+  ID.AddInteger(llvm::APFloat::SemanticsToEnum(X.getSemantics()));
+  X.Profile(ID);
----------------
steakhal wrote:

What is interesting here is that `APFloat::Profile`calls `bitcastToAPInt`, which asserts that `Semantics == &APFloatBase::semPPCDoubleDouble` - so this semantic is pretty constant.

I'm really surprised that it wouldn't be part of its `Profile`. If it carries any meaningful value, it should be part of its `Profile`.

https://github.com/llvm/llvm-project/pull/214098


More information about the cfe-commits mailing list