[clang] [clang] Warn on umask() argument bits outside 0777 (PR #198130)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 5 06:55:53 PDT 2026


================
@@ -1490,6 +1490,49 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
                           << FunctionName << DestinationStr << SourceStr);
 }
 
+void Sema::checkFortifiedLibcArgument(FunctionDecl *FD, CallExpr *TheCall) {
+  if (TheCall->isValueDependent() || TheCall->isTypeDependent() ||
+      isConstantEvaluatedContext())
+    return;
+  if (!FD->isExternC())
+    return;
+  const IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+    return;
+
+  // umask(mode_t): warn when the constant-evaluated argument has bits set
+  // outside the file-permission mask (0777). Those bits are ignored.
+  // Require a matching system-header declaration to avoid warning on
+  // user-defined lookalikes.
+  auto AnyDeclInSystemHeader = [&](const FunctionDecl *F) {
----------------
AaronBallman wrote:

> So why did it hurt for read/write specifically? Those names are everywhere, lots of real C code declares its own read/write with different signatures, so a pile of previously-clean code started warning. That's what got them pulled and dispatched by name instead.

Thanks, that's good to know!

https://github.com/llvm/llvm-project/pull/198130


More information about the cfe-commits mailing list