[PATCH] D50108: [analyzer] Forward arguments in registerChecker to avoid accidental copies

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 2 11:17:33 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL338753: [analyzer] Forward arguments in registerChecker to avoid accidental copies (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50108?vs=158397&id=158806#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50108

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
===================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -149,13 +149,13 @@
   ///
   /// \returns a pointer to the checker object.
   template <typename CHECKER, typename... AT>
-  CHECKER *registerChecker(AT... Args) {
+  CHECKER *registerChecker(AT &&... Args) {
     CheckerTag tag = getTag<CHECKER>();
     CheckerRef &ref = CheckerTags[tag];
     if (ref)
       return static_cast<CHECKER *>(ref); // already registered.
 
-    CHECKER *checker = new CHECKER(Args...);
+    CHECKER *checker = new CHECKER(std::forward<AT>(Args)...);
     checker->Name = CurrentCheckName;
     CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
     CHECKER::_register(checker, *this);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50108.158806.patch
Type: text/x-patch
Size: 902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180802/653dc502/attachment.bin>


More information about the llvm-commits mailing list