Skip to content

Commit

Permalink
[AST] Use a reference in a range-based for
Browse files Browse the repository at this point in the history
This avoids unneeded copies when using a range-based for loops.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D71526
  • Loading branch information
mordante committed Dec 15, 2019
1 parent aa45584 commit 29e78ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/AST/ASTContext.cpp
Expand Up @@ -2462,7 +2462,7 @@ structHasUniqueObjectRepresentations(const ASTContext &Context,
return llvm::None;

SmallVector<std::pair<QualType, int64_t>, 4> Bases;
for (const auto Base : ClassDecl->bases()) {
for (const auto &Base : ClassDecl->bases()) {
// Empty types can be inherited from, and non-empty types can potentially
// have tail padding, so just make sure there isn't an error.
if (!isStructEmpty(Base.getType())) {
Expand All @@ -2480,7 +2480,7 @@ structHasUniqueObjectRepresentations(const ASTContext &Context,
Layout.getBaseClassOffset(R.first->getAsCXXRecordDecl());
});

for (const auto Base : Bases) {
for (const auto &Base : Bases) {
int64_t BaseOffset = Context.toBits(
Layout.getBaseClassOffset(Base.first->getAsCXXRecordDecl()));
int64_t BaseSize = Base.second;
Expand Down

0 comments on commit 29e78ec

Please sign in to comment.