[clang] dde474c - [CIR] Make ClangIR compatible with latest nested name specifier AST representation (#152846)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 11 11:08:41 PDT 2025
Author: Amr Hesham
Date: 2025-08-11T20:08:37+02:00
New Revision: dde474cfc41b480422a3c4e9607843660a88fc2a
URL: https://github.com/llvm/llvm-project/commit/dde474cfc41b480422a3c4e9607843660a88fc2a
DIFF: https://github.com/llvm/llvm-project/commit/dde474cfc41b480422a3c4e9607843660a88fc2a.diff
LOG: [CIR] Make ClangIR compatible with latest nested name specifier AST representation (#152846)
After AST representation, new modifications landed in
(https://github.com/llvm/llvm-project/pull/147835). ClangIR requires
some changes in how we use Clang AST to be compatible with the new
changes
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenCall.cpp
clang/lib/CIR/CodeGen/CIRGenExpr.cpp
clang/lib/CIR/CodeGen/CIRGenFunction.cpp
clang/lib/CIR/CodeGen/CIRGenTypes.cpp
clang/lib/CIR/CodeGen/TargetInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
index adf0ca1a1fe93..e3fe3ca1c30c9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
@@ -42,17 +42,17 @@ CIRGenFunctionInfo::create(CanQualType resultType,
return fi;
}
-cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &fi) {
- mlir::Type resultType = convertType(fi.getReturnType());
+cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &info) {
+ mlir::Type resultType = convertType(info.getReturnType());
SmallVector<mlir::Type, 8> argTypes;
- argTypes.reserve(fi.getNumRequiredArgs());
+ argTypes.reserve(info.getNumRequiredArgs());
- for (const CanQualType &argType : fi.requiredArguments())
+ for (const CanQualType &argType : info.requiredArguments())
argTypes.push_back(convertType(argType));
return cir::FuncType::get(argTypes,
(resultType ? resultType : builder.getVoidTy()),
- fi.isVariadic());
+ info.isVariadic());
}
CIRGenCallee CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const {
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index c437b14dd8d1c..d8f7ba5c79cc6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -1169,7 +1169,8 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf,
->getBaseElementTypeUnsafe()
->getAs<clang::RecordType>()) {
// Get the destructor for the reference temporary.
- auto *classDecl = cast<CXXRecordDecl>(rt->getOriginalDecl());
+ auto *classDecl =
+ cast<CXXRecordDecl>(rt->getOriginalDecl()->getDefinitionOrSelf());
if (!classDecl->hasTrivialDestructor())
referenceTemporaryDtor =
classDecl->getDefinitionOrSelf()->getDestructor();
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index 03555a52f1252..8a3f5ab78ab59 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
@@ -356,8 +356,8 @@ static bool mayDropFunctionReturn(const ASTContext &astContext,
// destructor or a non-trivially copyable type.
if (const RecordType *recordType =
returnType.getCanonicalType()->getAs<RecordType>()) {
- if (const auto *classDecl =
- dyn_cast<CXXRecordDecl>(recordType->getOriginalDecl()))
+ if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
+ recordType->getOriginalDecl()->getDefinitionOrSelf()))
return classDecl->hasTrivialDestructor();
}
return returnType.isTriviallyCopyableType(astContext);
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 2084b6d9e8989..0084519154e2a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -139,6 +139,8 @@ isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt,
if (!alreadyChecked.insert(rd).second)
return true;
+ assert(rd->isCompleteDefinition() &&
+ "Expect RecordDecl to be CompleteDefinition");
const Type *key = cgt.getASTContext().getCanonicalTagType(rd).getTypePtr();
// If this type is already laid out, converting it is a noop.
diff --git a/clang/lib/CIR/CodeGen/TargetInfo.cpp b/clang/lib/CIR/CodeGen/TargetInfo.cpp
index 1447dba87db7e..7b6259b04122d 100644
--- a/clang/lib/CIR/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CIR/CodeGen/TargetInfo.cpp
@@ -17,13 +17,13 @@ bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context,
if (cxxrd->isDynamicClass())
return false;
- for (const auto &I : cxxrd->bases())
- if (!isEmptyRecordForLayout(context, I.getType()))
+ for (const auto &i : cxxrd->bases())
+ if (!isEmptyRecordForLayout(context, i.getType()))
return false;
}
- for (const auto *I : rd->fields())
- if (!isEmptyFieldForLayout(context, I))
+ for (const auto *i : rd->fields())
+ if (!isEmptyFieldForLayout(context, i))
return false;
return true;
More information about the cfe-commits
mailing list