SERVER-101419 fix clang-tidy header regex (#32873)
GitOrigin-RevId: 7061f42a8773991dcf5661b9f421ca971e17aa18
This commit is contained in:
parent
d901d4f0e9
commit
1f4f3a27a7
@ -153,7 +153,7 @@ Checks: '-*,
|
||||
-readability-string-compare,
|
||||
-readability-uniqueptr-delete-release
|
||||
'
|
||||
HeaderFilterRegex: '(mongo/.*|@MONGO_BUILD_DIR@)'
|
||||
HeaderFilterRegex: 'mongo/[-A-Za-z0-9_/]*\.(h|hpp|ipp|inl|cstruct.h|defs|def.h)'
|
||||
CheckOptions:
|
||||
- key: bugprone-assert-side-effect.AssertMacros
|
||||
value: assert
|
||||
|
||||
22
SConstruct
22
SConstruct
@ -6,7 +6,6 @@ import errno
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import re
|
||||
import shlex
|
||||
@ -6974,27 +6973,6 @@ def injectMongoIncludePaths(thisEnv):
|
||||
|
||||
env.AddMethod(injectMongoIncludePaths, "InjectMongoIncludePaths")
|
||||
|
||||
gen_header_paths = [
|
||||
(pathlib.Path(env.Dir("$BAZEL_OUT_DIR").path) / "src" / "mongo").as_posix(),
|
||||
(pathlib.Path(env.Dir("$BUILD_DIR").path) / "mongo").as_posix(),
|
||||
]
|
||||
|
||||
replacements = {
|
||||
"@MONGO_BUILD_DIR@": (
|
||||
gen_header_paths[0] + "(?!.*\.pb\.h)" + "|" + gen_header_paths[1] + "/.*"
|
||||
),
|
||||
"@MONGO_BRACKET_BUILD_DIR@": (";".join(gen_header_paths)),
|
||||
}
|
||||
|
||||
clang_tidy_config = env.Substfile(
|
||||
target=".clang-tidy",
|
||||
source=[
|
||||
".clang-tidy.in",
|
||||
],
|
||||
SUBST_DICT=replacements,
|
||||
)
|
||||
env.Alias("generated-sources", clang_tidy_config)
|
||||
|
||||
if get_option("bazel-includes-info"):
|
||||
env.Tool("bazel_includes_info")
|
||||
|
||||
|
||||
@ -21,16 +21,16 @@ bazel_features_deps()
|
||||
|
||||
http_archive(
|
||||
name = "bazel_clang_tidy",
|
||||
sha256 = "f77f7f63fc43b6f7dba23f807132e24c36110d481826685ce49f38a04058c4ea",
|
||||
strip_prefix = "bazel_clang_tidy-1.5",
|
||||
integrity = "sha256-nar8iWq+4goJBEfmQZPWGsRlHdt+paVu5LY1WQ/BCZA=",
|
||||
strip_prefix = "bazel_clang_tidy-a46e57159bfe2d5d41135cec61f1c9cd514c1964",
|
||||
urls = [
|
||||
# Implements retry by relisting each url multiple times to be used as a failover.
|
||||
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.5.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.5.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.5.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.5.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.5.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/a46e57159bfe2d5d41135cec61f1c9cd514c1964.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/a46e57159bfe2d5d41135cec61f1c9cd514c1964.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/a46e57159bfe2d5d41135cec61f1c9cd514c1964.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/a46e57159bfe2d5d41135cec61f1c9cd514c1964.tar.gz",
|
||||
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/a46e57159bfe2d5d41135cec61f1c9cd514c1964.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def is_writeable(file) -> bool:
|
||||
try:
|
||||
@ -60,12 +62,78 @@ def get_replacements_to_apply(fixes_file) -> dict:
|
||||
return replacements_to_apply
|
||||
|
||||
|
||||
def _combine_errors(dir: str) -> str:
|
||||
failed_files = 0
|
||||
all_fixes = {}
|
||||
files_to_parse = []
|
||||
for root, _, files in os.walk(dir):
|
||||
for name in files:
|
||||
if name.endswith("clang-tidy.yaml"):
|
||||
files_to_parse.append(os.path.join(root, name))
|
||||
|
||||
# loop files_to_parse and count the number of failed_files
|
||||
for item in files_to_parse:
|
||||
if item is None:
|
||||
continue
|
||||
failed_files += 1
|
||||
|
||||
# Read the yaml fixes for the file to combine them with the other suggested fixes
|
||||
with open(item) as input_yml:
|
||||
fixes = yaml.safe_load(input_yml)
|
||||
if not fixes:
|
||||
continue
|
||||
for fix in fixes["Diagnostics"]:
|
||||
fix_msg = None
|
||||
if "Notes" in fix:
|
||||
fix_msg = fix["Notes"][0]
|
||||
if len(fix["Notes"]) > 1:
|
||||
print(f'Warning: this script may be missing values in [{fix["Notes"]}]')
|
||||
else:
|
||||
fix_msg = fix["DiagnosticMessage"]
|
||||
fix_data = (
|
||||
all_fixes.setdefault(fix["DiagnosticName"], {})
|
||||
.setdefault(fix_msg.get("FilePath", "FilePath Not Found"), {})
|
||||
.setdefault(
|
||||
str(fix_msg.get("FileOffset", "FileOffset Not Found")),
|
||||
{
|
||||
"replacements": fix_msg.get("Replacements", "Replacements not found"),
|
||||
"message": fix_msg.get("Message", "Message not found"),
|
||||
"count": 0,
|
||||
"source_files": [],
|
||||
},
|
||||
)
|
||||
)
|
||||
for replacement in fix_data["replacements"]:
|
||||
if replacement.get("FilePath") and os.path.exists(replacement.get("FilePath")):
|
||||
with open(replacement.get("FilePath"), "rb") as contents:
|
||||
replacement["FileContentsMD5"] = hashlib.md5(contents.read()).hexdigest()
|
||||
|
||||
fix_data["count"] += 1
|
||||
fix_data["source_files"].append(fixes["MainSourceFile"])
|
||||
|
||||
fixes_file = os.path.join(dir, "clang_tidy_fixes.json")
|
||||
with open(fixes_file, "w") as files_file:
|
||||
json.dump(all_fixes, files_file, indent=4, sort_keys=True)
|
||||
|
||||
return fixes_file
|
||||
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(dest="fixes_file", help="Path to fixes file.")
|
||||
parser.add_argument(
|
||||
dest="fixes",
|
||||
help="Path to fixes file or directory of fixes files.",
|
||||
nargs="?",
|
||||
default="bazel-bin",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
replacements_to_apply = get_replacements_to_apply(args.fixes_file)
|
||||
if os.path.isdir(args.fixes):
|
||||
fixes_file = _combine_errors(args.fixes)
|
||||
else:
|
||||
fixes_file = args.fixes
|
||||
|
||||
replacements_to_apply = get_replacements_to_apply(fixes_file)
|
||||
|
||||
for file in replacements_to_apply:
|
||||
with open(file, "rb") as fin:
|
||||
|
||||
@ -7,12 +7,12 @@ parser.add_argument("--warnings-as-errors", action="store_true")
|
||||
parser.add_argument("--output", required=True, type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
rule_dir = os.path.dirname(args.output)
|
||||
rule_dir = os.path.dirname(args.output).replace(os.getcwd(), "")
|
||||
|
||||
with open(args.input) as f:
|
||||
content = f.read()
|
||||
|
||||
content = content.replace("@MONGO_BUILD_DIR@", f"{rule_dir}/src/mongo/(?!.*\\.pb\\.h)")
|
||||
content = content.replace("@MONGO_BUILD_DIR@", f".*/{rule_dir}/src/mongo/.*/.*_gen.h")
|
||||
content = content.replace("@MONGO_BRACKET_BUILD_DIR@", f"{rule_dir}/src/mongo")
|
||||
if args.warnings_as_errors:
|
||||
content += 'WarningsAsErrors: "*"\n'
|
||||
|
||||
@ -607,7 +607,7 @@ public:
|
||||
* must hold the client lock, but updates to memory usage may be frequent and cause contention
|
||||
* on the client lock.
|
||||
*/
|
||||
void setMemoryTrackingStats(const int64_t inUseMemoryBytes, const int64_t maxUsedMemoryBytes);
|
||||
void setMemoryTrackingStats(int64_t inUseMemoryBytes, int64_t maxUsedMemoryBytes);
|
||||
|
||||
int64_t getInUseMemoryBytes() const {
|
||||
return _inUseMemoryBytes.load();
|
||||
|
||||
@ -123,11 +123,11 @@ public:
|
||||
*/
|
||||
static std::vector<BSONObj> generateStageInPipeline(
|
||||
const std::vector<BSONObj>& pipeline,
|
||||
const StringData timeField,
|
||||
StringData timeField,
|
||||
const boost::optional<StringData>& metaField,
|
||||
const boost::optional<std::int32_t>& bucketMaxSpanSeconds,
|
||||
const timeseries::MixedSchemaBucketsState& timeseriesMixedSchemaBucketsState,
|
||||
const bool timeseriesBucketsAreFixed);
|
||||
bool timeseriesBucketsAreFixed);
|
||||
|
||||
bool includeMetaField() const {
|
||||
return _bucketUnpacker.includeMetaField();
|
||||
|
||||
@ -45,22 +45,19 @@ namespace mongo {
|
||||
*/
|
||||
namespace timeseries {
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO(SERVER-101169): Remove these helper functions.
|
||||
timeseries::MixedSchemaBucketsState getTimeseriesMixedSchemaBucketsState(const Collection& coll) {
|
||||
inline timeseries::MixedSchemaBucketsState getTimeseriesMixedSchemaBucketsState(
|
||||
const Collection& coll) {
|
||||
return coll.getTimeseriesMixedSchemaBucketsState();
|
||||
}
|
||||
|
||||
timeseries::MixedSchemaBucketsState getTimeseriesMixedSchemaBucketsState(
|
||||
inline timeseries::MixedSchemaBucketsState getTimeseriesMixedSchemaBucketsState(
|
||||
const TypeCollectionTimeseriesFields& timeseriesFields) {
|
||||
return timeseriesFields.getTimeseriesBucketsMayHaveMixedSchemaData().value_or(true)
|
||||
? timeseries::MixedSchemaBucketsState::NonDurableMayHaveMixedSchemaBuckets
|
||||
: timeseries::MixedSchemaBucketsState::NoMixedSchemaBuckets;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
* Returns a rewritten pipeline that queries against a timeseries collection.
|
||||
*
|
||||
@ -71,11 +68,11 @@ timeseries::MixedSchemaBucketsState getTimeseriesMixedSchemaBucketsState(
|
||||
*/
|
||||
std::vector<BSONObj> rewritePipelineForTimeseriesCollection(
|
||||
const std::vector<BSONObj>& pipeline,
|
||||
const StringData timeField,
|
||||
StringData timeField,
|
||||
const boost::optional<StringData>& metaField,
|
||||
const boost::optional<std::int32_t>& bucketMaxSpanSeconds,
|
||||
const timeseries::MixedSchemaBucketsState& timeseriesMixedSchemaBucketsState,
|
||||
const bool timeseriesBucketsAreFixed);
|
||||
bool timeseriesBucketsAreFixed);
|
||||
|
||||
/**
|
||||
* Rewrite the aggregate request's pipeline BSON for a timeseries query. The command object's
|
||||
|
||||
@ -1942,3 +1942,4 @@ void ReshardingCoordinator::_logStatsOnCompletion(bool success) {
|
||||
#endif // RESHARDING_COORDINATOR_PART_4
|
||||
|
||||
} // namespace mongo
|
||||
#undef MONGO_LOGV2_DEFAULT_COMPONENT
|
||||
|
||||
@ -266,7 +266,7 @@ TenantIdMap<std::vector<BSONObj>> getClusterParametersLocally(OperationContext*
|
||||
* and throws any error that occurs while running this command.
|
||||
*/
|
||||
long long runCountCommandOnConfig(OperationContext* opCtx,
|
||||
const std::shared_ptr<Shard> localConfigShard,
|
||||
std::shared_ptr<Shard> localConfigShard,
|
||||
const NamespaceString& nss,
|
||||
BSONObj query);
|
||||
|
||||
@ -289,7 +289,7 @@ struct DrainingShardUsage {
|
||||
* shard being removed.
|
||||
*/
|
||||
DrainingShardUsage getDrainingProgress(OperationContext* opCtx,
|
||||
const std::shared_ptr<Shard> localConfigShard,
|
||||
std::shared_ptr<Shard> localConfigShard,
|
||||
const std::string& shardName);
|
||||
|
||||
/**
|
||||
@ -330,7 +330,7 @@ boost::optional<RemoveShardProgress> dropLocalCollectionsAndDatabases(
|
||||
*/
|
||||
void removeShard(const Lock::ExclusiveLock&,
|
||||
OperationContext* opCtx,
|
||||
const std::shared_ptr<Shard> localConfigShard,
|
||||
std::shared_ptr<Shard> localConfigShard,
|
||||
const std::string& shardName,
|
||||
std::shared_ptr<executor::TaskExecutor> executor);
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ namespace timeseries {
|
||||
* Returns true if `options.bucketRoundingSeconds` and `options.bucketMaxSpanSeconds` are equal and
|
||||
* the `parametersChanged` argument is `false`.
|
||||
*/
|
||||
bool areTimeseriesBucketsFixed(const TimeseriesOptions& options, const bool parametersChanged);
|
||||
bool areTimeseriesBucketsFixed(const TimeseriesOptions& options, bool parametersChanged);
|
||||
|
||||
/**
|
||||
* Evaluates whether the transition of timeseries granularities is valid (returning Status::OK if
|
||||
|
||||
@ -114,7 +114,7 @@ void ConnectionPool::ConnectionInterface::indicateUsed() {
|
||||
// It is illegal to attempt to use a connection after calling indicateFailure().
|
||||
invariant(_status.isOK() || _status == ConnectionPool::kConnectionStateUnknown);
|
||||
_lastUsed = now();
|
||||
_timesUsed.fetch_add(1, std::memory_order_relaxed);
|
||||
_timesUsed.fetchAndAddRelaxed(1);
|
||||
}
|
||||
|
||||
void ConnectionPool::ConnectionInterface::indicateSuccess() {
|
||||
@ -130,7 +130,7 @@ Date_t ConnectionPool::ConnectionInterface::getLastUsed() const {
|
||||
}
|
||||
|
||||
size_t ConnectionPool::ConnectionInterface::getTimesUsed() const {
|
||||
return _timesUsed.load(std::memory_order_relaxed);
|
||||
return _timesUsed.loadRelaxed();
|
||||
}
|
||||
|
||||
const Status& ConnectionPool::ConnectionInterface::getStatus() const {
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
#include "mongo/executor/connection_pool_stats.h"
|
||||
#include "mongo/executor/egress_connection_closer.h"
|
||||
#include "mongo/executor/egress_connection_closer_manager.h"
|
||||
#include "mongo/platform/atomic_word.h"
|
||||
#include "mongo/platform/compiler.h"
|
||||
#include "mongo/stdx/mutex.h"
|
||||
#include "mongo/stdx/unordered_map.h"
|
||||
@ -496,7 +497,7 @@ protected:
|
||||
private:
|
||||
size_t _generation;
|
||||
Date_t _lastUsed;
|
||||
std::atomic<size_t> _timesUsed{0};
|
||||
AtomicWord<size_t> _timesUsed{0};
|
||||
Status _status = ConnectionPool::kConnectionStateUnknown;
|
||||
};
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~GRPCServerContext() = default;
|
||||
~GRPCServerContext() override = default;
|
||||
|
||||
void addInitialMetadataEntry(const std::string& key, const std::string& value) override {
|
||||
_ctx->AddInitialMetadata(key, value);
|
||||
|
||||
@ -40,7 +40,7 @@ public:
|
||||
explicit GRPCServerStream(::grpc::ServerReaderWriter<ConstSharedBuffer, SharedBuffer>* stream)
|
||||
: _stream{stream} {}
|
||||
|
||||
~GRPCServerStream() = default;
|
||||
~GRPCServerStream() override = default;
|
||||
|
||||
boost::optional<SharedBuffer> read() override {
|
||||
SharedBuffer msg;
|
||||
|
||||
@ -86,7 +86,7 @@ class GRPCSession : public Session {
|
||||
public:
|
||||
explicit GRPCSession(TransportLayer* tl, HostAndPort remote);
|
||||
|
||||
virtual ~GRPCSession() override = default;
|
||||
~GRPCSession() override = default;
|
||||
|
||||
const HostAndPort& remote() const override {
|
||||
return _remote;
|
||||
@ -346,15 +346,15 @@ public:
|
||||
|
||||
// IngressSession does not support asynchronous operations.
|
||||
|
||||
Future<Message> _asyncReadFromStream() override final {
|
||||
Future<Message> _asyncReadFromStream() final {
|
||||
MONGO_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
Future<void> _asyncWriteToStream(Message m) override final {
|
||||
Future<void> _asyncWriteToStream(Message m) final {
|
||||
MONGO_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
void _cancelAsyncOperations() override final {
|
||||
void _cancelAsyncOperations() final {
|
||||
MONGO_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user