[clang] 30a9cac - [clang][ASTImporter] Fix -Wpessimizing-move in ASTImporter.cpp (NFC)

Jie Fu via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 00:14:26 PDT 2024


Author: Jie Fu
Date: 2024-09-06T15:14:18+08:00
New Revision: 30a9cace807d4b5c98f2d0e2bd5bdea49061c8b8

URL: https://github.com/llvm/llvm-project/commit/30a9cace807d4b5c98f2d0e2bd5bdea49061c8b8
DIFF: https://github.com/llvm/llvm-project/commit/30a9cace807d4b5c98f2d0e2bd5bdea49061c8b8.diff

LOG: [clang][ASTImporter] Fix -Wpessimizing-move in ASTImporter.cpp (NFC)

/llvm-project/clang/lib/AST/ASTImporter.cpp:371:20: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
       return std::move(Err);
              ^
/llvm-project/clang/lib/AST/ASTImporter.cpp:371:20: note: remove std::move call here
       return std::move(Err);
              ^~~~~~~~~~   ~
/llvm-project/clang/lib/AST/ASTImporter.cpp:380:22: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
         return std::move(Err);
                ^
/llvm-project/clang/lib/AST/ASTImporter.cpp:380:22: note: remove std::move call here
              return std::move(Err);
                     ^~~~~~~~~~   ~
2 errors generated.

Added: 
    

Modified: 
    clang/lib/AST/ASTImporter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index d335e34907b599..e854dbfb7bf2e5 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -368,7 +368,7 @@ namespace clang {
           auto *ToInheritedFrom = const_cast<TemplateParmDeclT *>(
               importChecked(Err, D->getDefaultArgStorage().getInheritedFrom()));
           if (Err)
-            return std::move(Err);
+            return Err;
           if (!ToInheritedFrom->hasDefaultArgument()) {
             // Resolve possible circular dependency between default value of the
             // template argument and the template declaration.
@@ -377,7 +377,7 @@ namespace clang {
                                        .getInheritedFrom()
                                        ->getDefaultArgument());
             if (Err)
-              return std::move(Err);
+              return Err;
             ToInheritedFrom->setDefaultArgument(Importer.getToContext(),
                                                 ToInheritedDefaultArg);
           }


        


More information about the cfe-commits mailing list