blob: 6663c0c509d95f0885f650b11a1ff23ede9f45fa [file] [log] [blame]
Andreas Gampe097f34c2017-08-23 08:57:51 -07001/*
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"
Vladimir Markobdbee062022-11-16 12:44:15 +000026#include "base/macros.h"
Andreas Gampe097f34c2017-08-23 08:57:51 -070027#include "base/variant_map.h"
28
Vladimir Markobdbee062022-11-16 12:44:15 +000029namespace art HIDDEN {
Andreas Gampe097f34c2017-08-23 08:57:51 -070030
31template <typename TValue>
32struct SimpleParseArgumentMapKey : VariantMapKey<TValue> {
33 SimpleParseArgumentMapKey() {}
34 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
40struct 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
50using Parser = CmdlineParser<SimpleParseArgumentMap, SimpleParseArgumentMapKey>;
51
52static inline Parser CreateSimpleParser(bool ignore_unrecognized) {
53 std::unique_ptr<Parser::Builder> parser_builder =
Yi Kongc57c6802018-10-29 14:28:56 -070054 std::make_unique<Parser::Builder>();
Andreas Gampe097f34c2017-08-23 08:57:51 -070055
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_