commit | 71bfaf6800771be5fcc90a6c069cc0d1cae8d166 | [log] [tgz] |
---|---|---|
author | bnc <bnc@google.com> | Fri May 13 05:39:08 2022 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Fri May 13 05:41:13 2022 -0700 |
tree | 388a184094676d8867a584848e87192e6edfa419 | |
parent | bf3a11997dbcbc6fc44924ec515fcfc582588d45 [diff] |
Add using directives to BalsaHeader to fix gcc compile error. Three ConstHeaderApi virtual methods each have two overloads that only differ in a single argument type: absl::string_view versus QuicheLowerCaseString. In Envoy, QuicheLowerCaseString is an alias to Envoy::Http::LowerCaseString [1], which has an implicit conversion operator to absl::string_view [2]. [1] https://github.com/envoyproxy/envoy/blob/741b8c08d3de1650fc45d5c9a75e418867a10fa9/source/common/quic/platform/quiche_lower_case_string_impl.h#L13 [2] https://github.com/envoyproxy/envoy/blob/741b8c08d3de1650fc45d5c9a75e418867a10fa9/envoy/http/header_map.h#L82-L83 ConstHeaderApi provides a trivial definition to the QuicheLowerCaseString overload that calls the absl::string_view overload, which is overridden in BalsaHeaders. This makes perfect sense but makes gcc in Envoy unhappy: quiche/common/balsa/header_api.h:89:23: error: ‘virtual std::string quiche::ConstHeaderApi::GetAllOfHeaderAsString(const QuicheLowerCaseString&) const’ was hidden [-Werror=overloaded-virtual] quiche/common/balsa/balsa_headers.h:560:15: error: by ‘virtual std::string quiche::BalsaHeaders::GetAllOfHeaderAsString(absl::string_view) const’ [-Werror=overloaded-virtual] This is because when called with a QuicheLowerCaseString argument on a BalsaHeaders object, the latter overload is preferred over the former (due to the implicit conversion), which is not the intended behavior. GetAllOfHeader() does not pose an issue due to the using HeaderApi::GetAllOfHeader; directive at balsa_headers.h:549. This CL adds similar using directives to the other two methods to solve this problem. And here is a minimal example to verify this behavior. Running with gcc a.cc -Woverloaded-virtual -l:libstdc++.a && ./a.out prints "right" and no warning, but if the using directive is removed, the warning appears and "wrong" is printed: #include <iostream> class T { public: operator int() const { return 0; } }; class base { public: virtual void print(int a) = 0; virtual void print(T a) { std::cout << "right" << std::endl; } }; class derived : public base { public: using base::print; void print(int a) override { std::cout << "wrong" << std::endl; } }; int main() { T t; derived c; c.print(t); return 0; } PiperOrigin-RevId: 448474666
QUICHE stands for QUIC, Http, Etc. It is Google‘s production-ready implementation of QUIC, HTTP/2, HTTP/3, and related protocols and tools. It powers Google’s servers, Chromium, Envoy, and other projects. It is actively developed and maintained.
There are two public QUICHE repositories. Either one may be used by embedders, as they are automatically kept in sync:
To embed QUICHE in your project, platform APIs need to be implemented and build files need to be created. Note that it is on the QUICHE team's roadmap to include default implementation for all platform APIs and to open-source build files. In the meanwhile, take a look at open source embedders like Chromium and Envoy to get started:
To contribute to QUICHE, follow instructions at CONTRIBUTING.md.
QUICHE is only supported on little-endian platforms.