Skip to content

Commit b6500da

Browse files
AmrDevelopergithub-actions[bot]
authored andcommitted
Automerge: [CIR] Make ClangIR compatible with latest nested name specifier AST representation (#152846)
After AST representation, new modifications landed in (llvm/llvm-project#147835). ClangIR requires some changes in how we use Clang AST to be compatible with the new changes
2 parents 12f0432 + dde474c commit b6500da

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ CIRGenFunctionInfo::create(CanQualType resultType,
4242
return fi;
4343
}
4444

45-
cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &fi) {
46-
mlir::Type resultType = convertType(fi.getReturnType());
45+
cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &info) {
46+
mlir::Type resultType = convertType(info.getReturnType());
4747
SmallVector<mlir::Type, 8> argTypes;
48-
argTypes.reserve(fi.getNumRequiredArgs());
48+
argTypes.reserve(info.getNumRequiredArgs());
4949

50-
for (const CanQualType &argType : fi.requiredArguments())
50+
for (const CanQualType &argType : info.requiredArguments())
5151
argTypes.push_back(convertType(argType));
5252

5353
return cir::FuncType::get(argTypes,
5454
(resultType ? resultType : builder.getVoidTy()),
55-
fi.isVariadic());
55+
info.isVariadic());
5656
}
5757

5858
CIRGenCallee CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const {

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf,
11691169
->getBaseElementTypeUnsafe()
11701170
->getAs<clang::RecordType>()) {
11711171
// Get the destructor for the reference temporary.
1172-
auto *classDecl = cast<CXXRecordDecl>(rt->getOriginalDecl());
1172+
auto *classDecl =
1173+
cast<CXXRecordDecl>(rt->getOriginalDecl()->getDefinitionOrSelf());
11731174
if (!classDecl->hasTrivialDestructor())
11741175
referenceTemporaryDtor =
11751176
classDecl->getDefinitionOrSelf()->getDestructor();

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ static bool mayDropFunctionReturn(const ASTContext &astContext,
356356
// destructor or a non-trivially copyable type.
357357
if (const RecordType *recordType =
358358
returnType.getCanonicalType()->getAs<RecordType>()) {
359-
if (const auto *classDecl =
360-
dyn_cast<CXXRecordDecl>(recordType->getOriginalDecl()))
359+
if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
360+
recordType->getOriginalDecl()->getDefinitionOrSelf()))
361361
return classDecl->hasTrivialDestructor();
362362
}
363363
return returnType.isTriviallyCopyableType(astContext);

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt,
139139
if (!alreadyChecked.insert(rd).second)
140140
return true;
141141

142+
assert(rd->isCompleteDefinition() &&
143+
"Expect RecordDecl to be CompleteDefinition");
142144
const Type *key = cgt.getASTContext().getCanonicalTagType(rd).getTypePtr();
143145

144146
// If this type is already laid out, converting it is a noop.

clang/lib/CIR/CodeGen/TargetInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context,
1717
if (cxxrd->isDynamicClass())
1818
return false;
1919

20-
for (const auto &I : cxxrd->bases())
21-
if (!isEmptyRecordForLayout(context, I.getType()))
20+
for (const auto &i : cxxrd->bases())
21+
if (!isEmptyRecordForLayout(context, i.getType()))
2222
return false;
2323
}
2424

25-
for (const auto *I : rd->fields())
26-
if (!isEmptyFieldForLayout(context, I))
25+
for (const auto *i : rd->fields())
26+
if (!isEmptyFieldForLayout(context, i))
2727
return false;
2828

2929
return true;

0 commit comments

Comments
 (0)