[all-commits] [llvm/llvm-project] 9b2ec8: [analyzer] Avoid creating LazyCompoundVal when pos...
Balazs Benics via All-commits
all-commits at lists.llvm.org
Fri Nov 29 00:19:54 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9b2ec87f5bce57cc900cf52a99f805d999716053
https://github.com/llvm/llvm-project/commit/9b2ec87f5bce57cc900cf52a99f805d999716053
Author: Balazs Benics <benicsbalazs at gmail.com>
Date: 2024-11-29 (Fri, 29 Nov 2024)
Changed paths:
M clang/lib/StaticAnalyzer/Core/RegionStore.cpp
M clang/test/Analysis/ctor-trivial-copy.cpp
M clang/test/Analysis/explain-svals.cpp
M clang/test/Analysis/iterator-modeling.cpp
M clang/test/Analysis/stl-algorithm-modeling-aggressive-std-find-modeling.cpp
M clang/test/Analysis/stl-algorithm-modeling.cpp
M clang/test/Analysis/template-param-objects.cpp
Log Message:
-----------
[analyzer] Avoid creating LazyCompoundVal when possible (#116840)
In #115916 I allowed copying empty structs.
Later in #115917 I changed how objects are copied, and basically when we
would want to copy a struct (an LCV) of a single symbol (likely coming
from an opaque fncall or invalidation), just directly bind that symbol
instead of creating an LCV referring to the symbol. This was an
optimization to skip a layer of indirection.
Now, it turns out I should have apply the same logic in #115916. I
should not have just blindly created an LCV by calling
`createLazyBinding()`, but rather check if I can apply the shortcut
described in #115917 and only create the LCV if the shortcut doesn't
apply.
In this patch I check if there is a single default binding that the copy
would refer to and if so, just return that symbol instead of creating an
LCV.
There shouldn't be any observable changes besides that we should have
fewer LCVs. This change may surface bugs in checkers that were
associating some metadata with entities in a wrong way. Notably,
STLAlgorithmModeling and DebugIteratorModeling checkers would likely
stop working after this change.
I didn't investigate them deeply because they were broken even prior to
this patch. Let me know if I should migrate these checkers to be just as
bugged as they were prior to this patch - thus make the tests pass.
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