[clang] [Clang] [Sema] Ensure noexcept(typeid(E)) checks if E throws when needed (PR #95846)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 21:57:11 PDT 2024
================
@@ -1111,13 +1111,18 @@ static CanThrowResult canDynamicCastThrow(const CXXDynamicCastExpr *DC) {
}
static CanThrowResult canTypeidThrow(Sema &S, const CXXTypeidExpr *DC) {
- if (DC->isTypeOperand())
+ // Operand is not evaluated, cannot possibly throw
+ if (!DC->isPotentiallyEvaluated())
return CT_Cannot;
if (DC->isValueDependent())
return CT_Dependent;
- return DC->hasNullCheck() ? CT_Can : CT_Cannot;
+ // Can throw std::bad_typeid if a nullptr is dereferenced
----------------
tbaederr wrote:
```suggestion
// Can throw std::bad_typeid if a nullptr is dereferenced.
```
https://github.com/llvm/llvm-project/pull/95846
More information about the cfe-commits
mailing list