[LLD][COFF] Emit tail merge pdata for delay load thunks on ARM64EC (#116810)
[llvm-project.git] / mlir / unittests / IR / LocationTest.cpp
blob03374ee0b8467b826a16fb6fbca19b7c0c48f29b
1 //===- LocationTest.cpp - unit tests for affine map API -------------------===//
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/Location.h"
10 #include "mlir/IR/Builders.h"
11 #include "gtest/gtest.h"
13 using namespace mlir;
15 // Check that we only walk *locations* and not non-location attributes.
16 TEST(LocationTest, Walk) {
17 MLIRContext ctx;
18 Builder builder(&ctx);
19 BoolAttr trueAttr = builder.getBoolAttr(true);
21 Location loc1 = FileLineColLoc::get(builder.getStringAttr("foo"), 1, 2);
22 Location loc2 = FileLineColLoc::get(builder.getStringAttr("foo"), 3, 4);
23 Location fused = builder.getFusedLoc({loc1, loc2}, trueAttr);
25 SmallVector<Attribute> visited;
26 fused->walk([&](Location l) {
27 visited.push_back(LocationAttr(l));
28 return WalkResult::advance();
29 });
31 EXPECT_EQ(llvm::ArrayRef(visited), ArrayRef<Attribute>({fused, loc1, loc2}));
34 // Check that we skip location attrs nested under a non-location attr.
35 TEST(LocationTest, SkipNested) {
36 MLIRContext ctx;
37 Builder builder(&ctx);
39 Location loc1 = FileLineColLoc::get(builder.getStringAttr("foo"), 1, 2);
40 Location loc2 = FileLineColLoc::get(builder.getStringAttr("foo"), 3, 4);
41 Location loc3 = FileLineColLoc::get(builder.getStringAttr("bar"), 1, 2);
42 Location loc4 = FileLineColLoc::get(builder.getStringAttr("bar"), 3, 4);
43 ArrayAttr arr = builder.getArrayAttr({loc3, loc4});
44 Location fused = builder.getFusedLoc({loc1, loc2}, arr);
46 SmallVector<Attribute> visited;
47 fused->walk([&](Location l) {
48 visited.push_back(LocationAttr(l));
49 return WalkResult::advance();
50 });
52 EXPECT_EQ(llvm::ArrayRef(visited), ArrayRef<Attribute>({fused, loc1, loc2}));