[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

Frederic Tingaud via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 1 00:44:43 PST 2018


ftingaud added inline comments.


================
Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+    : MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+      MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+                                         getDefaultMinimumLanguageVersion())) {}
----------------
aaron.ballman wrote:
> Why is this is a user-facing option?
> 
> If it needs to be a user-facing option, you also need to implement an override for `storeOptions()` as well.
As the rule was very customizable, I also made the c++ version customizable. But the option is only useful if a user has a custom make_unique that needs c++14 (uses std::make_unique internally) and multiple versions of C++ in their codeline. I agree this is a rather specific usecase. I can remove it and make the code simpler if it is your recommendation.


================
Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:25
+const std::string MakeUniqueCheck::getDefaultMinimumLanguageVersion() const {
+  return Options.get("MakeSmartPtrFunction", "").empty() ? "c++14" : "c++11";
+}
----------------
aaron.ballman wrote:
> What is this option? Why is this returning a string literal rather than something less error-prone like an enumeration?
I made the MinimumLanguageVersion a string literal to make it customizable by the user. If we remove the customization, we can switch to an enum or a boolean.


https://reviews.llvm.org/D43766





More information about the cfe-commits mailing list