[PATCH] D11446: For loop style fix

David Majnemer david.majnemer at gmail.com
Fri Jul 24 13:21:46 PDT 2015


majnemer added inline comments.

================
Comment at: lib/CodeGen/CGVTables.cpp:835
@@ -834,6 +834,3 @@
 
-  typedef std::vector<const CXXRecordDecl *>::const_iterator const_iterator;
-  for (const_iterator i = DeferredVTables.begin(),
-                      e = DeferredVTables.end(); i != e; ++i) {
-    const CXXRecordDecl *RD = *i;
+  for (const auto &RD : DeferredVTables) {
     if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
----------------
It would be nicer to use `const CXXRecordDecl *RD : DeferredVTables` because the type in the collection isn't trivially obvious.  Also, the braces for the `for-loop` are now superfluous.

================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1026
@@ -1025,4 +1025,3 @@
   // Now walk all possible inheritance paths.
-  for (CXXBasePaths::paths_iterator I = Paths.begin(), E = Paths.end(); I != E;
-       ++I) {
-    if (I->Access != AS_public) // Ignore non-public inheritance.
+  for (auto &Path : Paths) {
+    if (Path.Access != AS_public)  // Ignore non-public inheritance.
----------------
I'd change the `auto` to `CXXBasePath` because the type isn't clear.

================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1032
@@ -1032,3 +1031,3 @@
 
-    for (CXXBasePath::iterator J = I->begin(), JE = I->end(); J != JE; ++J) {
+    for (auto &PathElement : Path) {
       // If the path contains a virtual base class we can't give any hint.
----------------
Likewise, I'd change this `auto` to `CXXBasePathElement`.


http://reviews.llvm.org/D11446







More information about the cfe-commits mailing list