Copilot commented on code in PR #3611:
URL: https://github.com/apache/thrift/pull/3611#discussion_r3501341279


##########
compiler/cpp/src/thrift/generate/t_xsd_generator.cc:
##########
@@ -94,9 +94,11 @@ class t_xsd_generator : public t_generator {
   std::string base_type_name(t_base_type::t_base tbase);
 
   virtual std::string xml_autogen_comment() {
-    return std::string("<!--\n") + " * Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
-           + " *\n" + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT 
YOU ARE DOING\n"
-           + " -->\n";
+    return "<!--\n"
+           " * Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           " *\n"
+           " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+           " -->\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro (see 
compiler/cpp/src/thrift/version.h). Using `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers and no 
overloaded `operator+` applies, so this should not compile. Use adjacent 
string-literal concatenation with the macro instead (no `operator+` at all).



##########
compiler/cpp/src/thrift/generate/t_rb_generator.cc:
##########
@@ -342,9 +342,12 @@ string t_rb_generator::render_includes() {
  * Autogen'd comment
  */
 string t_rb_generator::rb_autogen_comment() {
-  return std::string("# frozen_string_literal: true\n") + "#\n"
-         + "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
-         + "#\n" + "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU 
ARE DOING\n" + "#\n";
+  return "# frozen_string_literal: true\n"
+         "#\n"
+         "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         "#\n"
+         "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+         "#\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Use adjacent 
string-literal concatenation with the macro to keep this compile-time and avoid 
`operator+`.



##########
compiler/cpp/src/thrift/generate/t_perl_generator.cc:
##########
@@ -152,8 +152,11 @@ class t_perl_generator : public t_oop_generator {
   std::string type_to_enum(t_type* ttype);
 
   std::string autogen_comment() override {
-    return std::string("#\n") + "# Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
-           + "#\n" + "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU 
ARE DOING\n" + "#\n";
+    return "#\n"
+           "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           "#\n"
+           "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+           "#\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Prefer 
adjacent string-literal concatenation with the macro.



##########
compiler/cpp/src/thrift/generate/t_erl_generator.cc:
##########
@@ -393,9 +393,11 @@ string t_erl_generator::render_includes() {
  * Autogen'd comment
  */
 string t_erl_generator::erl_autogen_comment() {
-  return std::string("%%\n") + "%% Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
-         + "%%\n" + "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU 
ARE DOING\n"
-         + "%%\n";
+  return "%%\n"
+         "%% Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         "%%\n"
+         "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+         "%%\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Use adjacent 
string-literal concatenation with the macro instead.



##########
compiler/cpp/src/thrift/generate/t_go_generator.cc:
##########
@@ -692,9 +692,7 @@ string t_go_generator::render_fastbinary_includes() {
  * https://github.com/golang/go/issues/13560#issuecomment-288457920
  */
 string t_go_generator::go_autogen_comment() {
-  return
-        std::string() +
-        "// Code generated by Thrift Compiler (" + THRIFT_VERSION + "). DO NOT 
EDIT.\n\n";
+  return "// Code generated by Thrift Compiler (" + THRIFT_VERSION + "). DO 
NOT EDIT.\n\n";

Review Comment:
   This expression uses `"..." + THRIFT_VERSION` but `THRIFT_VERSION` is a 
string-literal macro, so this is ill-formed (both operands are C string 
literals/pointers). Use adjacent string-literal concatenation with the macro 
instead (no `operator+`).



##########
compiler/cpp/src/thrift/generate/t_delphi_generator.cc:
##########
@@ -342,9 +342,11 @@ class t_delphi_generator : public t_oop_generator {
   std::string constructor_param_name(string name);
 
   std::string autogen_comment() override {
-    return std::string("(**\n") + " * Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
-           + " *\n" + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT 
YOU ARE DOING\n"
-           + " *)\n";
+    return "(**\n"
+           " * Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           " *\n"
+           " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+           " *)\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Use adjacent 
string-literal concatenation with the macro instead.



##########
compiler/cpp/src/thrift/generate/t_ocaml_generator.cc:
##########
@@ -249,8 +249,11 @@ void t_ocaml_generator::init_generator() {
  * Autogen'd comment
  */
 string t_ocaml_generator::ocaml_autogen_comment() {
-  return std::string("(*\n") + " Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n" + "\n"
-         + " DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING\n" + 
"*)\n";
+  return "(*\n"
+         " Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         "\n"
+         " DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING\n"
+         "*)\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Use adjacent 
string-literal concatenation with the macro instead.



##########
compiler/cpp/src/thrift/generate/t_js_generator.cc:
##########
@@ -269,9 +269,11 @@ class t_js_generator : public t_oop_generator {
   void parse_thrift_package_output_directory(const std::string& 
thrift_package_output_directory);
 
   std::string autogen_comment() override {
-    return std::string("//\n") + "// Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
-           + "//\n" + "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT 
YOU ARE DOING\n"
-           + "//\n";
+    return "//\n"
+           "// Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           "//\n"
+           "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+           "//\n";

Review Comment:
   `THRIFT_VERSION` is a string-literal macro; `"..." + THRIFT_VERSION` is 
ill-formed because both operands are C string literals/pointers. Use adjacent 
string-literal concatenation with the macro to keep this purely literal 
concatenation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to