[PATCH] clang-modernize: Clean up help output

Guillaume Papin guillaume.papin at epitech.eu
Mon Oct 7 14:06:28 PDT 2013



================
Comment at: clang-modernize/tool/ClangModernize.cpp:70
@@ -60,3 +69,3 @@
     "Apply all transforms supported by both clang >= 3.0 and gcc >= 4.7:\n\n"
     "  clang-modernize -for-compilers=clang-3.0,gcc-4.7 foo.cpp -- -Ibar\n");
 
----------------
I think -std=c++11 should be added like in the first example.

================
Comment at: clang-modernize/tool/ClangModernize.cpp:314
@@ +313,3 @@
+       I != E; ++I) {
+    if (std::find(UnhiddenCategories, CategoryEnd, I->second->Category) ==
+            CategoryEnd &&
----------------
Just a thought when looking at this line, I find it more difficult to understand when things are "negatives".
What about something like `VisibleCategories` instead of `UnhiddenCategories`?

================
Comment at: clang-modernize/tool/ClangModernize.cpp:316-320
@@ +315,7 @@
+            CategoryEnd &&
+        I->first() != "help" && I->first() != "version" &&
+        I->first() != "help-list")
+      I->second->setHiddenFlag(cl::ReallyHidden);
+    else if (I->first() == "help" || I->first() == "version" ||
+             I->first() == "help-list")
+      I->second->setCategory(GeneralCategory);
----------------
I would favor an array for these options and then `std::find()` instead of repeating the code. On the other hand I guess it's not subject to change often.

What about checking these options first and then check the option category:
```
if (opt is one of ["help" "version" "help-list"])
  opt.setCategory(GeneralCategory);

if (std::find(UnhiddenCategories, CategoryEnd, I->second->Category) == CategoryEnd)
 <...>
```


http://llvm-reviews.chandlerc.com/D1849



More information about the cfe-commits mailing list