@@ -1218,12 +1218,12 @@ void VectorTypeNamespaceRule::registerMatcher(MatchFinder &MF) {
12181218 " longlong1" , " ulonglong1" , " double1" , " __half_raw" )))
12191219 .bind (" inherit" ),
12201220 this );
1221- // Matcher for __half_raw implicitly convert to half.
1221+ // Matcher for __half_raw/__half2_raw implicitly convert to half/half2 .
12221222 MF.addMatcher (
12231223 declRefExpr (allOf (unless (hasParent (memberExpr ())),
12241224 unless (hasParent (unaryOperator (hasOperatorName (" &" )))),
1225- to (varDecl (hasType (qualType (hasDeclaration (
1226- namedDecl ( hasAnyName (" __half_raw" ))))))),
1225+ to (varDecl (hasType (qualType (hasDeclaration (namedDecl (
1226+ hasAnyName (" __half_raw" , " __half2_raw " ))))))),
12271227 hasParent (implicitCastExpr ())))
12281228 .bind (" halfRawExpr" ),
12291229 this );
@@ -1405,7 +1405,7 @@ void VectorTypeNamespaceRule::runRule(const MatchFinder::MatchResult &Result) {
14051405 UETT, Diagnostics::SIZEOF_WARNING, true , argTypeName,
14061406 " Check that the allocated memory size in the migrated code is correct" );
14071407 }
1408- // Runrule for __half_raw implicitly convert to half.
1408+ // Run rule for __half_raw/__half2_raw implicitly convert to half/half2 .
14091409 if (auto DRE = getNodeAsType<DeclRefExpr>(Result, " halfRawExpr" )) {
14101410 if (const auto *RT =
14111411 DRE->getType ().getCanonicalType ()->getAs <RecordType>()) {
@@ -1414,13 +1414,17 @@ void VectorTypeNamespaceRule::runRule(const MatchFinder::MatchResult &Result) {
14141414 }
14151415 ExprAnalysis EA;
14161416 std::string Replacement;
1417- llvm::raw_string_ostream OS (Replacement);
1418- OS << MapNames::getClNamespace () + " bit_cast<" +
1419- MapNames::getClNamespace () + " half>(" ;
14201417 EA.analyze (DRE);
1421- OS << EA.getReplacedString ();
1422- OS << " )" ;
1423- OS.flush ();
1418+ if (DRE->getType ().getCanonicalType ().getAsString () == " __half2_raw" ) {
1419+ llvm::raw_string_ostream OS (Replacement);
1420+ OS << EA.getReplacedString () << " .as<" << MapNames::getClNamespace ()
1421+ << " half2>()" ;
1422+ } else {
1423+ llvm::raw_string_ostream OS (Replacement);
1424+ OS << MapNames::getClNamespace () << " bit_cast<"
1425+ << MapNames::getClNamespace () << " half>(" << EA.getReplacedString ()
1426+ << " )" ;
1427+ }
14241428 emplaceTransformation (new ReplaceStmt (DRE, Replacement));
14251429 return ;
14261430 }
0 commit comments