summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-03-31 21:17:32 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-04-01 20:26:42 +0200
commit836f76e9c02acc00925f0b3ed2ba9ae9d379b823 (patch)
treed57a14c307b1c2598ac1fe9bba853c2f0d2bce5c
parent0b3c5f17de5af6b5f0520295d96eb21c6ebe5a60 (diff)
downloadccache-836f76e9c02acc00925f0b3ed2ba9ae9d379b823.tar.gz
refactor: Sort sloppiness parsing/generation
-rw-r--r--src/Config.cpp56
-rw-r--r--unittest/test_Config.cpp20
2 files changed, 38 insertions, 38 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index 09531ff7..ffc88597 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -267,7 +267,9 @@ parse_sloppiness(const std::string& value)
end = value.find_first_of(", ", start);
std::string token =
util::strip_whitespace(value.substr(start, end - start));
- if (token == "file_stat_matches") {
+ if (token == "clang_index_store") {
+ result.enable(core::Sloppy::clang_index_store);
+ } else if (token == "file_stat_matches") {
result.enable(core::Sloppy::file_stat_matches);
} else if (token == "file_stat_matches_ctime") {
result.enable(core::Sloppy::file_stat_matches_ctime);
@@ -275,20 +277,18 @@ parse_sloppiness(const std::string& value)
result.enable(core::Sloppy::include_file_ctime);
} else if (token == "include_file_mtime") {
result.enable(core::Sloppy::include_file_mtime);
- } else if (token == "system_headers" || token == "no_system_headers") {
- result.enable(core::Sloppy::system_headers);
- } else if (token == "pch_defines") {
- result.enable(core::Sloppy::pch_defines);
- } else if (token == "time_macros") {
- result.enable(core::Sloppy::time_macros);
- } else if (token == "clang_index_store") {
- result.enable(core::Sloppy::clang_index_store);
+ } else if (token == "ivfsoverlay") {
+ result.enable(core::Sloppy::ivfsoverlay);
} else if (token == "locale") {
result.enable(core::Sloppy::locale);
} else if (token == "modules") {
result.enable(core::Sloppy::modules);
- } else if (token == "ivfsoverlay") {
- result.enable(core::Sloppy::ivfsoverlay);
+ } else if (token == "pch_defines") {
+ result.enable(core::Sloppy::pch_defines);
+ } else if (token == "system_headers" || token == "no_system_headers") {
+ result.enable(core::Sloppy::system_headers);
+ } else if (token == "time_macros") {
+ result.enable(core::Sloppy::time_macros);
} // else: ignore unknown value for forward compatibility
start = value.find_first_not_of(", ", end);
}
@@ -299,17 +299,8 @@ std::string
format_sloppiness(core::Sloppiness sloppiness)
{
std::string result;
- if (sloppiness.is_enabled(core::Sloppy::include_file_mtime)) {
- result += "include_file_mtime, ";
- }
- if (sloppiness.is_enabled(core::Sloppy::include_file_ctime)) {
- result += "include_file_ctime, ";
- }
- if (sloppiness.is_enabled(core::Sloppy::time_macros)) {
- result += "time_macros, ";
- }
- if (sloppiness.is_enabled(core::Sloppy::pch_defines)) {
- result += "pch_defines, ";
+ if (sloppiness.is_enabled(core::Sloppy::clang_index_store)) {
+ result += "clang_index_store, ";
}
if (sloppiness.is_enabled(core::Sloppy::file_stat_matches)) {
result += "file_stat_matches, ";
@@ -317,11 +308,14 @@ format_sloppiness(core::Sloppiness sloppiness)
if (sloppiness.is_enabled(core::Sloppy::file_stat_matches_ctime)) {
result += "file_stat_matches_ctime, ";
}
- if (sloppiness.is_enabled(core::Sloppy::system_headers)) {
- result += "system_headers, ";
+ if (sloppiness.is_enabled(core::Sloppy::include_file_ctime)) {
+ result += "include_file_ctime, ";
}
- if (sloppiness.is_enabled(core::Sloppy::clang_index_store)) {
- result += "clang_index_store, ";
+ if (sloppiness.is_enabled(core::Sloppy::include_file_mtime)) {
+ result += "include_file_mtime, ";
+ }
+ if (sloppiness.is_enabled(core::Sloppy::ivfsoverlay)) {
+ result += "ivfsoverlay, ";
}
if (sloppiness.is_enabled(core::Sloppy::locale)) {
result += "locale, ";
@@ -329,8 +323,14 @@ format_sloppiness(core::Sloppiness sloppiness)
if (sloppiness.is_enabled(core::Sloppy::modules)) {
result += "modules, ";
}
- if (sloppiness.is_enabled(core::Sloppy::ivfsoverlay)) {
- result += "ivfsoverlay, ";
+ if (sloppiness.is_enabled(core::Sloppy::pch_defines)) {
+ result += "pch_defines, ";
+ }
+ if (sloppiness.is_enabled(core::Sloppy::system_headers)) {
+ result += "system_headers, ";
+ }
+ if (sloppiness.is_enabled(core::Sloppy::time_macros)) {
+ result += "time_macros, ";
}
if (!result.empty()) {
// Strip last ", ".
diff --git a/unittest/test_Config.cpp b/unittest/test_Config.cpp
index 1fed21c8..c5ff92ad 100644
--- a/unittest/test_Config.cpp
+++ b/unittest/test_Config.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2011-2022 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
@@ -169,15 +169,15 @@ TEST_CASE("Config::update_from_file")
CHECK(config.reshare());
CHECK_FALSE(config.run_second_cpp());
CHECK(config.sloppiness().to_bitmask()
- == (static_cast<uint32_t>(core::Sloppy::include_file_mtime)
- | static_cast<uint32_t>(core::Sloppy::include_file_ctime)
- | static_cast<uint32_t>(core::Sloppy::time_macros)
+ == (static_cast<uint32_t>(core::Sloppy::clang_index_store)
| static_cast<uint32_t>(core::Sloppy::file_stat_matches)
| static_cast<uint32_t>(core::Sloppy::file_stat_matches_ctime)
- | static_cast<uint32_t>(core::Sloppy::system_headers)
+ | static_cast<uint32_t>(core::Sloppy::include_file_ctime)
+ | static_cast<uint32_t>(core::Sloppy::include_file_mtime)
+ | static_cast<uint32_t>(core::Sloppy::ivfsoverlay)
| static_cast<uint32_t>(core::Sloppy::pch_defines)
- | static_cast<uint32_t>(core::Sloppy::clang_index_store)
- | static_cast<uint32_t>(core::Sloppy::ivfsoverlay)));
+ | static_cast<uint32_t>(core::Sloppy::system_headers)
+ | static_cast<uint32_t>(core::Sloppy::time_macros)));
CHECK_FALSE(config.stats());
CHECK(config.temporary_dir() == FMT("{}_foo", user));
CHECK(config.umask() == 0777u);
@@ -473,9 +473,9 @@ TEST_CASE("Config::visit_items")
"(test.conf) reshare = true",
"(test.conf) run_second_cpp = false",
"(test.conf) secondary_storage = ss",
- "(test.conf) sloppiness = include_file_mtime, include_file_ctime,"
- " time_macros, pch_defines, file_stat_matches, file_stat_matches_ctime,"
- " system_headers, clang_index_store, ivfsoverlay",
+ "(test.conf) sloppiness = clang_index_store, file_stat_matches,"
+ " file_stat_matches_ctime, include_file_ctime, include_file_mtime,"
+ " ivfsoverlay, pch_defines, system_headers, time_macros",
"(test.conf) stats = false",
"(test.conf) stats_log = sl",
"(test.conf) temporary_dir = td",