[clang] [ASTContext] Add a break to nested switch in `encodeTypeForFunctionPointerAuth` (PR #99763)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 11:06:49 PDT 2024
================
@@ -3363,6 +3363,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
#include "clang/Basic/RISCVVTypes.def"
llvm_unreachable("not yet implemented");
}
+ break;
----------------
AaronBallman wrote:
My thinking was: if we add the `llvm_unreachable` as the last statement in the case for `Type::Builtin`, then any case in the nested switch which does not return will eventually hit that unreachable and be caught as a bug rather than falling through. If someone adds a new case to the nested switch, this still happens.
As for the diagnostic, it's off by default (https://godbolt.org/z/PPs993TT9) but is something we explicitly opt into for the project to help us catch bugs: https://github.com/llvm/llvm-project/blob/bee2654300a8f524e05dd4cad41411d597246ac0/llvm/cmake/modules/HandleLLVMOptions.cmake#L824
https://github.com/llvm/llvm-project/pull/99763
More information about the cfe-commits
mailing list