[clang] [Clang] Introduce a trait to determine the structure binding size (PR #131515)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 18 08:47:47 PDT 2025


================
@@ -368,7 +368,11 @@ std::optional<SVal> SValBuilder::getConstantVal(const Expr *E) {
 
   case Stmt::TypeTraitExprClass: {
     const auto *TE = cast<TypeTraitExpr>(E);
-    return makeTruthVal(TE->getValue(), TE->getType());
+    if (TE->isStoredAsBoolean())
+      return makeTruthVal(TE->getBoolValue(), TE->getType());
+    if (TE->getType()->isIntegralOrEnumerationType())
+      return makeIntVal(TE->getAPValue().getInt());
+    return std::nullopt;
----------------
shafik wrote:

How could we end up here? Is this tested?

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


More information about the cfe-commits mailing list