[PATCH] D87561: [Sema] List conversion validate character array

Mark de Wever via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 10:50:39 PDT 2020


Mordante marked 3 inline comments as done.
Mordante added a comment.

Thanks for the feedback!



================
Comment at: clang/lib/Sema/SemaOverload.cpp:4988
+
+    if (ToType->isArrayType() && ToType->isCharType() &&
+        isa<StringLiteral>(From->getInit(0))) {
----------------
rsmith wrote:
> `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?
I think exposing this function sounds good.


================
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)) {
----------------
rsmith wrote:
> Phabricator thinks you converted spaces to tabs here. Please can you check and convert back if necessary?
That's odd in my editor I see spaces. I ran `git clang-format` on an earlier version where I made some changes here. I'll revert the hunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87561



More information about the cfe-commits mailing list