[all-commits] [llvm/llvm-project] 4affb2: [analyzer] Use dynamic type when invalidating by a...

Balazs Benics via All-commits all-commits at lists.llvm.org
Thu Oct 24 04:22:41 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4affb2d59a541d8163404d7e21252b4686f1c3b8
      https://github.com/llvm/llvm-project/commit/4affb2d59a541d8163404d7e21252b4686f1c3b8
  Author: Balazs Benics <benicsbalazs at gmail.com>
  Date:   2024-10-24 (Thu, 24 Oct 2024)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
    M clang/lib/StaticAnalyzer/Core/CallEvent.cpp
    M clang/test/Analysis/const-method-call.cpp

  Log Message:
  -----------
  [analyzer] Use dynamic type when invalidating by a member function call (#111138)

When instantiating "callable<T>", the "class CallableType" nested type
will only have a declaration in the copy for the instantiation - because
it's not refereed to directly by any other code that would need a
complete definition.

However, in the past, when conservative eval calling member function, we
took the static type of the "this" expr, and looked up the CXXRecordDecl
it refereed to to see if it has any mutable members (to decide if it
needs to refine invalidation or not). Unfortunately, that query needs a
definition, and it asserts otherwise, thus we crashed.

To fix this, we should consult the dynamic type of the object, because
that will have the definition.
I anyways added a check for "hasDefinition" just to be on the safe side.

Fixes #77378



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list