Repository metrics
- Stars
- (27,997 stars)
- PR merge metrics
- (平均マージ 8d) (30d で 378 merged PRs)
説明
Title: Get include-what-you-use work for Envoy
Description: There are lots of include-what-you-use violations in Envoy:
- over-inclusion: including too many unused headers slows down compilation.
- transitive-inclusion: some of the missing explicit includes will make further development difficult.
include-what-you-use is powerful to address those violations and fix them.
@htuch mentioned at #10917 that we need to get it work for Envoy.
I tried on my own development environment and it works.
Here are steps to get it work:
- follow instructions at [Instructions for developers] (https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md) to build iwyu
- generate compilation database by
tools/gen_compilation_database.py --include_headers
-
replace
-stdlib=libc++-stdlib=libstdc++in the generated json filecompile_commands.json -
run
iwyu_tool.py -p .at Envoy root directory. (Please refer to section "Using with a compilation database" from [Instructions for developers] (https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md) for details)
The output shall look like this
...
source/common/grpc/google_async_client_impl.cc should add these lines:
#include <grpc/impl/codegen/gpr_types.h> // for GPR_CLOCK_REALTIME
#include <grpc/support/time.h> // for gpr_inf_future
#include <grpcpp/channel.h> // for Channel
#include <grpcpp/impl/codegen/async_stream_impl.h> // for ClientAsyncReader...
#include <grpcpp/impl/codegen/call_op_set.h> // for WriteOptions
#include <grpcpp/impl/codegen/string_ref.h> // for string_ref
#include <chrono> // for duration
#include <tuple> // for tie, tuple
#include "absl/strings/match.h" // for EndsWith
#include "common/grpc/stat_names.h" // for StatNames
#include "common/http/header_map_impl.h" // for RequestHeaderMapImpl
#include "common/protobuf/utility.h" // for PROTOBUF_GET_WRAP...
#include "common/stats/symbol_table_impl.h" // for StatName
#include "envoy/api/api.h" // for Api
#include "envoy/common/time.h" // for TimeSource
#include "envoy/stats/stats.h" // for Counter
source/common/grpc/google_async_client_impl.cc should remove these lines:
- #include "common/config/datasource.h" // lines 9-9
- #include "common/grpc/common.h" // lines 10-10
- #include "common/grpc/google_grpc_creds_impl.h" // lines 11-11
- #include "grpcpp/support/proto_buffer_reader.h" // lines 15-15
The full include-list for source/common/grpc/google_async_client_impl.cc:
#include "common/grpc/google_async_client_impl.h"
#include <grpc/impl/codegen/gpr_types.h> // for GPR_CLOCK_REALTIME
#include <grpc/support/time.h> // for gpr_inf_future
#include <grpcpp/channel.h> // for Channel
#include <grpcpp/impl/codegen/async_stream_impl.h> // for ClientAsyncReader...
#include <grpcpp/impl/codegen/call_op_set.h> // for WriteOptions
#include <grpcpp/impl/codegen/string_ref.h> // for string_ref
...
It will be useful if we can apply the iwyu check to every pull request to check iwyu violations.