[clang] [-Wunsafe-buffer-usage] Allow strerror for %s in printf-like calls (PR #175208)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 9 14:35:47 PST 2026


================
@@ -771,6 +771,11 @@ static bool isNullTermPointer(const Expr *Ptr, ASTContext &Ctx) {
       if (MD->getName() == "c_str" && RD->getName() == "basic_string")
         return true;
   }
+  if (auto *CE = dyn_cast<CallExpr>(Ptr->IgnoreParenImpCasts())) {
+    const FunctionDecl *F = CE->getDirectCallee();
+    if (F && F->getIdentifier() && F->getName() == "strerror")
----------------
ojhunt wrote:

Ah yeah, here we go: https://github.com/swiftlang/llvm-project/blob/941e9a5682c3a452ea98258a9b1701e40315033c/clang/lib/Analysis/UnsafeBufferUsage.cpp#L1696


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


More information about the cfe-commits mailing list