[PATCH] D15120: Add support for __float128 type to be used by targets that support it

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 15:52:10 PST 2016


hubert.reinterpretcast added inline comments.

================
Comment at: lib/Sema/SemaExpr.cpp:1156-1159
@@ +1155,6 @@
+
+  QualType LHSElemType = dyn_cast<ComplexType>(LHSType) ?
+    cast<ComplexType>(LHSType)->getElementType() : LHSType;
+  QualType RHSElemType = dyn_cast<ComplexType>(RHSType) ?
+    cast<ComplexType>(RHSType)->getElementType() : RHSType;
+
----------------
rsmith wrote:
> hubert.reinterpretcast wrote:
> > The result of the `dyn_cast` can be saved instead of using `cast` after the `dyn_cast`.
> Do not use `dyn_cast` / `cast` on types, use `LHSType->getAs<...>()` / `LHSType->castAs<...>()` instead. This will do the wrong thing on sugared types (eg, a typedef for a complex type).
Are there contexts in Clang where sugared types don't occur? Is the general guidance to use `getAs` or `castAs` even if the types are known to be canonical (which I agree isn't the case here)?


Repository:
  rL LLVM

http://reviews.llvm.org/D15120





More information about the cfe-commits mailing list