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