From: Denys Petrov Date: Mon, 26 Oct 2020 14:59:54 +0000 (+0200) Subject: [analyzer] [NFC] Simplify SVal::getAsLocSymbol function using existing functions X-Git-Tag: llvmorg-13-init~8169 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32efb81ea60a9e99571923bf9308598f6cd341f2;p=platform%2Fupstream%2Fllvm.git [analyzer] [NFC] Simplify SVal::getAsLocSymbol function using existing functions Summary: Method of obtaining MemRegion from LocAsInteger/MemRegionVal already exists in SVal::getAsRegion function. Replace repetitive conditions in SVal::getAsLocSymbol with SVal::getAsRegion function. Differential Revision: https://reviews.llvm.org/D89982 --- diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp index c4d5377..25259688 100644 --- a/clang/lib/StaticAnalyzer/Core/SVals.cpp +++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp @@ -84,16 +84,12 @@ const FunctionDecl *SVal::getAsFunctionDecl() const { /// 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; }