Closed balazske closed 5 years ago
The problem is caused by an empty DeclGroup
in DeclStmt
. This happens because the check for failed import of the DeclGroup in VisitDeclStmt
is not correct when a single Decl is failing to import: The new DeclGroup will be created with a single nullptr and will behave as an empty group.
This is related: https://github.com/Ericsson/clang/issues/487 where we also had an empty DeclGroup. The DeclGroup was empty becasue class templates redecl chain was incorrect.
The correction of the wrong check makes this crash go away but a next one ToDecl->hasBody()
follows. The root cause is anyway not the bad check but the failed import. And the error reports do not look correct, for example (this comes before the crash):
clang/testproject/protobuf-3.5.1/src/google/protobuf/descriptor.h:453:19: error: field 'extension_ranges_' declared with incompatible types in different translation units ('google::protobuf::Descriptor::ExtensionRange *' vs. 'google::protobuf::Descriptor::ExtensionRange *')
ExtensionRange* extension_ranges_;
^
clang/testproject/protobuf-3.5.1/src/google/protobuf/descriptor.h:453:19: note: declared here with type 'google::protobuf::Descriptor::ExtensionRange *'
ExtensionRange* extension_ranges_;
I will try this after #505 is finished.
Fixed.
During analysis of protobuf the following crash happens (on ctu-clang7):