https://github.com/flynow10 created https://github.com/llvm/llvm-project/pull/183928
Addresses issue #183501 >From fbbb8edc2582cfb2c8c3c8b55b8a8b653c821289 Mon Sep 17 00:00:00 2001 From: Natalie Wagner <[email protected]> Date: Fri, 27 Feb 2026 21:23:41 -0500 Subject: [PATCH] [clang][sema] Add arg count check for two builtins --- clang/lib/Sema/SemaChecking.cpp | 3 +++ clang/test/Sema/builtin-allow-sanitize-check.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 45dce52179f82..366c3033099dd 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3804,6 +3804,9 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, } case Builtin::BI__builtin_allow_sanitize_check: { + if (checkArgCount(TheCall, 1)) + return ExprError(); + Expr *Arg = TheCall->getArg(0); // Check if the argument is a string literal. const StringLiteral *SanitizerName = diff --git a/clang/test/Sema/builtin-allow-sanitize-check.c b/clang/test/Sema/builtin-allow-sanitize-check.c index 6e0e21a869461..a7d83c1833d84 100644 --- a/clang/test/Sema/builtin-allow-sanitize-check.c +++ b/clang/test/Sema/builtin-allow-sanitize-check.c @@ -9,6 +9,9 @@ void test_builtin_allow_sanitize_check() { // Test with unsupported sanitizer name. (void)__builtin_allow_sanitize_check("unsupported"); // expected-error {{invalid argument 'unsupported' to __builtin_allow_sanitize_check}} + // Test with invalid number of arguments + (void)__builtin_allow_sanitize_check(); // expected-error {{too few arguments to function call}} + // Test with supported sanitizer names. (void)__builtin_allow_sanitize_check("address"); (void)__builtin_allow_sanitize_check("thread"); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
