From 3ea55260995655776c14e53f1dc6e0a99d93d0ad Mon Sep 17 00:00:00 2001 From: "Jiang, Zhiwei" Date: Tue, 30 Jul 2024 14:08:26 +0800 Subject: [PATCH] [SYCLomatic] Fix lit case kernel_without_name.cu on Windows (#2202) Signed-off-by: Jiang, Zhiwei --- clang/lib/DPCT/AnalysisInfo.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/clang/lib/DPCT/AnalysisInfo.cpp b/clang/lib/DPCT/AnalysisInfo.cpp index ed886a388ae3..0a8c22895334 100644 --- a/clang/lib/DPCT/AnalysisInfo.cpp +++ b/clang/lib/DPCT/AnalysisInfo.cpp @@ -5160,21 +5160,26 @@ KernelCallExpr::ArgInfo::ArgInfo(const ParmVarDecl *PVD, IsUsedAsLvalueAfterMalloc(Used), Index(Index) { if (isa(Arg)) { HasImplicitConversion = true; - } else if (const auto* CCE = dyn_cast(Arg)) { + } else if (const auto *CCE = dyn_cast(Arg)) { HasImplicitConversion = true; - if (CCE->getNumArgs()) { - if (const auto *ICE = dyn_cast(CCE->getArg(0))) { - if (ICE->getCastKind() == CK_DerivedToBase) { - IsRedeclareRequired = true; - } - } + if (CCE->getNumArgs() == 1) { + Arg = CCE->getArg(0); } - } else if (const auto *ICE = dyn_cast(Arg)) { + } +#ifdef _WIN32 + // This code path is for ConstructorConversion on Windows since its AST is + // different from the one on Linux. + if (const auto *MTE = dyn_cast(Arg)) { + Arg = MTE->getSubExpr(); + } +#endif + if (const auto *ICE = dyn_cast(Arg)) { auto CK = ICE->getCastKind(); if (CK != CK_LValueToRValue) { HasImplicitConversion = true; } - if (CK == CK_ConstructorConversion || CK == CK_UserDefinedConversion) { + if (CK == CK_ConstructorConversion || CK == CK_UserDefinedConversion || + CK == CK_DerivedToBase) { IsRedeclareRequired = true; } }