mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Run clang-tidy on headers (#3572)
This patches bazel_clang_tidy handling of headers. I found an equivalent change at https://github.com/erenon/bazel_clang_tidy/pull/13, but that was [already rejected](https://github.com/erenon/bazel_clang_tidy/pull/13#issuecomment-1047007424). Per the criticism, this will result in redundant processing of headers. The project instead uses `HeaderFilterRegex: ".*"`, but that results in two problems: 1. When running with `-k`, errors are repeated when a header is included more than once, which is common. 2. clang-tidy including errors from headers that are included from other modules (e.g., abseil-cpp); filtering correctly is difficult. Given the trade-offs and options (including forking), I thought patching was preferable so long as it remains narrow.
This commit is contained in:
@@ -150,7 +150,7 @@ class NodeStack {
|
||||
template <const Parse::NodeKind& RequiredParseKind>
|
||||
auto PopWithParseNode() -> auto {
|
||||
constexpr IdKind RequiredIdKind = ParseNodeKindToIdKind(RequiredParseKind);
|
||||
auto NodeIdCast = [&](auto back) {
|
||||
auto node_id_cast = [&](auto back) {
|
||||
using NodeIdT = Parse::NodeIdForKind<RequiredParseKind>;
|
||||
return std::pair<NodeIdT, decltype(back.second)>(back);
|
||||
};
|
||||
@@ -158,37 +158,37 @@ class NodeStack {
|
||||
if constexpr (RequiredIdKind == IdKind::InstId) {
|
||||
auto back = PopWithParseNode<SemIR::InstId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::InstBlockId) {
|
||||
auto back = PopWithParseNode<SemIR::InstBlockId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::FunctionId) {
|
||||
auto back = PopWithParseNode<SemIR::FunctionId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::ClassId) {
|
||||
auto back = PopWithParseNode<SemIR::ClassId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::InterfaceId) {
|
||||
auto back = PopWithParseNode<SemIR::InterfaceId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::NameId) {
|
||||
auto back = PopWithParseNode<SemIR::NameId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::TypeId) {
|
||||
auto back = PopWithParseNode<SemIR::TypeId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return NodeIdCast(back);
|
||||
return node_id_cast(back);
|
||||
}
|
||||
CARBON_FATAL() << "Unpoppable IdKind for parse kind: " << RequiredParseKind
|
||||
<< "; see value in ParseNodeKindToIdKind";
|
||||
|
||||
Reference in New Issue
Block a user