[clang] Warning Libc functions (PR #101583)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 13 15:16:38 PDT 2024
================
@@ -2292,6 +2292,18 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
}
}
+ void handleUnsafeLibcCall(const CallExpr *Call, unsigned PrintfInfo,
+ ASTContext &Ctx) override {
+ // We have checked that there is a direct callee with an identifier name:
+ StringRef Name = Call->getDirectCallee()->getName();
+
+ S.Diag(Call->getBeginLoc(), diag::warn_unsafe_buffer_libc_call)
+ << Name << Call->getSourceRange();
----------------
haoNoQ wrote:
Just pass `const Decl *D = Call->getDirectCallee()` directly into `S.Diag()`. It even automatically adds quotes around the name this way.
https://github.com/llvm/llvm-project/pull/101583
More information about the cfe-commits
mailing list