================
@@ -1140,6 +1143,152 @@ static bool ProcessFormatStringLiteral(const Expr 
*FormatExpr,
   return false;
 }
 
+static std::optional<int> getPathMaxValue(const ASTContext &Ctx) {
+  if (Ctx.getTargetInfo().getTriple().isOSGlibc())
+    return {4096};
----------------
ojhunt wrote:

You can use PP.getMacroDefinition for PATH_MAX, giving you macro info, from 
there you can examine the macro definition, which will presumably be a single 
token that is an integer literal, which you can parse out. If PATH_MAX is not 
defined then you definitionally know the developer cannot be doing the correct 
thing so you can warn.

Rather than caching that you might choose to ask for getMacroDefinition at the 
location of the expression - it limits your ability to cache but as it's just a 
couple of hash lookups it should be completely fine.

If PATH_MAX is not a single token numeric macro you could emit a warning and 
someone will file a bug that allows us to see what other patterns we need to 
support.

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

Reply via email to