1 /** 2 * Copyright (c) 2021-2022 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 panda::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)23void 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 DEF(COMPONENT, NAME) \ 37 if (NAME == arg) { \ 38 components.set(COMPONENT); \ 39 continue; \ 40 } 41 COMPILER_LOG_COMPONENTS(DEF) 42 #undef DEF 43 44 UNREACHABLE(); 45 } 46 } 47 // clang-format on 48 } // namespace panda::compiler 49