[all-commits] [llvm/llvm-project] 6ba4af: [ODRHash] Hash `ObjCInterfaceDecl` and diagnose di...

Volodymyr Sapsai via All-commits all-commits at lists.llvm.org
Fri Jan 20 08:18:34 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6ba4afb4d6f2f8f293ad704a37de4139c5c8c0f0
      https://github.com/llvm/llvm-project/commit/6ba4afb4d6f2f8f293ad704a37de4139c5c8c0f0
  Author: Volodymyr Sapsai <vsapsai at apple.com>
  Date:   2023-01-20 (Fri, 20 Jan 2023)

  Changed paths:
    M clang/include/clang/AST/DeclObjC.h
    M clang/include/clang/AST/ODRDiagsEmitter.h
    M clang/include/clang/AST/ODRHash.h
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/AST/DeclObjC.cpp
    M clang/lib/AST/ODRDiagsEmitter.cpp
    M clang/lib/AST/ODRHash.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    A clang/test/Modules/compare-objc-interface.m
    M clang/test/Modules/interface-diagnose-missing-import.m
    M clang/test/Modules/method_pool.m

  Log Message:
  -----------
  [ODRHash] Hash `ObjCInterfaceDecl` and diagnose discovered mismatches.

When two modules contain interfaces with the same name, check the
definitions are equivalent and diagnose if they are not.

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


  Commit: ed7a46a8de77087447936965044e2faf734102e5
      https://github.com/llvm/llvm-project/commit/ed7a46a8de77087447936965044e2faf734102e5
  Author: Volodymyr Sapsai <vsapsai at apple.com>
  Date:   2023-01-20 (Fri, 20 Jan 2023)

  Changed paths:
    M clang/include/clang/AST/DeclObjC.h
    M clang/include/clang/AST/ODRDiagsEmitter.h
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/DeclObjC.cpp
    M clang/lib/AST/ODRDiagsEmitter.cpp
    M clang/lib/Parse/ParseObjc.cpp
    M clang/lib/Sema/SemaDeclObjC.cpp
    M clang/test/Modules/compare-objc-interface.m
    M clang/test/Modules/hidden-duplicates.m

  Log Message:
  -----------
  [modules] Allow parsing a duplicate Obj-C interface if a previous one comes from a hidden [sub]module.

Instead of emitting a redefinition error, check that definitions are
equivalent and allow such scenario.

A few non-obvious implementation details:
* to avoid multiple definitions in the redeclaration chain we just drop
  the new definition after checking for equivalence;
* for checking definition equivalence use ODR hash instead of
  ASTStructuralEquivalence because it avoids excessive recursive
  deserialization. Though after detecting a mismatch we do deserialize
  multiple entities to provide a better error message.

rdar://82908223

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


Compare: https://github.com/llvm/llvm-project/compare/585fbc240738...ed7a46a8de77


More information about the All-commits mailing list