[clang] [Clang] fix range calculation for conditionals with throw expressions (PR #112081)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 09:40:24 PDT 2024


================
@@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth,
     return IntRange(BitField->getBitWidthValue(C),
                     BitField->getType()->isUnsignedIntegerOrEnumerationType());
 
----------------
a-tarasyuk wrote:

@shafik Getting the expression range for a void type isn't handled at this stage

https://github.com/llvm/llvm-project/blob/bf1a554312bd011cb2016a2c9d7e75d6fe3b02af/clang/lib/Sema/SemaChecking.cpp#L9628-L9631

Throw expressions can be handled if `CondResult` isn't treated as a boolean

https://github.com/llvm/llvm-project/blob/bf1a554312bd011cb2016a2c9d7e75d6fe3b02af/clang/lib/Sema/SemaChecking.cpp#L9633-L9644

It seems this case could be handled either before

https://github.com/llvm/llvm-project/blob/bf1a554312bd011cb2016a2c9d7e75d6fe3b02af/clang/lib/Sema/SemaChecking.cpp#L9629-L9631

or by adding a condition in the recursion call to handle void types. Which approach do you think is better? Thanks







https://github.com/llvm/llvm-project/pull/112081


More information about the cfe-commits mailing list