[PATCH] D14198: Make the modernize-loop-convert's const-detection smarter.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 31 18:05:24 PDT 2015


klimek added inline comments.

================
Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:371-373
@@ -370,1 +370,5 @@
 
+/// \brief Returns false when it can be guaranteed that no container element
+/// is going to be modified due to this expression.
+static bool canBeModified(ASTContext *Context, const Expr *E) {
+  auto Parents = Context->getParents(*E);
----------------
Reading just this function, it is unclear what the 'container' is.

================
Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:392
@@ +391,3 @@
+  for (const Usage &U : Usages) {
+    if (U.Kind != Usage::UK_CaptureByCopy && U.Kind != Usage::UK_CaptureByRef &&
+        canBeModified(Context, U.Expression))
----------------
Can't CaptureBuRef be modified?

================
Comment at: test/clang-tidy/modernize-loop-convert-const.cpp:233
@@ +232,3 @@
+void takingReferences() {
+  // We do it twice to prevent the check from thinking that they are aliases.
+
----------------
But they are aliases. Shouldn't we then go into the const-ness of the aliases?


http://reviews.llvm.org/D14198





More information about the cfe-commits mailing list