Revert "[clang-repl] Enable native CPU detection by default (#77491)" (#79178)
[llvm-project.git] / mlir / unittests / Pass / PassPipelineParserTest.cpp
blob4aa35af5c277c3e6a3d4861770f618268c90f8ec
1 //===- PassPipelineParserTest.cpp - Pass Parser unit tests ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "mlir/IR/Builders.h"
10 #include "mlir/IR/BuiltinOps.h"
11 #include "mlir/Pass/Pass.h"
12 #include "mlir/Pass/PassManager.h"
13 #include "mlir/Pass/PassRegistry.h"
14 #include "llvm/Support/raw_ostream.h"
15 #include "gtest/gtest.h"
17 #include <memory>
19 using namespace mlir;
20 using namespace mlir::detail;
22 namespace {
23 TEST(PassPipelineParserTest, InvalidOpAnchor) {
24 // Helper functor used to parse a pipeline and check that it results in the
25 // provided error message.
26 auto checkParseFailure = [](StringRef pipeline, StringRef expectedErrorMsg) {
27 std::string errorMsg;
29 llvm::raw_string_ostream os(errorMsg);
30 FailureOr<OpPassManager> result = parsePassPipeline(pipeline, os);
31 EXPECT_TRUE(failed(result));
33 EXPECT_TRUE(StringRef(errorMsg).contains(expectedErrorMsg));
36 // Handle parse errors when the anchor is incorrectly structured.
37 StringRef anchorErrorMsg =
38 "expected pass pipeline to be wrapped with the anchor operation type";
39 checkParseFailure("module", anchorErrorMsg);
40 checkParseFailure("()", anchorErrorMsg);
41 checkParseFailure("module(", anchorErrorMsg);
42 checkParseFailure("module)", anchorErrorMsg);
45 } // namespace