1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // This file declares a completion of the CompilerOptionsMap and should be included into a 18 // .cc file, only. 19 20 #ifndef ART_COMPILER_DRIVER_SIMPLE_COMPILER_OPTIONS_MAP_H_ 21 #define ART_COMPILER_DRIVER_SIMPLE_COMPILER_OPTIONS_MAP_H_ 22 23 #include <memory> 24 25 #include "compiler_options_map-inl.h" 26 #include "base/macros.h" 27 #include "base/variant_map.h" 28 29 namespace art HIDDEN { 30 31 template <typename TValue> 32 struct SimpleParseArgumentMapKey : VariantMapKey<TValue> { SimpleParseArgumentMapKeySimpleParseArgumentMapKey33 SimpleParseArgumentMapKey() {} SimpleParseArgumentMapKeySimpleParseArgumentMapKey34 explicit SimpleParseArgumentMapKey(TValue default_value) 35 : VariantMapKey<TValue>(std::move(default_value)) {} 36 // Don't ODR-use constexpr default values, which means that Struct::Fields 37 // that are declared 'static constexpr T Name = Value' don't need to have a matching definition. 38 }; 39 40 struct SimpleParseArgumentMap : CompilerOptionsMap<SimpleParseArgumentMap, 41 SimpleParseArgumentMapKey> { 42 // This 'using' line is necessary to inherit the variadic constructor. 43 using CompilerOptionsMap<SimpleParseArgumentMap, SimpleParseArgumentMapKey>::CompilerOptionsMap; 44 }; 45 46 #define COMPILER_OPTIONS_MAP_TYPE SimpleParseArgumentMap 47 #define COMPILER_OPTIONS_MAP_KEY_TYPE SimpleParseArgumentMapKey 48 #include "compiler_options_map-storage.h" 49 50 using Parser = CmdlineParser<SimpleParseArgumentMap, SimpleParseArgumentMapKey>; 51 CreateSimpleParser(bool ignore_unrecognized)52static inline Parser CreateSimpleParser(bool ignore_unrecognized) { 53 std::unique_ptr<Parser::Builder> parser_builder = 54 std::make_unique<Parser::Builder>(); 55 56 AddCompilerOptionsArgumentParserOptions<SimpleParseArgumentMap>(*parser_builder); 57 58 parser_builder->IgnoreUnrecognized(ignore_unrecognized); 59 60 return parser_builder->Build(); 61 } 62 63 } // namespace art 64 65 #endif // ART_COMPILER_DRIVER_SIMPLE_COMPILER_OPTIONS_MAP_H_ 66