Skip to content

Fix typo and idiomatic empty check in converter_lib.cpp#116

Merged
nunoplopes merged 3 commits into
masterfrom
copilot/fix-spelling-filed-id
May 18, 2026
Merged

Fix typo and idiomatic empty check in converter_lib.cpp#116
nunoplopes merged 3 commits into
masterfrom
copilot/fix-spelling-filed-id

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

Two independent code quality fixes in converter_lib.cpp.

  • Typo fix: Rename filed_idfile_id in GetMainFileName
  • Idiomatic check: Replace name.size() == 0 with name.empty()
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Corrected spelling of 'filed_id' to 'file_id'.","fixFiles":[{"filePath":"cpp2rust/converter/converter_lib.cpp","diff":"diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp\n--- a/cpp2rust/converter/converter_lib.cpp\n+++ b/cpp2rust/converter/converter_lib.cpp\n@@ -274,8 +274,8 @@\n \n std::string GetMainFileName(const clang::ASTContext &ctx) {\n   const auto &src_mgr = ctx.getSourceManager();\n-  auto filed_id = src_mgr.getMainFileID();\n-  auto file_entry = src_mgr.getFileEntryRefForID(filed_id);\n+  auto file_id = src_mgr.getMainFileID();\n+  auto file_entry = src_mgr.getFileEntryRefForID(file_id);\n   auto file_path = file_entry->getName();\n   auto file_name = llvm::sys::path::filename(file_path);\n   return llvm::sys::path::stem(file_name).str();\n"}]},{"message":"Use name.empty() instead of name.size() == 0 for checking if a string is empty. This is more idiomatic and clearly expresses intent.","fixFiles":[{"filePath":"cpp2rust/converter/converter_lib.cpp","diff":"diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp\n--- a/cpp2rust/converter/converter_lib.cpp\n+++ b/cpp2rust/converter/converter_lib.cpp\n@@ -399,7 +399,7 @@\n     }\n   }\n \n-  if (name.size() == 0) {\n+  if (name.empty()) {\n     name = \"self\";\n   }\n \n"}]},{"message":"Recursive call to GetTemplateArgs(clang::QualType) with a single argument, but the function signature requires two parameters (qual_type and expr). This will result in a compilation error or call to a different overload if it exists. Pass nullptr as the second argument to match the function signature.","fixFiles":[{"filePath":"cpp2rust/converter/converter_lib.cpp","diff":"diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp\n--- a/cpp2rust/converter/converter_lib.cpp\n+++ b/cpp2rust/converter/converter_lib.cpp\n@@ -539,7 +539,7 @@\n   if (auto pt = qual_type->getPointeeType(); !pt.isNull())\n     qual_type = pt;\n \n-  return GetTemplateArgs(qual_type);\n+  return GetTemplateArgs(qual_type, nullptr);\n }\n \n clang::Expr *GetCallObject(clang::CallExpr *expr) {\n"}]}]

Copilot AI changed the title [WIP] Fix spelling of 'filed_id' to 'file_id' in converter_lib.cpp Fix typo, idiomatic empty check, and missing nullptr in converter_lib.cpp May 17, 2026
Copilot AI requested a review from nunoplopes May 17, 2026 21:06
Comment thread cpp2rust/converter/converter_lib.cpp Outdated
qual_type = pt;

return GetTemplateArgs(qual_type);
return GetTemplateArgs(qual_type, nullptr);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot revert this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — reverted in 7836d00.

Copilot AI changed the title Fix typo, idiomatic empty check, and missing nullptr in converter_lib.cpp Fix typo and idiomatic empty check in converter_lib.cpp May 17, 2026
Copilot AI requested a review from nunoplopes May 17, 2026 21:28
@nunoplopes nunoplopes marked this pull request as ready for review May 18, 2026 06:57
@nunoplopes nunoplopes merged commit 2668652 into master May 18, 2026
9 checks passed
@nunoplopes nunoplopes deleted the copilot/fix-spelling-filed-id branch May 18, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants