[analyzer] MacOSKeychainAPIChecker: Simplify getSymbolForRegion by using existing API. Thanks Jordy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138765 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
index 76d9287..c2b5476 100644
--- a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -198,14 +198,10 @@
 
 static SymbolRef getSymbolForRegion(CheckerContext &C,
                                    const MemRegion *R) {
+  // Implicit casts (ex: void* -> char*) can turn Symbolic region into element
+  // region, if that is the case, get the underlining region.
+  R = R->StripCasts();
   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();
-      if (!R || !isa<SymbolicRegion>(R))
-        return 0;
-    } else
       return 0;
   }
   return cast<SymbolicRegion>(R)->getSymbol();