[PATCH] D30931: [clang-tidy] modified identifier naming case to use CT_AnyCase for ignoring case style

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 03:11:24 PDT 2017


alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

A couple of nits, otherwise looks good. Do you need me to commit the patch for you?



================
Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:169
         .Case("camel_Snake_Back", CT_CamelSnakeBack)
-        .Default(CT_AnyCase);
+        .Default(llvm::Optional<CaseType>());
   };
----------------
`llvm::None` is more idiomatic.


================
Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:181
+    } else {
+      NamingStyles.push_back(llvm::Optional<NamingStyle>());
+    }
----------------
`llvm::None` here as well.


================
Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:211
   for (size_t i = 0; i < SK_Count; ++i) {
-    Options.store(Opts, (StyleNames[i] + "Case").str(),
-                  toString(NamingStyles[i].Case));
-    Options.store(Opts, (StyleNames[i] + "Prefix").str(),
-                  NamingStyles[i].Prefix);
-    Options.store(Opts, (StyleNames[i] + "Suffix").str(),
-                  NamingStyles[i].Suffix);
+    if (NamingStyles[i].hasValue()) {
+      if (NamingStyles[i]->Case.hasValue()) {
----------------
`.hasValue()` can be omitted, since `llvm::Optional<>` defines `operator bool` and `operator *`, and thus can be used in a similar fashion as a pointer / smart pointer: `if (opt) DoSomething(*opt);`.


https://reviews.llvm.org/D30931





More information about the cfe-commits mailing list