Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp @@ -208,11 +208,12 @@ << FixItHint::CreateInsertion( Initializer->getLParenLoc().getLocWithOffset(1), "std::move("); - auto Insertion = - Inserter->CreateIncludeInsertion(SM.getMainFileID(), "utility", - /*IsAngled=*/true); - if (Insertion.hasValue()) - Diag << Insertion.getValue(); + if (auto IncludeFixit = Inserter->CreateIncludeInsertion( + Result.SourceManager->getFileID(Initializer->getSourceLocation()), + "utility", + /*IsAngled=*/true)) { + Diag << *IncludeFixit; + } } } // namespace modernize Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h +++ clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h @@ -0,0 +1,7 @@ +class ThreadId { +}; + +struct A { + A(const ThreadId &tid) : threadid(tid) {} + ThreadId threadid; +}; Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp @@ -0,0 +1,8 @@ +// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h +// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:" +// RUN: FileCheck -input-file=%T/pass-by-value-header.h %s -check-prefix=CHECK-FIXES + +#include "pass-by-value-header.h" +// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move [modernize-pass-by-value] +// CHECK-FIXES: #include +// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}