summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index 2c623727119..054e5ce94d9 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -391,6 +391,12 @@ static bool containerIsConst(const Expr *ContainerExpr, bool Dereference) {
return false;
CType = CType->getPointeeType();
}
+ // If VDec is a reference to a container, Dereference is false,
+ // but we still need to check the const-ness of the underlying container
+ // type.
+ if (const auto &RT = CType->getAs<ReferenceType>()) {
+ CType = RT->getPointeeType();
+ }
return CType.isConstQualified();
}
return false;
OpenPOWER on IntegriCloud