[PATCH] D97512: [clang] removes check against integral-to-pointer conversion...

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 10:13:52 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:10320
+
+  const clang::CastKind Kind = Cast->getCastKind();
+  if (Kind == clang::CK_BitCast &&
----------------
We don't typically use top-level `const` on locals or params.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:10326
+      !isa<IntegerLiteral>(
+          Cast->getSubExpr()->IgnoreImplicitAsWritten()->IgnoreParens()))
+    return;
----------------
I'm not 100% certain, but would `IgnoreParenImpCasts()` be sufficient here? (`IgnoreImplicitAsWritten() seems to be a bit special -- the only use of it I can find in tree is for rewritten binary operator expressions.)


================
Comment at: clang/test/Analysis/free.cpp:221
+void t18b (S s) {
+  std::free((void*)(unsigned long long)s.p); // no warning
+}
----------------
I think it'd be useful to add tests for named casts as well as the C-style casts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97512/new/

https://reviews.llvm.org/D97512



More information about the cfe-commits mailing list