[all-commits] [llvm/llvm-project] d32c68: [modules] Merge equivalent extensions and diagnose...

Volodymyr Sapsai via All-commits all-commits at lists.llvm.org
Wed Apr 27 15:53:19 PDT 2022


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

  Changed paths:
    M clang/include/clang/AST/DeclObjC.h
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/AST/DeclObjC.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    A clang/test/Modules/merge-extension-ivars.m
    A clang/test/Modules/redecl-ivars.m

  Log Message:
  -----------
  [modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

Emitting metadata for the same ivar multiple times can lead to
miscompilations. Objective-C runtime adds offsets to calculate ivar
position in memory and presence of duplicate offsets causes wrong final
position thus overwriting unrelated memory.

Such a situation is impossible with modules disabled as clang diagnoses
ivar redeclarations during sema checks after parsing
(`Sema::ActOnFields`). Fix the case with modules enabled by checking
during deserialization if ivar is already declared. We also support
a use case where the same category ends up in multiple modules. We
don't want to treat this case as ivar redeclaration and instead merge
corresponding ivars.

rdar://83468070

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




More information about the All-commits mailing list