diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp --- a/clang/lib/StaticAnalyzer/Core/SVals.cpp +++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp @@ -84,16 +84,12 @@ /// the first symbolic parent region is returned. SymbolRef SVal::getAsLocSymbol(bool IncludeBaseRegions) const { // FIXME: should we consider SymbolRef wrapped in CodeTextRegion? - if (Optional X = getAs()) - return X->getLoc().getAsLocSymbol(IncludeBaseRegions); - - if (Optional X = getAs()) { - const MemRegion *R = X->getRegion(); - if (const SymbolicRegion *SymR = IncludeBaseRegions ? - R->getSymbolicBase() : - dyn_cast(R->StripCasts())) + if (const MemRegion *R = getAsRegion()) + if (const SymbolicRegion *SymR = + IncludeBaseRegions ? R->getSymbolicBase() + : dyn_cast(R->StripCasts())) return SymR->getSymbol(); - } + return nullptr; }