[clang] 29e78ec - [AST] Use a reference in a range-based for
Mark de Wever via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 15 12:18:28 PST 2019
Author: Mark de Wever
Date: 2019-12-15T21:17:07+01:00
New Revision: 29e78ec67988a5aa712da805f8197bfa3d738700
URL: https://github.com/llvm/llvm-project/commit/29e78ec67988a5aa712da805f8197bfa3d738700
DIFF: https://github.com/llvm/llvm-project/commit/29e78ec67988a5aa712da805f8197bfa3d738700.diff
LOG: [AST] Use a reference in a range-based for
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
Added:
Modified:
clang/lib/AST/ASTContext.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4fd7e20dac84..1046663c7009 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -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())) {
@@ -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;
More information about the cfe-commits
mailing list