[clang] [clang][Sema] Add bounds checking for libc poll (PR #177286)
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 28 11:02:38 PST 2026
================
@@ -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};
+
+ if (Ctx.getTargetInfo().getTriple().isOSDarwin())
+ return {1024};
+
+ return std::nullopt;
+}
+
+/* Follow simple references to other macros so we can match the Expr spelling */
----------------
ziqingluo-90 wrote:
nit: this function could be useful for other checks so I'd like the comment to be a bit more clear:
- We do not have to mention "match the Expr spelling" since it is unrelated to this function.
- We could make it clear that this function follows the macro chain, where all macros are "simple"---having no arguments and are defined as an identifier of another macro. The function returns the first non-"simple" macro along the chain or nullptr if the chain is empty.
https://github.com/llvm/llvm-project/pull/177286
More information about the cfe-commits
mailing list