[all-commits] [llvm/llvm-project] 160bc1: [ODRHash] Hash `RecordDecl` and diagnose discovere...

Volodymyr Sapsai via All-commits all-commits at lists.llvm.org
Thu Jan 19 14:00:03 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 160bc160b9b114069a8cb9b4cc887aa86e5ca7c4
      https://github.com/llvm/llvm-project/commit/160bc160b9b114069a8cb9b4cc887aa86e5ca7c4
  Author: Volodymyr Sapsai <vsapsai at apple.com>
  Date:   2023-01-19 (Thu, 19 Jan 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/DeclBase.h
    M clang/include/clang/AST/ODRDiagsEmitter.h
    M clang/include/clang/AST/ODRHash.h
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/AST/Decl.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/ASTWriterDecl.cpp
    A clang/test/Modules/compare-record.c

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

When two modules contain struct/union with the same name, check the
definitions are equivalent and diagnose if they are not. This is similar
to `CXXRecordDecl` where we already discover and diagnose mismatches.

rdar://problem/56764293

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


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

  Changed paths:
    M clang/lib/AST/RecordLayoutBuilder.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/test/Modules/compare-record.c

  Log Message:
  -----------
  [ODRHash] Detect mismatches in anonymous `RecordDecl`.

Allow completing a redeclaration check for anonymous structs/unions
inside `RecordDecl`, so we deserialize and compare anonymous entities
from different modules.

Completing the redeclaration chain for `RecordDecl` in
`ASTContext::getASTRecordLayout` mimics the behavior in
`CXXRecordDecl::dataPtr`. Instead of completing the redeclaration chain
every time we request a definition, do that right before we need a
complete definition in `ASTContext::getASTRecordLayout`.

Such code is required only for anonymous `RecordDecl` because we
deserialize named decls when we look them up by name. But it doesn't
work for anonymous decls as they don't have a name. That's why need to
force deserialization of anonymous decls in a different way.

rdar://81864186

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


Compare: https://github.com/llvm/llvm-project/compare/9bdcf8778a5c...f33b5b1bf703


More information about the All-commits mailing list