================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits