@@ -403,15 +403,17 @@ TranslationRule::ExprRule *search(const clang::Expr *expr) {
403403
404404std::pair<TranslationRule::TypeRule *, std::vector<std::optional<std::string>>>
405405search (clang::QualType qual_type) {
406- if (auto name = GetNameOfScalarTypedef (qual_type); !name.empty ()) {
407- auto res = search (types_, name, GetTypeMapKey (name));
408- if (res.first ) {
409- log () << " search type " << name
410- << " , result: " << res.first ->type_info .type << ' \n ' ;
411- return res;
412- }
406+ auto sugared = ToString (qual_type, ScalarSugar::kPreserve );
407+ if (auto res = search (types_, sugared, GetTypeMapKey (sugared)); res.first ) {
408+ log () << " search type " << sugared
409+ << " , result: " << res.first ->type_info .type << ' \n ' ;
410+ return res;
413411 }
414412 auto type = ToString (qual_type);
413+ if (type == sugared) {
414+ log () << " search type " << type << " , result: None\n " ;
415+ return {};
416+ }
415417 auto res = search (types_, type, GetTypeMapKey (type));
416418 log () << " search type " << type
417419 << " , result: " << (res.first ? res.first ->type_info .type : " None" )
@@ -742,9 +744,17 @@ void AddRuleForUserDefinedType(clang::NamedDecl *decl) {
742744 }
743745}
744746
745- std::string ToString (clang::QualType qual_type) {
747+ std::string ToString (clang::QualType qual_type, ScalarSugar sugar ) {
746748 assert (ctx_);
747749
750+ if (sugar == ScalarSugar::kPreserve ) {
751+ if (const auto *typedef_type = qual_type->getAs <clang::TypedefType>()) {
752+ if (qual_type.getCanonicalType ()->isBuiltinType ()) {
753+ return typedef_type->getDecl ()->getNameAsString ();
754+ }
755+ }
756+ }
757+
748758 if (auto cxx_record_decl = qual_type->getAsCXXRecordDecl ()) {
749759 if (cxx_record_decl->isLambda ()) {
750760 return ToString (cxx_record_decl->getLambdaCallOperator ());
0 commit comments