r338753 - [analyzer] Forward arguments in registerChecker to avoid accidental copies
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 2 11:17:01 PDT 2018
Author: george.karpenkov
Date: Thu Aug 2 11:17:01 2018
New Revision: 338753
URL: http://llvm.org/viewvc/llvm-project?rev=338753&view=rev
Log:
[analyzer] Forward arguments in registerChecker to avoid accidental copies
Differential Revision: https://reviews.llvm.org/D50108
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=338753&r1=338752&r2=338753&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Thu Aug 2 11:17:01 2018
@@ -149,13 +149,13 @@ public:
///
/// \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);
More information about the cfe-commits
mailing list