[PATCH] D135341: adds `__reference_constructs_from_temporary`

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 13 10:19:51 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5515
+      QualType UPtr = S.BuiltinAddPointer(S.BuiltinRemoveReference(U, UnaryTransformType::RemoveCVRef, {}), {});
+      return EvaluateBinaryTypeTrait(S, TypeTrait::BTT_IsConvertibleTo, UPtr, TPtr, RParenLoc);
     }
----------------
cjdb wrote:
> cor3ntin wrote:
> > cor3ntin wrote:
> > > Could you put the implementation of `BTT_IsConvertibleTo` in its own function?
> > I was thinking something like
> > 
> > ```
> > QualType TPtr = S.Context.getPointerType(S.BuiltinRemoveReference(T, UnaryTransformType::RemoveCVRef, {}));
> > QualType UPtr = S.Context.getPointerType(S.BuiltinRemoveReference(U, UnaryTransformType::RemoveCVRef, {}));
> > return IsConvertibleTo(S, UPtr, TPtr);
> > ```
> > 
> > and then EvaluateBinaryTypeTrait can use this new `IsConvertibleTo` (which we can extract from EvaluateBinaryTypeTrait)
> That sounds like an orthogonal change. How about I revert to what was previously there and do that as a second PR? It'll also need a location parameter.
I don't insist. Please keep the `getPointerType` changes though.

It is pretty unusual to evaluate type traits in terms of the implementation of other type traits, because all of these things do different Sema (some of it is wasteful) and 
could add undesired diagnostics in the future.

But if you prefer that can be done later!



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135341/new/

https://reviews.llvm.org/D135341



More information about the cfe-commits mailing list