summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 21:26:32 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 21:26:32 +0000
commitfc53191b76471391dc3fb1e46cfc96cf8ab9c2ff (patch)
tree81197f506edacb4334b2e9b155140656d62f7a89
parent77dd14cd303c5d4468895378e12361921e75e201 (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360002 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clang-tidy/openmp/ExceptionEscapeCheck.cpp2
-rw-r--r--test/clang-tidy/openmp-exception-escape.cpp14
2 files changed, 8 insertions, 8 deletions
diff --git a/clang-tidy/openmp/ExceptionEscapeCheck.cpp b/clang-tidy/openmp/ExceptionEscapeCheck.cpp
index 218437a6..c3894a6c 100644
--- a/clang-tidy/openmp/ExceptionEscapeCheck.cpp
+++ b/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/test/clang-tidy/openmp-exception-escape.cpp b/test/clang-tidy/openmp-exception-escape.cpp
index d620b5c9..73345836 100644
--- a/test/clang-tidy/openmp-exception-escape.cpp
+++ b/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
}
}