blob: e7a51a4995c4edacc92d1f0dca13b5a8c6bb1802 [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"
26#include "base/variant_map.h"
27
28namespace art {
29
30template <typename TValue>
31struct SimpleParseArgumentMapKey : VariantMapKey<TValue> {
32 SimpleParseArgumentMapKey() {}
33 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
39struct 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
49using Parser = CmdlineParser<SimpleParseArgumentMap, SimpleParseArgumentMapKey>;
50
51static inline Parser CreateSimpleParser(bool ignore_unrecognized) {
52 std::unique_ptr<Parser::Builder> parser_builder =
Yi Kongc57c6802018-10-29 14:28:56 -070053 std::make_unique<Parser::Builder>();
Andreas Gampe097f34c2017-08-23 08:57:51 -070054
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_