This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by balazske on Mar 26 2022, 8:33 AM.

Details

Summary

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.

Diff Detail

Event Timeline

balazske created this revision.Mar 26 2022, 8:33 AM
Herald added a reviewer: shafik. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
balazske requested review of this revision.Mar 26 2022, 8:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2022, 8:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I wanted to remove this one instance of consumeError because the change in D122525, to ensure that consumeError is called really only from ImportDeclContext (and other places where it is not relevant).

martong accepted this revision.Mar 31 2022, 2:47 AM

Thanks! Good catch!

(For inexperienced readers, let me explain why I accepted the patch: If there is an error then the imported Decl is marked as erroneous, i.e an Error object is associated with the imported Decl, thus users of the ASTImporter can react according to the set error.)

This revision is now accepted and ready to land.Mar 31 2022, 2:47 AM