• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tudasc / TypeART / 12904858633

22 Jan 2025 09:11AM UTC coverage: 90.735% (+0.005%) from 90.73%
12904858633

Pull #149

github

web-flow
Merge f0a5eda87 into 37d7f8cb1
Pull Request #149: Replace llvm::Optional with std::optional

88 of 102 new or added lines in 23 files covered. (86.27%)

1 existing line in 1 file now uncovered.

3829 of 4220 relevant lines covered (90.73%)

117945.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/lib/passes/TypeARTConfiguration.cpp
1
// TypeART library
2
//
3
// Copyright (c) 2017-2025 TypeART Authors
4
// Distributed under the BSD 3-Clause license.
5
// (See accompanying file LICENSE.txt or copy at
6
// https://opensource.org/licenses/BSD-3-Clause)
7
//
8
// Project home: https://github.com/tudasc/TypeART
9
//
10
// SPDX-License-Identifier: BSD-3-Clause
11
//
12

13
#include "TypeARTConfiguration.h"
14

15
#include "Commandline.h"
16
#include "support/FileConfiguration.h"
17

18
namespace typeart::config {
19

20
TypeARTConfiguration::TypeARTConfiguration(std::unique_ptr<file::FileOptions> config_options,
72✔
21
                                           std::unique_ptr<cl::CommandLineOptions> commandline_options)
22
    : configuration_options_(std::move(config_options)), commandline_options_(std::move(commandline_options)) {
72✔
23
}
36✔
24

NEW
25
std::optional<OptionValue> TypeARTConfiguration::getValue(std::string_view opt_path) const {
×
26
  const bool use_cl = prioritize_commandline && commandline_options_->valueSpecified(opt_path);
×
27
  if (use_cl) {
×
28
    LOG_DEBUG("Take CL arg for " << opt_path.data())
29
    return commandline_options_->getValue(opt_path);
×
30
  }
31
  return configuration_options_->getValue(opt_path);
×
32
}
×
33

34
OptionValue TypeARTConfiguration::getValueOr(std::string_view opt_path, OptionValue alt) const {
96✔
35
  const bool use_cl = prioritize_commandline && commandline_options_->valueSpecified(opt_path);
60✔
36
  if (use_cl) {
60✔
37
    LOG_DEBUG("Take CL arg for " << opt_path.data())
38
    return commandline_options_->getValueOr(opt_path, alt);
30✔
39
  }
40
  return configuration_options_->getValueOr(opt_path, alt);
30✔
41
}
60✔
42

43
OptionValue TypeARTConfiguration::operator[](std::string_view opt_path) const {
600✔
44
  const bool use_cl = prioritize_commandline && commandline_options_->valueSpecified(opt_path);
600✔
45
  if (use_cl) {
600✔
46
    LOG_DEBUG("Take CL arg for " << opt_path.data())
47
    return commandline_options_->operator[](opt_path);
150✔
48
  }
49
  return configuration_options_->operator[](opt_path);
450✔
50
}
600✔
51

52
void TypeARTConfiguration::prioritizeCommandline(bool do_prioritize) {
36✔
53
  prioritize_commandline = do_prioritize;
36✔
54
}
36✔
55

56
void TypeARTConfiguration::emitTypeartFileConfiguration(llvm::raw_ostream& out_stream) {
36✔
57
  out_stream << configuration_options_->getConfigurationAsString();
36✔
58
}
36✔
59

60
llvm::ErrorOr<std::unique_ptr<TypeARTConfiguration>> make_typeart_configuration(const TypeARTConfigInit& init) {
42✔
61
  auto file_opts = init.mode != TypeARTConfigInit::FileConfigurationMode::Empty
42✔
62
                       ? config::file::make_file_configuration(init.file_path)
36✔
63
                       : config::file::make_default_file_configuration();
6✔
64
  if (file_opts) {
42✔
65
    auto cl_opts = std::make_unique<config::cl::CommandLineOptions>();
36✔
66
    auto config  = std::make_unique<config::TypeARTConfiguration>(std::move(file_opts.get()), std::move(cl_opts));
36✔
67
    config->prioritizeCommandline(true);
36✔
68
    return config;
36✔
69
  }
36✔
70
  LOG_FATAL("Could not initialize file configuration: \'" << init.file_path
6✔
71
                                                          << "\'. Reason: " << file_opts.getError().message())
72
  return file_opts.getError();
6✔
73
}
42✔
74

75
}  // namespace typeart::config
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc