• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 "compiler_logger.h"
17 
18 namespace ark::compiler {
19 std::bitset<CompilerLoggerComponents::LOG_COMPONENTS_NUM> CompilerLogger::components_(0);
20 
21 // clang-format off
22 /* static */
SetComponents(const std::vector<std::string> & args)23 void CompilerLogger::SetComponents(const std::vector<std::string>& args)
24 {
25     components_.reset();
26     for (const auto& arg : args) {
27         if (arg == "all") {
28             components_.set();
29             break;
30         }
31         if (arg == "none") {
32             components_.reset();
33             break;
34         }
35 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
36 #define CONTINUE_DEF(COMPONENT, NAME)       \
37             if ((NAME) == arg) {            \
38                 components_.set(COMPONENT); \
39                 continue;                   \
40             }
41         COMPILER_LOG_COMPONENTS(CONTINUE_DEF)
42 #undef CONTINUE_DEF
43 
44         UNREACHABLE();
45     }
46 }
47 // clang-format on
48 }  // namespace ark::compiler
49