teak-llvm/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.h
Roman Lebedev 462446fd9a [clang-tidy] openmp-exception-escape - a new check
Summary:
Finally, we are here!

Analyzes OpenMP Structured Blocks and checks that no exception escapes
out of the Structured Block it was thrown in.

As per the OpenMP specification, structured block is an executable statement,
possibly compound, with a single entry at the top and a single exit at the
bottom. Which means, ``throw`` may not be used to to 'exit' out of the
structured block. If an exception is not caught in the same structured block
it was thrown in, the behaviour is undefined / implementation defined,
the program will likely terminate.

Reviewers: JonasToth, aaron.ballman, baloghadamsoftware, gribozavr

Reviewed By: aaron.ballman, gribozavr

Subscribers: mgorny, xazax.hun, rnkovacs, guansong, jdoerfert, cfe-commits, ABataev

Tags: #clang-tools-extra, #openmp, #clang

Differential Revision: https://reviews.llvm.org/D59466

llvm-svn: 356802
2019-03-22 19:46:25 +00:00

42 lines
1.4 KiB
C++

//===--- ExceptionEscapeCheck.h - clang-tidy --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OPENMP_EXCEPTIONESCAPECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OPENMP_EXCEPTIONESCAPECHECK_H
#include "../ClangTidy.h"
#include "../utils/ExceptionAnalyzer.h"
namespace clang {
namespace tidy {
namespace openmp {
/// Analyzes OpenMP Structured Blocks and checks that no exception escapes
/// out of the Structured Block it was thrown in.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/openmp-exception-escape.html
class ExceptionEscapeCheck : public ClangTidyCheck {
public:
ExceptionEscapeCheck(StringRef Name, ClangTidyContext *Context);
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
std::string RawIgnoredExceptions;
utils::ExceptionAnalyzer Tracer;
};
} // namespace openmp
} // namespace tidy
} // namespace clang
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OPENMP_EXCEPTIONESCAPECHECK_H