[PATCH] D89982: [analyzer] [NFC] Simplify SVal::getAsLocSymbol function using existing functions
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 22 13:04:03 PDT 2020
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: krememek, vsavchenko, NoQ, martong, steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Method of obtaining `MemRegion` from `LocAsInteger/MemRegionVal` already exists in `SVal::getAsRegion` function. Replace repetitive conditions in `SVal::getAsLocSymbol` with `SVal::getAsRegion` function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89982
Files:
clang/lib/StaticAnalyzer/Core/SVals.cpp
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ 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<nonloc::LocAsInteger> X = getAs<nonloc::LocAsInteger>())
- return X->getLoc().getAsLocSymbol(IncludeBaseRegions);
-
- if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
- const MemRegion *R = X->getRegion();
- if (const SymbolicRegion *SymR = IncludeBaseRegions ?
- R->getSymbolicBase() :
- dyn_cast<SymbolicRegion>(R->StripCasts()))
+ if (const MemRegion *R = getAsRegion())
+ if (const SymbolicRegion *SymR =
+ IncludeBaseRegions ? R->getSymbolicBase()
+ : dyn_cast<SymbolicRegion>(R->StripCasts()))
return SymR->getSymbol();
- }
+
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89982.300087.patch
Type: text/x-patch
Size: 1134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201022/ce8dff63/attachment-0001.bin>
More information about the cfe-commits
mailing list