Skip to content

Commit 4f68d20

Browse files
committed
[clang][Interp][NFC] Simplify Pointer Block accessing code
Try to get PointeeStorage.BS.Pointee only once and reuse that.
1 parent 8011a23 commit 4f68d20

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/lib/AST/Interp/Pointer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ Pointer::~Pointer() {
5757
if (isIntegralPointer())
5858
return;
5959

60-
if (PointeeStorage.BS.Pointee) {
61-
PointeeStorage.BS.Pointee->removePointer(this);
62-
PointeeStorage.BS.Pointee->cleanup();
60+
if (Block *Pointee = PointeeStorage.BS.Pointee) {
61+
Pointee->removePointer(this);
62+
Pointee->cleanup();
6363
}
6464
}
6565

@@ -188,6 +188,7 @@ APValue Pointer::toAPValue() const {
188188
void Pointer::print(llvm::raw_ostream &OS) const {
189189
OS << PointeeStorage.BS.Pointee << " (";
190190
if (isBlockPointer()) {
191+
const Block *B = PointeeStorage.BS.Pointee;
191192
OS << "Block) {";
192193

193194
if (isRoot())
@@ -200,8 +201,8 @@ void Pointer::print(llvm::raw_ostream &OS) const {
200201
else
201202
OS << Offset << ", ";
202203

203-
if (PointeeStorage.BS.Pointee)
204-
OS << PointeeStorage.BS.Pointee->getSize();
204+
if (B)
205+
OS << B->getSize();
205206
else
206207
OS << "nullptr";
207208
} else {

0 commit comments

Comments
 (0)