[clang] [Clang][Sema] Add fortify warnings for realpath (PR #230695)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 20:14:03 PDT 2026
================
@@ -1601,6 +1601,23 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
BufferSize = Checker.ComputeSizeArgument(0);
break;
}
+ case Builtin::BIrealpath: {
+ BufferSize = Checker.ComputeSizeArgument(1);
+ if (!BufferSize)
+ return;
+ const llvm::Triple &T = Context.getTargetInfo().getTriple();
+ uint64_t PathMax = 0;
+ if (T.isOSLinux() || T.isOSFuchsia() || T.isOSAIX() || T.isOSHaiku())
+ PathMax = 4096;
+ else if (T.isOSDarwin() || T.isOSFreeBSD() || T.isOSNetBSD() ||
+ T.isOSOpenBSD() || T.isOSSolaris())
+ PathMax = 1024;
+ else
----------------
ojhunt wrote:
This smells of copy pasta -- assuming this logic exists elsewhere it should be placed in a helper function
https://github.com/llvm/llvm-project/pull/230695
More information about the cfe-commits
mailing list