[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 31 06:02:55 PDT 2020
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, vsavchenko, Eugene.Zelenko, krememek, steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, dexonsmith, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
`BaseMask` occupies the lowest bits. Effect of applying the mask is neutralized by right shift operation, thus making it useless.
Also change mask init value from //hex// to //bin// since it's more natural for mask.
Fix: Remove a redundant bitwise operation.
P.S. It hurts my eyes everytime I see it. I gave up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85026
Files:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@
#define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
};
- enum { BaseBits = 2, BaseMask = 0x3 };
+ enum { BaseBits = 2, BaseMask = 0b11 };
protected:
const void *Data = nullptr;
@@ -116,7 +116,7 @@
unsigned getRawKind() const { return Kind; }
BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
- unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+ unsigned getSubKind() const { return Kind >> BaseBits; }
// This method is required for using SVal in a FoldingSetNode. It
// extracts a unique signature for this SVal object.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85026.282206.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200731/117bb7fd/attachment.bin>
More information about the cfe-commits
mailing list