Fix regression when invalidating reference-counts for objects passed-by-reference to a function/method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61224 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index c85d934..90a54d6 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1589,14 +1589,6 @@
// to identify conjured symbols by an expression pair: the enclosing
// expression (the context) and the expression itself. This should
// disambiguate conjured symbols.
-
- // Is the invalidated variable something that we were tracking?
- SVal X = state.GetSVal(*MR);
-
- if (isa<loc::SymbolVal>(X)) {
- SymbolRef Sym = cast<loc::SymbolVal>(X).getSymbol();
- state = state.remove<RefBindings>(Sym);
- }
const TypedRegion* R = dyn_cast<TypedRegion>(MR->getRegion());
@@ -1608,6 +1600,15 @@
}
if (R) {
+
+ // Is the invalidated variable something that we were tracking?
+ SVal X = state.GetSVal(Loc::MakeVal(R));
+
+ if (isa<loc::SymbolVal>(X)) {
+ SymbolRef Sym = cast<loc::SymbolVal>(X).getSymbol();
+ state = state.remove<RefBindings>(Sym);
+ }
+
// Set the value of the variable to be a conjured symbol.
unsigned Count = Builder.getCurrentBlockCount();
QualType T = R->getRValueType(Ctx);