[PATCH] D74087: [Sema] Fix Sema checkArgCount function

Baptiste Saleil via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 5 13:40:04 PST 2020


bsaleil created this revision.
bsaleil added a reviewer: rsmith.
bsaleil added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes the checkArgCount function in Sema that is used to check the number of arguments of a call when doing custom type-checking.
The patch fixes that function in two ways:

1. It now displays the right range in case the number of actual arguments is greater than the number of expected arguments
2. It allows the function to properly handle the case in which the desired argument count is 0 and the number of actual arguments is 1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74087

Files:
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -122,7 +122,7 @@
 
   return S.Diag(range.getBegin(), diag::err_typecheck_call_too_many_args)
     << 0 /*function call*/ << desiredArgCount << argCount
-    << call->getArg(1)->getSourceRange();
+    << range;
 }
 
 /// Check that the first argument to __builtin_annotation is an integer


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74087.242734.patch
Type: text/x-patch
Size: 471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200205/690d4ae8/attachment-0001.bin>


More information about the cfe-commits mailing list