Index: clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp @@ -62,7 +62,7 @@ // lookup by region. bool isSymbolTracked(ProgramStateRef State, SymbolRef Sym) { RawPtrMapTy Map = State->get(); - for (const auto Entry : Map) { + for (const auto &Entry : Map) { if (Entry.second.contains(Sym)) return true; } @@ -236,7 +236,7 @@ ProgramStateRef State = C.getState(); PtrSet::Factory &F = State->getStateManager().get_context(); RawPtrMapTy RPM = State->get(); - for (const auto Entry : RPM) { + for (const auto &Entry : RPM) { if (!SymReaper.isLiveRegion(Entry.first)) { // Due to incomplete destructor support, some dead regions might // remain in the program state map. Clean them up. @@ -266,7 +266,7 @@ const MemRegion *getContainerObjRegion(ProgramStateRef State, SymbolRef Sym) { RawPtrMapTy Map = State->get(); - for (const auto Entry : Map) { + for (const auto &Entry : Map) { if (Entry.second.contains(Sym)) { return Entry.first; } Index: clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp @@ -812,7 +812,7 @@ // Keep symbolic expressions of iterator positions, container begins and ends // alive auto RegionMap = State->get(); - for (const auto Reg : RegionMap) { + for (const auto &Reg : RegionMap) { const auto Offset = Reg.second.getOffset(); for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i) if (isa(*i)) @@ -820,7 +820,7 @@ } auto SymbolMap = State->get(); - for (const auto Sym : SymbolMap) { + for (const auto &Sym : SymbolMap) { const auto Offset = Sym.second.getOffset(); for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i) if (isa(*i)) @@ -828,7 +828,7 @@ } auto ContMap = State->get(); - for (const auto Cont : ContMap) { + for (const auto &Cont : ContMap) { const auto CData = Cont.second; if (CData.getBegin()) { SR.markLive(CData.getBegin()); @@ -849,7 +849,7 @@ auto State = C.getState(); auto RegionMap = State->get(); - for (const auto Reg : RegionMap) { + for (const auto &Reg : RegionMap) { if (!SR.isLiveRegion(Reg.first)) { // The region behind the `LazyCompoundVal` is often cleaned up before // the `LazyCompoundVal` itself. If there are iterator positions keyed @@ -861,14 +861,14 @@ } auto SymbolMap = State->get(); - for (const auto Sym : SymbolMap) { + for (const auto &Sym : SymbolMap) { if (!SR.isLive(Sym.first)) { State = State->remove(Sym.first); } } auto ContMap = State->get(); - for (const auto Cont : ContMap) { + for (const auto &Cont : ContMap) { if (!SR.isLiveRegion(Cont.first)) { // We must keep the container data while it has live iterators to be able // to compare them to the begin and the end of the container. @@ -2218,13 +2218,13 @@ bool hasLiveIterators(ProgramStateRef State, const MemRegion *Cont) { auto RegionMap = State->get(); - for (const auto Reg : RegionMap) { + for (const auto &Reg : RegionMap) { if (Reg.second.getContainer() == Cont) return true; } auto SymbolMap = State->get(); - for (const auto Sym : SymbolMap) { + for (const auto &Sym : SymbolMap) { if (Sym.second.getContainer() == Cont) return true; } @@ -2234,7 +2234,7 @@ bool isBoundThroughLazyCompoundVal(const Environment &Env, const MemRegion *Reg) { - for (const auto Binding: Env) { + for (const auto &Binding : Env) { if (const auto LCVal = Binding.second.getAs()) { if (LCVal->getRegion() == Reg) return true; @@ -2291,7 +2291,7 @@ auto &RegionMapFactory = State->get_context(); auto RegionMap = State->get(); bool Changed = false; - for (const auto Reg : RegionMap) { + for (const auto &Reg : RegionMap) { if (Cond(Reg.second)) { RegionMap = RegionMapFactory.add(RegionMap, Reg.first, Proc(Reg.second)); Changed = true; @@ -2304,7 +2304,7 @@ auto &SymbolMapFactory = State->get_context(); auto SymbolMap = State->get(); Changed = false; - for (const auto Sym : SymbolMap) { + for (const auto &Sym : SymbolMap) { if (Cond(Sym.second)) { SymbolMap = SymbolMapFactory.add(SymbolMap, Sym.first, Proc(Sym.second)); Changed = true; Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -505,7 +505,7 @@ // Recursively examine the base classes. // Note that following base classes does not increase the recursion depth. if (const auto *RDX = dyn_cast(RD)) - for (const auto II : RDX->bases()) + for (const auto &II : RDX->bases()) if (const RecordDecl *RRD = II.getType()->getAsRecordDecl()) if (Optional Out = findRegionOfInterestInRecord(RRD, State, R, Vec, depth))