Skip to content

[Clang][NFC] Rename SecondArgIsLastNamedArgument for clarity and consistency #131346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

imdj
Copy link
Contributor

@imdj imdj commented Mar 14, 2025

Change the name of the control variable SecondArgIsLastNamedArgument to SecondArgIsLastNonVariadicArgument for clarity and consistency.

Following feedback on earlier PR that was merged:

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2025

@llvm/pr-subscribers-clang

Author: Imad Aldij (imdj)

Changes

Change the name of the control variable SecondArgIsLastNamedArgument to SecondArgIsLastNonVariadicArgument for clarity and consistency.

Following feedback on earlier PR that was merged:

  • #131238

Full diff: https://github.com/llvm/llvm-project/pull/131346.diff

1 Files Affected:

  • (modified) clang/lib/Sema/SemaChecking.cpp (+4-4)
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e99e30d75df94..c8e8cb6f4c150 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4867,14 +4867,14 @@ bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
   // current function or method. In C23 mode, if the second argument is an
   // integer constant expression with value 0, then we don't bother with this
   // check.
-  bool SecondArgIsLastNamedArgument = false;
+  bool SecondArgIsLastNonVariadicArgument = false;
   const Expr *Arg = TheCall->getArg(1)->IgnoreParenCasts();
   if (std::optional<llvm::APSInt> Val =
           TheCall->getArg(1)->getIntegerConstantExpr(Context);
       Val && LangOpts.C23 && *Val == 0)
     return false;
 
-  // These are valid if SecondArgIsLastNamedArgument is false after the next
+  // These are valid if SecondArgIsLastNonVariadicArgument is false after the next
   // block.
   QualType Type;
   SourceLocation ParamLoc;
@@ -4882,7 +4882,7 @@ bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
 
   if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
     if (const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
-      SecondArgIsLastNamedArgument = PV == LastParam;
+      SecondArgIsLastNonVariadicArgument = PV == LastParam;
 
       Type = PV->getType();
       ParamLoc = PV->getLocation();
@@ -4891,7 +4891,7 @@ bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
     }
   }
 
-  if (!SecondArgIsLastNamedArgument)
+  if (!SecondArgIsLastNonVariadicArgument)
     Diag(TheCall->getArg(1)->getBeginLoc(),
          diag::warn_second_arg_of_va_start_not_last_non_variadic_param);
   else if (IsCRegister || Type->isReferenceType() ||

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

@imdj
Copy link
Contributor Author

imdj commented Mar 14, 2025

cc: @erichkeane

Copy link

github-actions bot commented Mar 14, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@imdj imdj force-pushed the clang_second_arg_is_last branch 2 times, most recently from 3b2f0f9 to 6ecbeba Compare March 14, 2025 15:58
@cor3ntin cor3ntin changed the title [Clang] Rename SecondArgIsLastNamedArgument for clarity and consistency [Clang][NFC] Rename SecondArgIsLastNamedArgument for clarity and consistency Mar 14, 2025
Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

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

I'm in favor, but lets let @AaronBallman take a look/click merge if is OK too.

@imdj imdj force-pushed the clang_second_arg_is_last branch from a03dc8d to 0b0361f Compare March 15, 2025 19:46
@imdj
Copy link
Contributor Author

imdj commented Mar 15, 2025

I just did a rebase after the merge of #131166 .
Could you take a look please @AaronBallman and see if everything looks good now?

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM

@AaronBallman AaronBallman merged commit e0223fa into llvm:main Mar 17, 2025
10 of 11 checks passed
@imdj imdj deleted the clang_second_arg_is_last branch March 17, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants