[clang] [compiler-rt] [libcxx] [clang] Add unistd fortify checks and analyzer size constraints (PR #196499)
Oliver Hunt via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 00:42:57 PDT 2026
================
@@ -1270,224 +1388,324 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
return FunctionName.str();
};
- switch (BuiltinID) {
- default:
- return;
- case Builtin::BI__builtin_strcat:
- case Builtin::BIstrcat:
- case Builtin::BI__builtin_stpcpy:
- case Builtin::BIstpcpy:
- case Builtin::BI__builtin_strcpy:
- case Builtin::BIstrcpy: {
- DiagID = diag::warn_fortify_strlen_overflow;
- SourceSize = ComputeStrLenArgument(1);
+ if (LibC == LibCDispatch::Read) {
----------------
ojhunt wrote:
I _think_ if you did actually use a meta type rather than a function type this could be cleaned up as well, e.g
```cpp
struct LibcFuncType {
QualType ExpectedReturn;
SmallVec<QualType> Params;
std::optional<unsigned> SourceSizeIdx;
std::optional<unsigned> MaxOperationSizeIdx;
std::optional<unsigned> DestinationSizeIdx;
}
```
As your expected "function type" would make this logic become
```cpp
if (LibC) {
if (auto SrcSizeIdx = libcFuncType.SourceSizeIdx)
SourceSize = ComputeSizeArgument(*SrcSizeIdx);
...
```
Maybe the enum itself could be dropped even.
https://github.com/llvm/llvm-project/pull/196499
More information about the llvm-commits
mailing list