[PATCH] D151725: [clang] Move dyn_cast's into if statements for readability
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 08:43:08 PDT 2023
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151725
Files:
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -712,21 +712,17 @@
}
SourceRange MemRegion::sourceRange() const {
- const auto *const VR = dyn_cast<VarRegion>(this->getBaseRegion());
- const auto *const FR = dyn_cast<FieldRegion>(this);
-
// Check for more specific regions first.
- // FieldRegion
- if (FR) {
+ if (auto *FR = dyn_cast<FieldRegion>(this)) {
return FR->getDecl()->getSourceRange();
}
- // VarRegion
- else if (VR) {
+
+ if (auto *VR = dyn_cast<VarRegion>(this->getBaseRegion())) {
return VR->getDecl()->getSourceRange();
}
+
// Return invalid source range (can be checked by client).
- else
- return {};
+ return {};
}
//===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151725.526649.patch
Type: text/x-patch
Size: 929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230530/69f07fcc/attachment.bin>
More information about the cfe-commits
mailing list