[clang] Warning for unsafe invocation of span::data (PR #75650)

Malavika Samak via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 15:33:08 PST 2023


================
@@ -2261,6 +2261,21 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
         // note_unsafe_buffer_operation doesn't have this mode yet.
         assert(!IsRelatedToDecl && "Not implemented yet!");
         MsgParam = 3;
+      } else if (const auto *ECE = dyn_cast<ExplicitCastExpr>(Operation)) {
+        QualType destType = ECE->getType();
+        const uint64_t dSize = Ctx.getTypeSize(destType.getTypePtr()->getPointeeType());
+        if(const auto *CE =dyn_cast<CXXMemberCallExpr>(ECE->getSubExpr())) {
+
+          if(CE->getRecordDecl()->getQualifiedNameAsString().compare("std::span"))
----------------
malavikasamak wrote:

Hmmm. I think it shouldn't be an issue as we are getting the qualified name. However, I will add a test case to check this.

https://github.com/llvm/llvm-project/pull/75650


More information about the cfe-commits mailing list