]> granicus.if.org Git - clang/commitdiff
StaticAnalyzer: Avoid an unintentional copy
authorJustin Bogner <mail@justinbogner.com>
Tue, 22 Mar 2016 17:50:05 +0000 (17:50 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 22 Mar 2016 17:50:05 +0000 (17:50 +0000)
The range here isn't over references, so using `auto &` here incites a
copy. Switching to `auto *` would do, but we might as well list an
explicit type for clarity.

Found by -Wrange-loop-analysis.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

index 05bb7b71b8aa8e5f0ee07849d8540f9e4ce33f28..0640d2f49f43af80e23b6a554c0b54fcf22bd9b7 100644 (file)
@@ -168,7 +168,7 @@ public:
                                         const ASTRecordLayout &RL) {
     CharUnits PaddingSum;
     CharUnits Offset = ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
-    for (const auto &FD : RD->fields()) {
+    for (const FieldDecl *FD : RD->fields()) {
       // This checker only cares about the padded size of the
       // field, and not the data size. If the field is a record
       // with tail padding, then we won't put that number in our