[clang] 5479174 - [clang][ASTImporter] Not using consumeError at failed import of in-class initializer.

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 02:07:59 PDT 2022


Author: Balázs Kéri
Date: 2022-04-07T11:07:15+02:00
New Revision: 5479174071ec7d4692959bbdc15b5bb79e268e00

URL: https://github.com/llvm/llvm-project/commit/5479174071ec7d4692959bbdc15b5bb79e268e00
DIFF: https://github.com/llvm/llvm-project/commit/5479174071ec7d4692959bbdc15b5bb79e268e00.diff

LOG: [clang][ASTImporter] Not using consumeError at failed import of in-class initializer.

The error can be returned from the function, the problem written in comment before
does not exist. The same is done already in ASTImporter at various import failures.

After a declaration is created in an `ASTNodeImporter` import function
with `GetImportedOrCreateDecl`, that function registers it with
`MapImported`. At many places import errors can happen after this
and the error is returned. The same can be done in the place where
the in-class initializer is imported.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D122528

Added: 
    

Modified: 
    clang/lib/AST/ASTImporter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 5661e55b5505d..e3b3deff7c5c9 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3658,11 +3658,7 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
             if (!FoundField->getInClassInitializer())
               FoundField->setInClassInitializer(*ToInitializerOrErr);
           } else {
-            // We can't return error here,
-            // since we already mapped D as imported.
-            // FIXME: warning message?
-            consumeError(ToInitializerOrErr.takeError());
-            return FoundField;
+              return ToInitializerOrErr.takeError();
           }
         }
         return FoundField;


        


More information about the cfe-commits mailing list