aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
diff options
context:
space:
mode:
authormartinboehme <mboehme@google.com>2024-01-16 15:48:44 +0100
committerGitHub <noreply@github.com>2024-01-16 15:48:44 +0100
commit23bfc271a316345459809427d98e942455d0e2b6 (patch)
tree233dbb20746d40377632fdfc865ad3d231fa08b1 /clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
parent19cab7ef2e14d6e6b174019b6fd1549b476e1907 (diff)
downloadllvm-23bfc271a316345459809427d98e942455d0e2b6.zip
llvm-23bfc271a316345459809427d98e942455d0e2b6.tar.gz
llvm-23bfc271a316345459809427d98e942455d0e2b6.tar.bz2
[clang][dataflow] Use `ignoreCFGOmittedNodes()` in `setValue()`. (#78245)
This is to be consistent with `getValue()`, which also uses `ignoreCFGOmittedNodes()`. Before this fix, it was not possible to retrieve a `Value` from a "CFG omitted" node that had previously been set using `setValue()`; see the accompanying test, which fails without the fix. I discovered this issue while running internal integration tests on https://github.com/llvm/llvm-project/pull/78127.
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp')
-rw-r--r--clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index a50ee57..57572e5 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -803,13 +803,15 @@ void Environment::setValue(const StorageLocation &Loc, Value &Val) {
}
void Environment::setValue(const Expr &E, Value &Val) {
+ const Expr &CanonE = ignoreCFGOmittedNodes(E);
+
if (auto *RecordVal = dyn_cast<RecordValue>(&Val)) {
- assert(isOriginalRecordConstructor(E) ||
- &RecordVal->getLoc() == &getResultObjectLocation(E));
+ assert(isOriginalRecordConstructor(CanonE) ||
+ &RecordVal->getLoc() == &getResultObjectLocation(CanonE));
}
- assert(E.isPRValue());
- ExprToVal[&E] = &Val;
+ assert(CanonE.isPRValue());
+ ExprToVal[&CanonE] = &Val;
}
Value *Environment::getValue(const StorageLocation &Loc) const {