rsmith added inline comments.

================
Comment at: clang/lib/Sema/SemaOverload.cpp:4988
+
+    if (ToType->isArrayType() && ToType->isCharType() &&
+        isa<StringLiteral>(From->getInit(0))) {
----------------
`isCharType` is too narrow a check here. We also need to check for all the 
other types that can be initialized from a string literal (`wchar_t`, 
`char16_t`, ... -- including `unsigned short` in some cases). These details are 
handled by 
[`IsStringInit`](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaInit.cpp#L136).
 Maybe it's worth exposing that as a `bool Sema::isStringInit` function or 
similar to use from here?


================
Comment at: clang/lib/Sema/SemaOverload.cpp:4989
+    if (ToType->isArrayType() && ToType->isCharType() &&
+        isa<StringLiteral>(From->getInit(0))) {
       InitializedEntity Entity =
----------------
This is too narrow a check in two ways: we should allow parenthesized string 
literals here, and we should allow `ObjCEncodeExpr`.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:4991-4992
       InitializedEntity Entity =
-        InitializedEntity::InitializeParameter(S.Context, ToType,
-                                               /*Consumed=*/false);
+          InitializedEntity::InitializeParameter(S.Context, ToType,
+                                                 /*Consumed=*/false);
       if (S.CanPerformCopyInitialization(Entity, From)) {
----------------
Phabricator thinks you converted spaces to tabs here. Please can you check and 
convert back if necessary?


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