[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
This commit is contained in:
Roman Lebedev 2019-05-05 21:26:32 +00:00
parent 8462cc3c74
commit ee1431072e
2 changed files with 8 additions and 8 deletions

View File

@ -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());

View File

@ -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
}
}