[clang] 0989ce9 - [clang][analyzer][NFC] Move dyn_cast's into if statements for readability
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 09:22:50 PDT 2023
Author: Dmitri Gribenko
Date: 2023-05-30T18:22:43+02:00
New Revision: 0989ce947e3dd64f3e29e7c34f186c0a23c0323d
URL: https://github.com/llvm/llvm-project/commit/0989ce947e3dd64f3e29e7c34f186c0a23c0323d
DIFF: https://github.com/llvm/llvm-project/commit/0989ce947e3dd64f3e29e7c34f186c0a23c0323d.diff
LOG: [clang][analyzer][NFC] Move dyn_cast's into if statements for readability
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D151725
Added:
Modified:
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 0c126a632f74..bb45a879471a 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -712,21 +712,17 @@ std::string MemRegion::getDescriptiveName(bool UseQuotes) const {
}
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 {};
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list