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/variant_map.h"
27 
28 namespace art {
29 
30 template <typename TValue>
31 struct SimpleParseArgumentMapKey : VariantMapKey<TValue> {
SimpleParseArgumentMapKeySimpleParseArgumentMapKey32   SimpleParseArgumentMapKey() {}
SimpleParseArgumentMapKeySimpleParseArgumentMapKey33   explicit SimpleParseArgumentMapKey(TValue default_value)
34       : VariantMapKey<TValue>(std::move(default_value)) {}
35   // Don't ODR-use constexpr default values, which means that Struct::Fields
36   // that are declared 'static constexpr T Name = Value' don't need to have a matching definition.
37 };
38 
39 struct SimpleParseArgumentMap : CompilerOptionsMap<SimpleParseArgumentMap,
40                                                    SimpleParseArgumentMapKey> {
41   // This 'using' line is necessary to inherit the variadic constructor.
42   using CompilerOptionsMap<SimpleParseArgumentMap, SimpleParseArgumentMapKey>::CompilerOptionsMap;
43 };
44 
45 #define COMPILER_OPTIONS_MAP_TYPE SimpleParseArgumentMap
46 #define COMPILER_OPTIONS_MAP_KEY_TYPE SimpleParseArgumentMapKey
47 #include "compiler_options_map-storage.h"
48 
49 using Parser = CmdlineParser<SimpleParseArgumentMap, SimpleParseArgumentMapKey>;
50 
CreateSimpleParser(bool ignore_unrecognized)51 static inline Parser CreateSimpleParser(bool ignore_unrecognized) {
52   std::unique_ptr<Parser::Builder> parser_builder =
53       std::unique_ptr<Parser::Builder>(new Parser::Builder());
54 
55   AddCompilerOptionsArgumentParserOptions<SimpleParseArgumentMap>(*parser_builder);
56 
57   parser_builder->IgnoreUnrecognized(ignore_unrecognized);
58 
59   return parser_builder->Build();
60 }
61 
62 }  // namespace art
63 
64 #endif  // ART_COMPILER_DRIVER_SIMPLE_COMPILER_OPTIONS_MAP_H_
65