[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 16:30:30 PST 2019


bruno created this revision.
bruno added reviewers: rsmith, arphaman, vsapsai, martong.
Herald added subscribers: cfe-commits, ributzka, dexonsmith, jkorous, rnkovacs.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Take `struct Z {...}` defined differently and imported from both modules
X and Y. While in C/Objective-C mode, clang used to pick one of the
definitions and ignore the other even though they are not structurally
equivalent. Hook up a mechanism to check for it and reject such
conflicts. Instead of silently compiling, clang now emits:

In module 'Y' imported from t.m:2:
./y.h:2:8: error: type 'struct Z' has incompatible definitions in different translation units
struct Z {

  ^

./y.h:3:10: note: field 'm' has type 'double' here

  double m;
         ^

./x.h:3:7: note: field 'm' has type 'int' here

  int m;
      ^

rdar://problem/56764293


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71734

Files:
  clang/include/clang/AST/ASTStructuralEquivalence.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/merge-in-c/tag-types/module.modulemap
  clang/test/Modules/Inputs/merge-in-c/tag-types/x.h
  clang/test/Modules/Inputs/merge-in-c/tag-types/y.h
  clang/test/Modules/merge-tag-types.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71734.234806.patch
Type: text/x-patch
Size: 8583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191220/c62cbd8d/attachment.bin>


More information about the cfe-commits mailing list