This is an archive of the discontinued LLVM Phabricator instance.

[clang] Avoid expensive pulling in of definitions in ObjCInterfaceDecl::isThisDeclarationADefinition
Needs ReviewPublic

Authored by teemperor on Nov 3 2021, 8:19 AM.

Details

Reviewers
vsapsai
Summary

The current implementation of ObjCInterfaceDecl::isThisDeclarationADefinition calls
getDefinition and compares the result against itself. getDefinition is fairly complex
as it is required to pull in any unserialized declarations from the ExternalASTSource,
go over all the redeclarations and then find a defining declaration. In Clang this ends
up just being a few function calls and comparisons, but in LLDB the function call
causes us to do a roundtrip to disk which is rather expensive.

This patch replaces it by querying the definition data. If there is none, then there is
no definition in the current deserialized AST and this decl can't be a definition. If
there is a definition data then the definition there is compared against this (which
is just the old logic without the pulling in of unserialized definitions).

Diff Detail

Event Timeline

teemperor created this revision.Nov 3 2021, 8:19 AM
teemperor requested review of this revision.Nov 3 2021, 8:19 AM

In the summary you mention ObjCInterfaceDecl::isThisDeclarationADefinition but the change is made for ObjCProtocolDecl::isThisDeclarationADefinition (protocol vs interface). Is it in purpose or is it a mistake?

I believe it is valid to change isThisDeclarationADefinition implementation in this way as it corresponds to the method name. But need to check the callers in case they meant to call isThisDeclarationDesignatedDefinition.