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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits