[clang] 749aeea - [clang][ExtractAPI] Fix -Wpessimizing-move in DeclarationFragments.h (NFC)

Jie Fu via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 16:21:30 PDT 2023


Author: Jie Fu
Date: 2023-05-31T07:20:24+08:00
New Revision: 749aeeaf66a483345e12f69cc1f55dad4e997297

URL: https://github.com/llvm/llvm-project/commit/749aeeaf66a483345e12f69cc1f55dad4e997297
DIFF: https://github.com/llvm/llvm-project/commit/749aeeaf66a483345e12f69cc1f55dad4e997297.diff

LOG: [clang][ExtractAPI] Fix -Wpessimizing-move in DeclarationFragments.h (NFC)

/Users/jiefu/llvm-project/clang/include/clang/ExtractAPI/DeclarationFragments.h:118:26: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    Fragments.insert(It, std::move(Fragment(Spelling, Kind, PreciseIdentifier,
                         ^
/Users/jiefu/llvm-project/clang/include/clang/ExtractAPI/DeclarationFragments.h:118:26: note: remove std::move call here
    Fragments.insert(It, std::move(Fragment(Spelling, Kind, PreciseIdentifier,
                         ^~~~~~~~~~
1 error generated.

Added: 
    

Modified: 
    clang/include/clang/ExtractAPI/DeclarationFragments.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/ExtractAPI/DeclarationFragments.h b/clang/include/clang/ExtractAPI/DeclarationFragments.h
index 4c1b83080704..3b909b066866 100644
--- a/clang/include/clang/ExtractAPI/DeclarationFragments.h
+++ b/clang/include/clang/ExtractAPI/DeclarationFragments.h
@@ -115,8 +115,8 @@ class DeclarationFragments {
                                FragmentKind Kind,
                                StringRef PreciseIdentifier = "",
                                const Decl *Declaration = nullptr) {
-    Fragments.insert(It, std::move(Fragment(Spelling, Kind, PreciseIdentifier,
-                                            Declaration)));
+    Fragments.insert(It, Fragment(Spelling, Kind, PreciseIdentifier,
+                                            Declaration));
     return *this;
   }
 


        


More information about the cfe-commits mailing list