[analyzer] MacOSKeychainAPIChecker: Retrieve the memory region which we are tracking even when it's no longer a SymbolicRegion, for example, when it is cast to char*.

llvm-svn: 138415
This commit is contained in:
Anna Zaks 2011-08-23 23:56:12 +00:00
parent bb167011e3
commit f9e9c4e9bc
1 changed files with 8 additions and 2 deletions

View File

@ -167,8 +167,14 @@ unsigned MacOSKeychainAPIChecker::getTrackedFunctionIndex(StringRef Name,
static SymbolRef getSymbolForRegion(CheckerContext &C,
const MemRegion *R) {
if (!isa<SymbolicRegion>(R))
if (!isa<SymbolicRegion>(R)) {
// Implicit casts (ex: void* -> char*) can turn Symbolic region into element
// region, if that is the case, get the underlining region.
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R))
R = ER->getAsArrayOffset().getRegion();
else
return 0;
}
return cast<SymbolicRegion>(R)->getSymbol();
}