Use explicit types instead of auto unless the type is obvious from the right-hand side of the assignment or impossible to spell. The LLVM coding standards recommend avoiding auto in most cases to improve code readability and maintainability.

When to use auto:

When to avoid auto:

Example:

// Bad - type not obvious
auto name = getValue();
auto count = getElementCount();
auto context = builder.getContext();

// Good - explicit types improve readability
StringRef name = getValue();
unsigned count = getElementCount();
MLIRContext *context = builder.getContext();

// Good - auto appropriate here
auto *CI = dyn_cast<CallInst>(instruction);
for (auto it = container.begin(); it != container.end(); ++it) { ... }

This practice ensures code remains readable without IDE assistance and makes type information immediately available to reviewers and maintainers.