From ee1431072e3d139beef4aadd751bd9be0eb114c8 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sun, 5 May 2019 21:26:32 +0000 Subject: [PATCH] [clang-tidy] openmp-exception-escape check: point to the structured-block I'm not sure what i was thinking when i wrote it to point at the directive. It's at the very least confusing, and in the `for` is very misleading. We should point at the actual Stmt out of which the exception escapes, to highlight where it should be fixed e.g. via adding try-catch block. Yes, this breaks existing NOLINT, which is why this change needs to happen now, not any later. llvm-svn: 360002 --- .../clang-tidy/openmp/ExceptionEscapeCheck.cpp | 2 +- .../test/clang-tidy/openmp-exception-escape.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp index 218437a657b2..c3894a6c81ac 100644 --- a/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp +++ b/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp @@ -73,7 +73,7 @@ void ExceptionEscapeCheck::check(const MatchFinder::MatchResult &Result) { // FIXME: We should provide more information about the exact location where // the exception is thrown, maybe the full path the exception escapes. - diag(Directive->getBeginLoc(), + diag(StructuredBlock->getBeginLoc(), "an exception thrown inside of the OpenMP '%0' region is not caught in " "that same region") << getOpenMPDirectiveName(Directive->getDirectiveKind()); diff --git a/clang-tools-extra/test/clang-tidy/openmp-exception-escape.cpp b/clang-tools-extra/test/clang-tidy/openmp-exception-escape.cpp index d620b5c9ace2..733458369251 100644 --- a/clang-tools-extra/test/clang-tidy/openmp-exception-escape.cpp +++ b/clang-tools-extra/test/clang-tidy/openmp-exception-escape.cpp @@ -13,7 +13,7 @@ class bad_alloc {}; void parallel() { #pragma omp parallel thrower(); - // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region } void ignore() { @@ -57,7 +57,7 @@ void forloop(const int a) { #pragma omp for for (int i = 0; i < a; i++) thrower(); - // CHECK-MESSAGES: :[[@LINE-3]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region } void parallel_forloop(const int a) { @@ -67,8 +67,8 @@ void parallel_forloop(const int a) { for (int i = 0; i < a; i++) thrower(); thrower(); - // CHECK-MESSAGES: :[[@LINE-6]]:9: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region - // CHECK-MESSAGES: :[[@LINE-5]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-3]]:7: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region } } @@ -83,7 +83,7 @@ void parallel_forloop_caught(const int a) { } } thrower(); - // CHECK-MESSAGES: :[[@LINE-10]]:9: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-9]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region } } @@ -97,7 +97,7 @@ void parallel_caught_forloop(const int a) { thrower(); } catch (...) { } - // CHECK-MESSAGES: :[[@LINE-7]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-5]]:7: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region } } @@ -111,7 +111,7 @@ void parallel_outercaught_forloop(const int a) { thrower(); } catch (...) { } - // CHECK-MESSAGES: :[[@LINE-6]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region + // CHECK-MESSAGES: :[[@LINE-4]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region } }