1 /** 2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "scope_init_test.h" 17 #include "ir/expression.h" 18 #include "ir/statements/blockStatement.h" 19 #include "ir/statements/variableDeclarator.h" 20 #include "ir/statements/variableDeclaration.h" 21 22 namespace test::utils { 23 BodyToFirstName(ir_alias::Statement * body)24ir_alias::Identifier *ScopeInitTest::BodyToFirstName(ir_alias::Statement *body) 25 { 26 return body->AsBlockStatement() 27 ->Statements() 28 .front() 29 ->AsVariableDeclaration() 30 ->Declarators() 31 .front() 32 ->Id() 33 ->AsIdentifier(); 34 } 35 36 } // namespace test::utils