sbenza added inline comments.

================
Comment at: include/clang/AST/ASTTypeTraits.h:250
@@ +249,3 @@
+    return NodeKind.hasPointerIdentity()
+               ? *reinterpret_cast<void *const *>(Storage.buffer)
+               : nullptr;
----------------
I'm not sure about this reinterpret_cast.
We are not storing void*. We are storing 'const Node*'.
I think this way is UB.

Maybe we should modify the union and the create/getUnchecked methods to use 
'const void*' as storage instead.
Instead of:

```
new (Result.Storage.buffer) const BaseT * (&Node);
...
return *cast<T>(*reinterpret_cast<BaseT *const *>(Storage));
```
we should do

```
new (Result.Storage.buffer) const void * (static_cast<const BaseT*>(&Node));
...
return *cast<T>(static_cast<const BaseT*>(*reinterpret_cast<const void *const 
*>(Storage)));
```





http://reviews.llvm.org/D13946



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to