[all-commits] [llvm/llvm-project] 29444f: [modules] Merge ObjC interface ivars with anonymou...

Volodymyr Sapsai via All-commits all-commits at lists.llvm.org
Mon Apr 4 18:49:22 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29444f0444c6d3586969fd6fbe49c8188c02c244
      https://github.com/llvm/llvm-project/commit/29444f0444c6d3586969fd6fbe49c8188c02c244
  Author: Volodymyr Sapsai <vsapsai at apple.com>
  Date:   2022-04-04 (Mon, 04 Apr 2022)

  Changed paths:
    M clang/lib/Parse/ParseObjc.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Serialization/ASTCommon.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/test/AST/ast-dump-decl.mm
    A clang/test/Modules/merge-anon-record-definition-in-objc.m
    A clang/test/SemaObjC/check-dup-decls-inside-objc.m

  Log Message:
  -----------
  [modules] Merge ObjC interface ivars with anonymous types.

Without the fix ivars with anonymous types can trigger errors like

> error: 'TestClass::structIvar' from module 'Target' is not present in definition of 'TestClass' provided earlier
> [...]
> note: declaration of 'structIvar' does not match

It happens because types of ivars from different modules are considered
to be different. And it is caused by not merging anonymous `TagDecl`
from different modules.

To fix that I've changed `serialization::needsAnonymousDeclarationNumber`
to handle anonymous `TagDecl` inside `ObjCInterfaceDecl`. But that's not
sufficient as C code inside `ObjCInterfaceDecl` doesn't use interface
decl as a decl context but switches to its parent (TranslationUnit in
most cases).  I'm changing that to make `ObjCContainerDecl` the lexical
decl context but keeping the semantic decl context intact.

Test "check-dup-decls-inside-objc.m" doesn't reflect a change in
functionality but captures the existing behavior to prevent regressions.

rdar://85563013

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




More information about the All-commits mailing list