This is an archive of the discontinued LLVM Phabricator instance.

Correctly parse LateParsedTemplates in case of multiple dependent modules
ClosedPublic

Authored by gargvaibhav64 on Aug 25 2020, 2:53 AM.

Details

Summary

While parsing LateParsedTemplates, Clang assumes that the Global DeclID matches with the Local DeclID of a Decl. This is not the case when we have multiple dependent modules , each having their own LateParsedTemplate section. In such a case, a Local/Global DeclID confusion occurs which leads to improper casting of FunctionDecl's.

This commit creates a Vector to map the LateParsedTemplate section of each Module with their module file and therefore resolving the Global/Local DeclID confusion.

Diff Detail

Event Timeline

gargvaibhav64 created this revision.Aug 25 2020, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 2:53 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
gargvaibhav64 requested review of this revision.Aug 25 2020, 2:53 AM
gargvaibhav64 edited the summary of this revision. (Show Details)

Resolve a typo.

rsmith added inline comments.Aug 26 2020, 1:51 PM
clang/include/clang/Serialization/ASTReader.h
902–906

Given the changes below, we shouldn't need this any more, and can instead use this name for the container that carries the ModuleFile*.

908–909

We don't need a map here; we never need to look up the vector from the module file.

clang/lib/Serialization/ASTReader.cpp
3725–3728

We can directly initialize the vector in the container rather than initializing LateParsedTemplates and moving it. I think this also removes the only remaining use of the old LateParsedTemplates.

8394–8400
8396

No need to copy the vector here, and we can avoid hardcoding the preallocated SmallVector size.

gargvaibhav64 marked 5 inline comments as done.
gargvaibhav64 edited the summary of this revision. (Show Details)

Thanks. I incorporated all the changes.

rsmith accepted this revision.Sep 1 2020, 10:46 AM

Thanks!

clang/lib/Serialization/ASTReader.cpp
8398

Phabricator claims there's a tab here and below. Please double-check you're indenting with spaces before commit.

This revision is now accepted and ready to land.Sep 1 2020, 10:46 AM