[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / flang / unittests / Optimizer / Builder / Runtime / CommandTest.cpp
blobacc79ae63e9f698380b938206671d1b03dc08d33
1 //===- CommandTest.cpp -- command line runtime builder 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 "flang/Optimizer/Builder/Runtime/Command.h"
10 #include "RuntimeCallTestBase.h"
11 #include "gtest/gtest.h"
13 TEST_F(RuntimeCallTest, genCommandArgumentCountTest) {
14 mlir::Location loc = firBuilder->getUnknownLoc();
15 mlir::Value result = fir::runtime::genCommandArgumentCount(*firBuilder, loc);
16 checkCallOp(result.getDefiningOp(), "_FortranAArgumentCount", /*nbArgs=*/0,
17 /*addLocArgs=*/false);
20 TEST_F(RuntimeCallTest, genGetCommandArgument) {
21 mlir::Location loc = firBuilder->getUnknownLoc();
22 mlir::Type intTy = firBuilder->getDefaultIntegerType();
23 mlir::Type boxTy = fir::BoxType::get(firBuilder->getNoneType());
24 mlir::Value number = firBuilder->create<fir::UndefOp>(loc, intTy);
25 mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
26 mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
27 mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
28 mlir::Value result = fir::runtime::genGetCommandArgument(
29 *firBuilder, loc, number, value, length, errmsg);
30 checkCallOp(result.getDefiningOp(), "_FortranAGetCommandArgument",
31 /*nbArgs=*/4,
32 /*addLocArgs=*/true);
35 TEST_F(RuntimeCallTest, genGetEnvVariable) {
36 mlir::Location loc = firBuilder->getUnknownLoc();
37 mlir::Value name = firBuilder->create<fir::UndefOp>(loc, boxTy);
38 mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
39 mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
40 mlir::Value trimName = firBuilder->create<fir::UndefOp>(loc, i1Ty);
41 mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
42 mlir::Value result = fir::runtime::genGetEnvVariable(
43 *firBuilder, loc, name, value, length, trimName, errmsg);
44 checkCallOp(result.getDefiningOp(), "_FortranAGetEnvVariable", /*nbArgs=*/5,
45 /*addLocArgs=*/true);