Mordante marked 2 inline comments as done.
Mordante added inline comments.

================
Comment at: clang/lib/Sema/SemaOverload.cpp:4989
+    if (ToType->isArrayType() && ToType->isCharType() &&
+        isa<StringLiteral>(From->getInit(0))) {
       InitializedEntity Entity =
----------------
rsmith wrote:
> This is too narrow a check in two ways: we should allow parenthesized string 
> literals here, and we should allow `ObjCEncodeExpr`.
Actually it seems the code isn't behaving properly at all. It seems the 
conversion is done by
https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaOverload.cpp#L5174
resulting in an array-to-pointer conversion instead of an identity conversion.

It can solve it by manually removing the decay like:
```
    if (const auto *DT = dyn_cast<DecayedType>(ToType))
      if (const auto *AT = S.Context.getAsArrayType(DT->getOriginalType()))
        if (S.IsStringInit(From->getInit(0), AT) {
           ...
```
This code works and results in an identity conversion. But it feels a bit odd 
to manually peel away the array-to-pointer decay. Is this the best solution or 
do you have a better suggestions?
  



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87561

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to