================
@@ -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
+      return;
----------------
enh-google wrote:

yeah, the sensible way to use realpath() is to pass null and let it allocate 
for you, but that's why the check here is "at least" PATH_MAX, right?

"it's not what we _want_ to say, but it's the best that we _can_ say".

(having been generally quite opinionated in bionic's headers though, i do think 
there's a case to be made for the warning favoring using null instead. although 
you then have a similar problem to your current "what's the value of PATH_MAX 
on the _target_ OS?" for "does the target OS support a null second argument?".)

https://github.com/llvm/llvm-project/pull/230695
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to