[PATCH] D110586: Update `DynTypedNode` to support the conversion of `TypeLoc`s.

Samuel Benzaquen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 30 10:37:01 PDT 2021


sbenza added inline comments.


================
Comment at: clang/include/clang/AST/ASTTypeTraits.h:472
+      assert(ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind));
+      return *static_cast<const T *>(reinterpret_cast<const BaseT *>(Storage));
+    }
----------------
The create/get don't seem to match.
We are constructing a `BaseT` object in `create()`, so this `static_cast` to a derived type is UB?
That memory does not contain a `T`.

If we instead construct a `T` in `create()`, we should be able to read it as a `BaseT*` (assuming `is_pointer_interconvertible_base_of<BaseT, T>` is true)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110586



More information about the cfe-commits mailing list