Skip to content

Commit 7ce9725

Browse files
committed
Fix subexpr as extraction by getting pointee type.
1 parent 30c7d9a commit 7ce9725

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515

1616
#include "clang/AST/Expr.h"
1717
#include "clang/AST/StmtVisitor.h"
18+
#include "clang/AST/TypeBase.h"
1819
#include "clang/CIR/Dialect/IR/CIRTypes.h"
1920
#include "clang/CIR/MissingFeatures.h"
21+
#include "llvm/Support/raw_ostream.h"
2022

2123
#include "mlir/IR/Location.h"
2224
#include "mlir/IR/Value.h"
@@ -1889,7 +1891,11 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) {
18891891
cgf.getLoc(subExpr->getExprLoc()));
18901892
}
18911893

1892-
clang::LangAS srcLangAS = subExpr->getType().getAddressSpace();
1894+
clang::QualType srcTy = subExpr->IgnoreImpCasts()->getType();
1895+
if (srcTy->isPointerType() || srcTy->isReferenceType())
1896+
srcTy = srcTy->getPointeeType();
1897+
1898+
clang::LangAS srcLangAS = srcTy.getAddressSpace();
18931899
cir::TargetAddressSpaceAttr subExprAS;
18941900
if (clang::isTargetAddressSpace(srcLangAS))
18951901
subExprAS = cir::toCIRTargetAddressSpace(cgf.getMLIRContext(), srcLangAS);

0 commit comments

Comments
 (0)