Author: lebedevri Date: Sun May 5 14:26:32 2019 New Revision: 360002 URL: http://llvm.org/viewvc/llvm-project?rev=360002&view=rev Log: [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. Modified: clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp Modified: clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp?rev=360002&r1=360001&r2=360002&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp Sun May 5 14:26:32 2019 @@ -73,7 +73,7 @@ void ExceptionEscapeCheck::check(const M // 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()); Modified: clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp?rev=360002&r1=360001&r2=360002&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp Sun May 5 14:26:32 2019 @@ -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 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 } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits