[clang] [analyzer] Fix StdVariantChecker crash on std::get with a non-ptr arg (PR #210167)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 03:01:32 PDT 2026


================
@@ -222,12 +222,7 @@ class StdVariantChecker : public Checker<eval::Call, check::RegionChanges> {
   bool handleStdGetCall(const CallEvent &Call, CheckerContext &C) const {
     ProgramStateRef State = C.getState();
 
-    SVal ArgSVal = Call.getArgSVal(0);
-    if (ArgSVal.isUnknown())
-      return false;
-
-    const auto &ArgType =
-        ArgSVal.getType(C.getASTContext())->getPointeeType().getTypePtr();
+    const auto *ArgType = Call.getArgExpr(0)->getType().getTypePtr();
----------------
steakhal wrote:

This line changes the semantics of how we check the type.
Previously, `ArgType` referred to the type of the pointee.
After this change, it refers to the argument type directly - not to the derferenced (pointee) type.
Or is it because the ArgSVal was a MemRegion, thus it had an implicit pointee in its type? - I suspect this is the only explanation why the code change didn't break any of the tests.

If this would be the case, then this construct is strictly better than what it was - I like it.

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


More information about the cfe-commits mailing list