[PATCH] D32395: [clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls

Jonas Devlieghere via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 25 08:49:23 PDT 2017


JDevlieghere added inline comments.


================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:115
+  const auto *MakePairCall = Result.Nodes.getNodeAs<CallExpr>("make_pair");
+  assert(InnerCtorCall || MakePairCall);
 
----------------
It's highly recommended to put some kind of error message in the assertion statement, as per the LLVM coding standards.


================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:130
+  SourceRange CallParensRange;
+  if (MakePairCall)
+    CallParensRange = SourceRange(MakePairCall->getCallee()->getLocEnd(),
----------------
Can't we use the ternary operator here?


================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:140
 
+  SourceLocation ExprBegin;
+  if (MakePairCall)
----------------
Same here?


================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:147
   // Range for constructor name and opening brace.
-  auto CtorCallSourceRange = CharSourceRange::getTokenRange(
-      InnerCtorCall->getExprLoc(), CallParensRange.getBegin());
+  auto ParamCallSourceRange = CharSourceRange::getTokenRange(
+      ExprBegin, CallParensRange.getBegin());
----------------
I think this can be const.


https://reviews.llvm.org/D32395





More information about the cfe-commits mailing list