<commit_before>//===- unittests/AST/OMPStructuredBlockTest.cpp ---------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Fine-grained tests for IsOMPStructuredBlock bit of Stmt.
//
//===----------------------------------------------------------------------===//

#include "ASTPrint.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/SmallString.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

using namespace clang;
using namespace ast_matchers;
using namespace tooling;

namespace {

AST_MATCHER(Stmt, isOMPStructuredBlock) { return Node.isOMPStructuredBlock(); }

const ast_matchers::internal::VariadicDynCastAllOfMatcher<
    OMPExecutableDirective, OMPTargetDirective>
    ompTargetDirective;

StatementMatcher OMPInnermostStructuredBlockMatcher() {
  return stmt(isOMPStructuredBlock(),
              unless(hasDescendant(stmt(isOMPStructuredBlock()))))
      .bind("id");
}

AST_MATCHER(OMPExecutableDirective, isStandaloneDirective) {
  return Node.isStandaloneDirective();
}

StatementMatcher OMPStandaloneDirectiveMatcher() {
  return stmt(ompExecutableDirective(isStandaloneDirective())).bind("id");
}

template <typename T>
::testing::AssertionResult
PrintedOMPStmtMatches(StringRef Code, const T &NodeMatch,
                      StringRef ExpectedPrinted,
                      PolicyAdjusterType PolicyAdjuster = None) {
  std::vector<std::string> Args = {
      "-fopenmp=libomp",
  };
  return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted,
                            PolicyAdjuster);
}

static testing::AssertionResult NoMatches(StringRef Code,
                                          const StatementMatcher &StmtMatch) {
  PrintMatch Printer((PolicyAdjusterType()));<commit_msg>[AST] OMPStructuredBlockTest: two matchers were promoted into ASTMatchers.h<commit_after>//===- unittests/AST/OMPStructuredBlockTest.cpp ---------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Fine-grained tests for IsOMPStructuredBlock bit of Stmt.
//
//===----------------------------------------------------------------------===//

#include "ASTPrint.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/SmallString.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

using namespace clang;
using namespace ast_matchers;
using namespace tooling;

namespace {

const ast_matchers::internal::VariadicDynCastAllOfMatcher<
    OMPExecutableDirective, OMPTargetDirective>
    ompTargetDirective;

StatementMatcher OMPInnermostStructuredBlockMatcher() {
  return stmt(isOMPStructuredBlock(),
              unless(hasDescendant(stmt(isOMPStructuredBlock()))))
      .bind("id");
}

StatementMatcher OMPStandaloneDirectiveMatcher() {
  return stmt(ompExecutableDirective(isStandaloneDirective())).bind("id");
}

template <typename T>
::testing::AssertionResult
PrintedOMPStmtMatches(StringRef Code, const T &NodeMatch,
                      StringRef ExpectedPrinted,
                      PolicyAdjusterType PolicyAdjuster = None) {
  std::vector<std::string> Args = {
      "-fopenmp=libomp",
  };
  return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted,
                            PolicyAdjuster);
}

static testing::AssertionResult NoMatches(StringRef Code,
                                          const StatementMatcher &StmtMatch) {
  PrintMatch Printer((PolicyAdjusterType()));
{'fraction_non_alphanumeric': 0.19259617711105734, 'fraction_numerical': 0.0019356399709654004, 'mean_word_length': 2.7787934186471666, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355774', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1201, 'n_words': 224}