[clang][Sema] Fix typo in checkBuiltinArgument helper
authorAlex Bradbury <asb@igalia.com>
Wed, 20 Apr 2022 13:28:42 +0000 (14:28 +0100)
committerAlex Bradbury <asb@igalia.com>
Wed, 20 Apr 2022 13:42:41 +0000 (14:42 +0100)
The checkBuiltinArgument helper takes an integer ArgIndex and is
documented as performing normal type-checking on that argument. However,
it mistakenly hardcodes the argument index to zero when retrieving the
argument from the call expression.

This hadn't been noticed previously as all in-tree uses typecheck the
0th argument anyway.

clang/lib/Sema/SemaChecking.cpp

index cd069d5..f575c07 100644 (file)
@@ -6222,7 +6222,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) {
   InitializedEntity Entity =
     InitializedEntity::InitializeParameter(S.Context, Param);
 
-  ExprResult Arg = E->getArg(0);
+  ExprResult Arg = E->getArg(ArgIndex);
   Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg);
   if (Arg.isInvalid())
     return true;