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


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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to