From 0d618b1278502f6014891ea31218e6bd74786102 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Wed, 29 Nov 2023 12:41:53 -0800 Subject: [PATCH] Tidy up lint issues. (#3429) These are manual fixes; mostly from clang-tidy, some from clangd (which notes unused includes). In typed_insts, adding inlline due to misc-definitions-in-headers. Per discussion, clang-tidy is wrong, but inline silences it. For parameter name skew in definition versus declaration, I'm just using the name from the definition. --------- Co-authored-by: Richard Smith --- toolchain/base/value_store.h | 1 - toolchain/check/context.h | 8 ++++---- toolchain/check/convert.cpp | 12 ++++-------- toolchain/check/convert.h | 7 +++---- toolchain/check/decl_name_stack.h | 2 +- toolchain/check/handle_array.cpp | 1 - toolchain/check/handle_class.cpp | 1 - toolchain/check/handle_index.cpp | 1 - toolchain/check/handle_paren.cpp | 4 +--- toolchain/check/pending_block.h | 6 +++--- toolchain/diagnostics/diagnostic_emitter.h | 16 ++++++++-------- toolchain/diagnostics/mocks.h | 1 + toolchain/lower/file_context.cpp | 1 - toolchain/lower/function_context.h | 3 +-- toolchain/lower/handle_aggregates.cpp | 3 +-- toolchain/parse/context.cpp | 1 + toolchain/parse/context.h | 2 ++ toolchain/parse/node_kind.cpp | 11 ++++++----- toolchain/sem_ir/file.h | 7 ++++--- toolchain/sem_ir/ids.h | 3 +-- toolchain/sem_ir/inst.h | 3 ++- toolchain/sem_ir/inst_kind.h | 8 ++++---- toolchain/sem_ir/typed_insts.h | 8 ++++---- toolchain/sem_ir/typed_insts_test.cpp | 8 ++++---- 24 files changed, 55 insertions(+), 63 deletions(-) diff --git a/toolchain/base/value_store.h b/toolchain/base/value_store.h index 687af9388494..20084dbe0b11 100644 --- a/toolchain/base/value_store.h +++ b/toolchain/base/value_store.h @@ -11,7 +11,6 @@ #include "common/ostream.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/Sequence.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 63e20b636bf6..571371ece54c 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -45,7 +45,7 @@ class Context { // Stores references for work. explicit Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter, const Parse::Tree& parse_tree, - SemIR::File& semantics, llvm::raw_ostream* vlog_stream); + SemIR::File& sem_ir, llvm::raw_ostream* vlog_stream); // Marks an implementation TODO. Always returns false. auto TODO(Parse::NodeId parse_node, std::string label) -> bool; @@ -136,7 +136,7 @@ class Context { // If there is no `returned var` in scope, sets the given instruction to be // the current `returned var` and returns an invalid instruction ID. If there // is already a `returned var`, returns it instead. - auto SetReturnedVarOrGetExisting(SemIR::InstId bind_id) -> SemIR::InstId; + auto SetReturnedVarOrGetExisting(SemIR::InstId inst_id) -> SemIR::InstId; // Follows NameRef instructions to find the value named by a given // instruction. @@ -178,8 +178,8 @@ class Context { // corresponding result values are the elements of `block_args`. Returns an // instruction referring to the result value. auto AddConvergenceBlockWithArgAndPush( - Parse::NodeId parse_node, - std::initializer_list blocks_and_args) -> SemIR::InstId; + Parse::NodeId parse_node, std::initializer_list block_args) + -> SemIR::InstId; // Add the current code block to the enclosing function. // TODO: The parse_node is taken for expressions, which can occur in diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index f1cd3f4891ed..bebba0c3ec6e 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -10,11 +10,8 @@ #include "common/check.h" #include "llvm/ADT/STLExtras.h" #include "toolchain/check/context.h" -#include "toolchain/diagnostics/diagnostic_kind.h" -#include "toolchain/parse/node_kind.h" #include "toolchain/sem_ir/file.h" #include "toolchain/sem_ir/inst.h" -#include "toolchain/sem_ir/inst_kind.h" namespace Carbon::Check { @@ -213,7 +210,7 @@ class CopyOnWriteBlock { } } - auto id() -> SemIR::InstBlockId const { return id_; } + auto id() const -> SemIR::InstBlockId { return id_; } auto Set(int i, SemIR::InstId value) -> void { if (source_id_.is_valid() && file_.inst_blocks().Get(id_)[i] == value) { @@ -579,8 +576,8 @@ static auto ConvertStructToClass(Context& context, SemIR::StructType src_type, // Returns whether `category` is a valid expression category to produce as a // result of a conversion with kind `target_kind`, or at most needs a temporary // to be materialized. -static bool IsValidExprCategoryForConversionTarget( - SemIR::ExprCategory category, ConversionTarget::Kind target_kind) { +static auto IsValidExprCategoryForConversionTarget( + SemIR::ExprCategory category, ConversionTarget::Kind target_kind) -> bool { switch (target_kind) { case ConversionTarget::Value: return category == SemIR::ExprCategory::Value; @@ -720,8 +717,7 @@ static auto PerformBuiltinConversion(Context& context, Parse::NodeId parse_node, // iterative approach. type_ids.push_back(ExprAsType(context, parse_node, tuple_inst_id)); } - auto tuple_type_id = - context.CanonicalizeTupleType(parse_node, std::move(type_ids)); + auto tuple_type_id = context.CanonicalizeTupleType(parse_node, type_ids); return sem_ir.GetTypeAllowBuiltinTypes(tuple_type_id); } diff --git a/toolchain/check/convert.h b/toolchain/check/convert.h index 1f0e6642e91e..53c27fb28e26 100644 --- a/toolchain/check/convert.h +++ b/toolchain/check/convert.h @@ -8,13 +8,12 @@ #include "toolchain/check/context.h" #include "toolchain/check/pending_block.h" #include "toolchain/parse/tree.h" -#include "toolchain/sem_ir/inst.h" namespace Carbon::Check { // Description of the target of a conversion. struct ConversionTarget { - enum Kind { + enum Kind : int8_t { // Convert to a value of type `type`. Value, // Convert to either a value or a reference of type `type`. @@ -46,13 +45,13 @@ struct ConversionTarget { PendingBlock* init_block = nullptr; // Are we converting this value into an initializer for an object? - bool is_initializer() const { + auto is_initializer() const -> bool { return kind == Initializer || kind == FullInitializer; } }; // Convert a value to another type and expression category. -auto Convert(Context& context, Parse::NodeId parse_node, SemIR::InstId value_id, +auto Convert(Context& context, Parse::NodeId parse_node, SemIR::InstId expr_id, ConversionTarget target) -> SemIR::InstId; // Performs initialization of `target_id` from `value_id`. Returns the diff --git a/toolchain/check/decl_name_stack.h b/toolchain/check/decl_name_stack.h index e60aa5291ada..f739363849c4 100644 --- a/toolchain/check/decl_name_stack.h +++ b/toolchain/check/decl_name_stack.h @@ -7,7 +7,7 @@ #include "llvm/ADT/SmallVector.h" #include "toolchain/parse/tree.h" -#include "toolchain/sem_ir/inst.h" +#include "toolchain/sem_ir/ids.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_array.cpp b/toolchain/check/handle_array.cpp index d7e79513524f..72181ccf2a0c 100644 --- a/toolchain/check/handle_array.cpp +++ b/toolchain/check/handle_array.cpp @@ -6,7 +6,6 @@ #include "toolchain/check/convert.h" #include "toolchain/parse/node_kind.h" #include "toolchain/sem_ir/inst.h" -#include "toolchain/sem_ir/inst_kind.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_class.cpp b/toolchain/check/handle_class.cpp index 83fc2e69b40a..22433a06dce1 100644 --- a/toolchain/check/handle_class.cpp +++ b/toolchain/check/handle_class.cpp @@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" -#include "toolchain/lex/token_kind.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_index.cpp b/toolchain/check/handle_index.cpp index 287c7d66e0ca..389402b5e8cb 100644 --- a/toolchain/check/handle_index.cpp +++ b/toolchain/check/handle_index.cpp @@ -6,7 +6,6 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" #include "toolchain/sem_ir/inst.h" -#include "toolchain/sem_ir/inst_kind.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_paren.cpp b/toolchain/check/handle_paren.cpp index bd767185aa08..6513b578f3bf 100644 --- a/toolchain/check/handle_paren.cpp +++ b/toolchain/check/handle_paren.cpp @@ -2,8 +2,6 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include - #include "toolchain/check/context.h" namespace Carbon::Check { @@ -46,7 +44,7 @@ auto HandleTupleLiteral(Context& context, Parse::NodeId parse_node) -> bool { for (auto inst : inst_block) { type_ids.push_back(context.insts().Get(inst).type_id()); } - auto type_id = context.CanonicalizeTupleType(parse_node, std::move(type_ids)); + auto type_id = context.CanonicalizeTupleType(parse_node, type_ids); auto value_id = context.AddInst(SemIR::TupleLiteral{parse_node, type_id, refs_id}); diff --git a/toolchain/check/pending_block.h b/toolchain/check/pending_block.h index 6393b0671661..476137a88c24 100644 --- a/toolchain/check/pending_block.h +++ b/toolchain/check/pending_block.h @@ -14,10 +14,10 @@ namespace Carbon::Check { // that haven't been inserted yet. class PendingBlock { public: - PendingBlock(Context& context) : context_(context) {} + explicit PendingBlock(Context& context) : context_(context) {} PendingBlock(const PendingBlock&) = delete; - PendingBlock& operator=(const PendingBlock&) = delete; + auto operator=(const PendingBlock&) -> PendingBlock& = delete; // A scope in which we will tentatively add instructions to a pending block. // If we leave the scope without inserting or merging the block, instructions @@ -26,7 +26,7 @@ class PendingBlock { public: // If `block` is not null, enters the scope. If `block` is null, this object // has no effect. - DiscardUnusedInstsScope(PendingBlock* block) + explicit DiscardUnusedInstsScope(PendingBlock* block) : block_(block), size_(block ? block->insts_.size() : 0) {} ~DiscardUnusedInstsScope() { if (block_ && block_->insts_.size() > size_) { diff --git a/toolchain/diagnostics/diagnostic_emitter.h b/toolchain/diagnostics/diagnostic_emitter.h index 785a79660129..ad596cb289c4 100644 --- a/toolchain/diagnostics/diagnostic_emitter.h +++ b/toolchain/diagnostics/diagnostic_emitter.h @@ -17,7 +17,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" -#include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/raw_ostream.h" #include "toolchain/diagnostics/diagnostic_kind.h" @@ -218,8 +217,9 @@ class DiagnosticEmitter { class DiagnosticBuilder { public: // DiagnosticBuilder is move-only and cannot be copied. - DiagnosticBuilder(DiagnosticBuilder&&) = default; - DiagnosticBuilder& operator=(DiagnosticBuilder&&) = default; + DiagnosticBuilder(DiagnosticBuilder&&) noexcept = default; + auto operator=(DiagnosticBuilder&&) noexcept + -> DiagnosticBuilder& = default; // Adds a note diagnostic attached to the main diagnostic being built. // The API mirrors the main emission API: `DiagnosticEmitter::Emit`. @@ -239,8 +239,8 @@ class DiagnosticEmitter { // For the expected usage see the builder API: `DiagnosticEmitter::Build`. template auto Emit() -> void { - for (auto* annotator_ : emitter_->annotators_) { - annotator_->Annotate(*this); + for (auto* annotator : emitter_->annotators_) { + annotator->Annotate(*this); } emitter_->consumer_->HandleDiagnostic(std::move(diagnostic_)); } @@ -321,11 +321,11 @@ class DiagnosticEmitter { DiagnosticAnnotationScopeBase(const DiagnosticAnnotationScopeBase&) = delete; - DiagnosticAnnotationScopeBase& operator=( - const DiagnosticAnnotationScopeBase&) = delete; + auto operator=(const DiagnosticAnnotationScopeBase&) + -> DiagnosticAnnotationScopeBase& = delete; protected: - DiagnosticAnnotationScopeBase(DiagnosticEmitter* emitter) + explicit DiagnosticAnnotationScopeBase(DiagnosticEmitter* emitter) : emitter_(emitter) { emitter_->annotators_.push_back(this); } diff --git a/toolchain/diagnostics/mocks.h b/toolchain/diagnostics/mocks.h index bbaad5d72d53..77afecd515f2 100644 --- a/toolchain/diagnostics/mocks.h +++ b/toolchain/diagnostics/mocks.h @@ -16,6 +16,7 @@ class MockDiagnosticConsumer : public DiagnosticConsumer { MOCK_METHOD(void, HandleDiagnostic, (Diagnostic diagnostic), (override)); }; +// NOLINTNEXTLINE(modernize-use-trailing-return-type): From the macro. MATCHER_P(IsDiagnosticMessage, matcher, "") { const Diagnostic& diag = arg; return testing::ExplainMatchResult( diff --git a/toolchain/lower/file_context.cpp b/toolchain/lower/file_context.cpp index 3f12cbdd47ba..ba55f3f73cc6 100644 --- a/toolchain/lower/file_context.cpp +++ b/toolchain/lower/file_context.cpp @@ -11,7 +11,6 @@ #include "toolchain/sem_ir/entry_point.h" #include "toolchain/sem_ir/file.h" #include "toolchain/sem_ir/inst.h" -#include "toolchain/sem_ir/inst_kind.h" namespace Carbon::Lower { diff --git a/toolchain/lower/function_context.h b/toolchain/lower/function_context.h index 7c3b96f6ca8a..cc48e4fb9605 100644 --- a/toolchain/lower/function_context.h +++ b/toolchain/lower/function_context.h @@ -10,7 +10,6 @@ #include "llvm/IR/Module.h" #include "toolchain/lower/file_context.h" #include "toolchain/sem_ir/file.h" -#include "toolchain/sem_ir/inst.h" namespace Carbon::Lower { @@ -91,7 +90,7 @@ class FunctionContext { // initialization was performed in-place, and otherwise performs a store or a // copy. auto FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id, - SemIR::InstId init_id) -> void; + SemIR::InstId source_id) -> void; auto llvm_context() -> llvm::LLVMContext& { return file_context_->llvm_context(); diff --git a/toolchain/lower/handle_aggregates.cpp b/toolchain/lower/handle_aggregates.cpp index 61827cc7b09b..1dc80e37ba5d 100644 --- a/toolchain/lower/handle_aggregates.cpp +++ b/toolchain/lower/handle_aggregates.cpp @@ -9,7 +9,6 @@ #include "llvm/IR/Value.h" #include "toolchain/lower/function_context.h" #include "toolchain/sem_ir/inst.h" -#include "toolchain/sem_ir/inst_kind.h" namespace Carbon::Lower { @@ -113,7 +112,7 @@ auto HandleClassFieldAccess(FunctionContext& context, SemIR::InstId inst_id, .GetAs( context.sem_ir().GetTypeAllowBuiltinTypes(class_type_id)) .class_id; - auto& class_info = context.sem_ir().classes().Get(class_id); + const auto& class_info = context.sem_ir().classes().Get(class_id); // Translate the class field access into a struct access on the object // representation. diff --git a/toolchain/parse/context.cpp b/toolchain/parse/context.cpp index 0e838b02840e..e474a1e7dec3 100644 --- a/toolchain/parse/context.cpp +++ b/toolchain/parse/context.cpp @@ -24,6 +24,7 @@ enum class RelativeLocation : int8_t { }; // Adapts RelativeLocation for use with formatv. +// TODO: Investigate for approaches that clangd is happier with. static auto operator<<(llvm::raw_ostream& out, RelativeLocation loc) -> llvm::raw_ostream& { switch (loc) { diff --git a/toolchain/parse/context.h b/toolchain/parse/context.h index 00c82766f92e..f702422f4d2a 100644 --- a/toolchain/parse/context.h +++ b/toolchain/parse/context.h @@ -22,6 +22,8 @@ namespace Carbon::Parse { // used sparingly, and unbounded lookahead should be avoided. // // TODO: Decide whether we want to avoid lookahead altogether. +// +// NOLINTNEXTLINE(performance-enum-size): Deliberately matches index size. enum class Lookahead : int32_t { CurrentToken = 0, NextToken = 1, diff --git a/toolchain/parse/node_kind.cpp b/toolchain/parse/node_kind.cpp index abccdee9fdd6..33fad56fa5c2 100644 --- a/toolchain/parse/node_kind.cpp +++ b/toolchain/parse/node_kind.cpp @@ -47,8 +47,9 @@ auto NodeKind::child_count() const -> int32_t { return child_count; } -void CheckNodeMatchesLexerToken(NodeKind node_kind, Lex::TokenKind token_kind, - bool has_error) { +// NOLINTNEXTLINE(readability-function-size): It's hard to extract macros. +auto CheckNodeMatchesLexerToken(NodeKind node_kind, Lex::TokenKind token_kind, + bool has_error) -> void { switch (node_kind) { // Use `CARBON_LOG CARBON_ANY_TOKEN` to discover which combinations happen // in practice. @@ -69,9 +70,9 @@ void CheckNodeMatchesLexerToken(NodeKind node_kind, Lex::TokenKind token_kind, MatchActions \ } -#define CARBON_CASE(Name, MatchActions) \ - case NodeKind::Name: \ - MatchActions; \ +#define CARBON_CASE(Name, MatchActions) \ + case NodeKind::Name: \ + MatchActions; /* NOLINT(bugprone-macro-parentheses) */ \ break; #define CARBON_PARSE_NODE_KIND_BRACKET(Name, BracketName, MatchActions) \ diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index a0fa05a5d54f..29afb3daa2dd 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -12,7 +12,6 @@ #include "toolchain/base/value_store.h" #include "toolchain/base/yaml.h" #include "toolchain/sem_ir/ids.h" -#include "toolchain/sem_ir/inst.h" #include "toolchain/sem_ir/value_stores.h" namespace Carbon::SemIR { @@ -63,7 +62,7 @@ struct Function : public Printable { // A class. struct Class : public Printable { - enum InheritanceKind { + enum InheritanceKind : int8_t { // `abstract class` Abstract, // `base class` @@ -79,7 +78,9 @@ struct Class : public Printable { // Determines whether this class has been fully defined. This is false until // we reach the `}` of the class definition. - bool is_defined() const { return object_representation_id.is_valid(); } + auto is_defined() const -> bool { + return object_representation_id.is_valid(); + } // The following members always have values, and do not change throughout the // lifetime of the class. diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index 8f5db783ef6e..52cd8a2caf7e 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -5,8 +5,6 @@ #ifndef CARBON_TOOLCHAIN_SEM_IR_IDS_H_ #define CARBON_TOOLCHAIN_SEM_IR_IDS_H_ -#include - #include "common/check.h" #include "common/ostream.h" #include "toolchain/base/index_base.h" @@ -129,6 +127,7 @@ struct NameId : public IndexBase, public Printable { // Returns the NameId corresponding to a particular IdentifierId. static auto ForIdentifier(IdentifierId id) -> NameId { + // NOLINTNEXTLINE(misc-redundant-expression): Asserting to be sure. static_assert(NameId::InvalidIndex == IdentifierId::InvalidIndex); CARBON_CHECK(id.index >= 0 || id.index == InvalidIndex) << "Unexpected identifier ID"; diff --git a/toolchain/sem_ir/inst.h b/toolchain/sem_ir/inst.h index 2000fd4bd363..a655b0c13f86 100644 --- a/toolchain/sem_ir/inst.h +++ b/toolchain/sem_ir/inst.h @@ -191,7 +191,8 @@ static_assert(sizeof(Inst) == 20, "Unexpected Inst size"); // Typed instructions can be printed by converting them to instructions. template > -inline llvm::raw_ostream& operator<<(llvm::raw_ostream& out, TypedInst inst) { +inline auto operator<<(llvm::raw_ostream& out, TypedInst inst) + -> llvm::raw_ostream& { Inst(inst).Print(out); return out; } diff --git a/toolchain/sem_ir/inst_kind.h b/toolchain/sem_ir/inst_kind.h index 609edb86230b..a510f048d273 100644 --- a/toolchain/sem_ir/inst_kind.h +++ b/toolchain/sem_ir/inst_kind.h @@ -94,6 +94,10 @@ static_assert(sizeof(InstKind) == 1, "Kind objects include padding!"); // thin wrapper around an instruction kind index. class InstKind::Definition : public InstKind { public: + // Not copyable. + Definition(const Definition&) = delete; + auto operator=(const Definition&) -> Definition& = delete; + // Returns the name to use for this instruction kind in Semantics IR. constexpr auto ir_name() const -> llvm::StringLiteral { return ir_name_; } @@ -110,10 +114,6 @@ class InstKind::Definition : public InstKind { TerminatorKind terminator_kind) : InstKind(kind), ir_name_(ir_name), terminator_kind_(terminator_kind) {} - // Not copyable. - Definition(const Definition&) = delete; - Definition& operator=(const Definition&) = delete; - llvm::StringLiteral ir_name_; TerminatorKind terminator_kind_; }; diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index 6919fc9438cd..c7e9e2c6ceb0 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -587,15 +587,15 @@ struct VarStorage { // HasParseNode is true if T has a `Parse::NodeId parse_node` field. template -constexpr bool HasParseNode = false; +inline constexpr bool HasParseNode = false; template -constexpr bool HasParseNode = true; +inline constexpr bool HasParseNode = true; // HasTypeId is true if T has a `TypeId type_id` field. template -constexpr bool HasTypeId = false; +inline constexpr bool HasTypeId = false; template -constexpr bool HasTypeId = true; +inline constexpr bool HasTypeId = true; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/typed_insts_test.cpp b/toolchain/sem_ir/typed_insts_test.cpp index 54232353747c..f1673431108b 100644 --- a/toolchain/sem_ir/typed_insts_test.cpp +++ b/toolchain/sem_ir/typed_insts_test.cpp @@ -42,7 +42,7 @@ auto MakeInstWithNumberedFields(InstKind kind) -> Inst { template auto CommonFieldOrder() -> void { Inst inst = MakeInstWithNumberedFields(TypedInst::Kind); - TypedInst typed = inst.As(); + auto typed = inst.As(); if constexpr (HasParseNode) { EXPECT_EQ(typed.parse_node, Parse::NodeId(1)); } @@ -74,14 +74,14 @@ auto ExpectEqInsts(const Inst& inst1, const Inst& inst2, template auto RoundTrip() -> void { Inst inst1 = MakeInstWithNumberedFields(TypedInst::Kind); - TypedInst typed1 = inst1.As(); + auto typed1 = inst1.As(); Inst inst2 = typed1; ExpectEqInsts(inst1, inst2, HasParseNode, HasTypeId); // If the typed instruction has no padding, we should get exactly the same // thing if we convert back from an instruction. - TypedInst typed2 = inst2.As(); + auto typed2 = inst2.As(); if constexpr (std::has_unique_object_representations_v) { EXPECT_EQ(std::memcmp(&typed1, &typed2, sizeof(TypedInst)), 0); } @@ -127,7 +127,7 @@ template auto StructLayout() -> void { // We can only do this check if the typed instruction has no padding. if constexpr (std::has_unique_object_representations_v) { - TypedInst typed = + auto typed = MakeInstWithNumberedFields(TypedInst::Kind).template As(); StructLayoutHelper(&typed, sizeof(typed), HasParseNode, HasTypeId);