[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue May 27 07:56:43 PDT 2025
================
@@ -4410,6 +4409,21 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
Handlers);
}
+void Sema::DiagnoseExceptionUse(SourceLocation Loc, bool IsTry) {
+ const llvm::Triple &T = Context.getTargetInfo().getTriple();
+ const bool IsOpenMPGPUTarget =
+ getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
+
+ if (IsOpenMPGPUTarget || getLangOpts().CUDA)
+ return;
+
+ if (!getLangOpts().CXXExceptions &&
+ !getSourceManager().isInSystemHeader(Loc) &&
+ !CurContext->isDependentContext()) {
----------------
erichkeane wrote:
Don't use curley braces on single-line `if` bodies.
https://github.com/llvm/llvm-project/pull/139859
More information about the cfe-commits
mailing list