[clang] 5877949 - [clang][AST][NFC] Make FieldDecl in SubobjectAdjustment const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 01:36:39 PST 2024
Author: Timm Bäder
Date: 2024-01-30T10:36:24+01:00
New Revision: 58779495d3613386398fc70faeb098674d7757b5
URL: https://github.com/llvm/llvm-project/commit/58779495d3613386398fc70faeb098674d7757b5
DIFF: https://github.com/llvm/llvm-project/commit/58779495d3613386398fc70faeb098674d7757b5.diff
LOG: [clang][AST][NFC] Make FieldDecl in SubobjectAdjustment const
Added:
Modified:
clang/include/clang/AST/Expr.h
clang/lib/AST/Expr.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 59f0aee2c0ced..3fc481a62a78a 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -82,7 +82,7 @@ struct SubobjectAdjustment {
union {
struct DTB DerivedToBase;
- FieldDecl *Field;
+ const FieldDecl *Field;
struct P Ptr;
};
@@ -93,8 +93,7 @@ struct SubobjectAdjustment {
DerivedToBase.DerivedClass = DerivedClass;
}
- SubobjectAdjustment(FieldDecl *Field)
- : Kind(FieldAdjustment) {
+ SubobjectAdjustment(const FieldDecl *Field) : Kind(FieldAdjustment) {
this->Field = Field;
}
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index c2cd46dfbafcd..d665a08deb47e 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -86,12 +86,12 @@ const Expr *Expr::skipRValueSubobjectAdjustments(
while (true) {
E = E->IgnoreParens();
- if (const CastExpr *CE = dyn_cast<CastExpr>(E)) {
+ if (const auto *CE = dyn_cast<CastExpr>(E)) {
if ((CE->getCastKind() == CK_DerivedToBase ||
CE->getCastKind() == CK_UncheckedDerivedToBase) &&
E->getType()->isRecordType()) {
E = CE->getSubExpr();
- auto *Derived =
+ const auto *Derived =
cast<CXXRecordDecl>(E->getType()->castAs<RecordType>()->getDecl());
Adjustments.push_back(SubobjectAdjustment(CE, Derived));
continue;
@@ -101,10 +101,10 @@ const Expr *Expr::skipRValueSubobjectAdjustments(
E = CE->getSubExpr();
continue;
}
- } else if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
+ } else if (const auto *ME = dyn_cast<MemberExpr>(E)) {
if (!ME->isArrow()) {
assert(ME->getBase()->getType()->isRecordType());
- if (FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
+ if (const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
E = ME->getBase();
Adjustments.push_back(SubobjectAdjustment(Field));
@@ -112,12 +112,11 @@ const Expr *Expr::skipRValueSubobjectAdjustments(
}
}
}
- } else if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
+ } else if (const auto *BO = dyn_cast<BinaryOperator>(E)) {
if (BO->getOpcode() == BO_PtrMemD) {
assert(BO->getRHS()->isPRValue());
E = BO->getLHS();
- const MemberPointerType *MPT =
- BO->getRHS()->getType()->getAs<MemberPointerType>();
+ const auto *MPT = BO->getRHS()->getType()->getAs<MemberPointerType>();
Adjustments.push_back(SubobjectAdjustment(MPT, BO->getRHS()));
continue;
}
More information about the cfe-commits
mailing list