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

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 11:02:03 PST 2021


cjdb added a subscriber: rsmith.
cjdb added inline comments.


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


================
Comment at: clang/lib/Sema/SemaChecking.cpp:10326
+      !isa<IntegerLiteral>(
+          Cast->getSubExpr()->IgnoreImplicitAsWritten()->IgnoreParens()))
+    return;
----------------
aaron.ballman wrote:
> 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.)
@rsmith would you mind weighing in here please? My original use-case for `IgnoreImplicitAsWritten` might be different to here and I don't have an answer for @aaron.ballman.


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


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