[PATCH] D21675: New ODR checker for modules

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 23 22:39:14 PDT 2016


rtrieu created this revision.
rtrieu added a subscriber: cfe-commits.

Early prototype of an improved ODR checker for Clang and modules.  The current ODR checking of classes is limited to a small number of attributes such as number of methods and base classes.  This still allows a number of ODR violations to pass through undetected which only manifests as problems during linking.  This improved ODR checker calculates a hash based on the class contents, then checks that the two decls have the same hash before allowing them to be merged.  The test case shows a number of ODR violations that the current Clang checker would not have caught.

The hashing relies on three visitors for Stmt's, Decl's, and Type's.  For Stmt's, the visitor behind Stmt::Profile was refactored so that a hash could be generated without depending on pointers.  For Decl's, a new DeclVisitor was created.  The Type visitor has not been written yet.  Instead, Types are converted into a string as a stand-in.

The other area for improvement is the diagnostic message.  Most have the default message stating the class has different definitions in different modules.  New specific messages will need to be created to supplement the default message.

http://reviews.llvm.org/D21675

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/Stmt.h
  lib/AST/DeclCXX.cpp
  lib/AST/StmtProfile.cpp
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/odr_hash/first.h
  test/Modules/Inputs/odr_hash/module.map
  test/Modules/Inputs/odr_hash/second.h
  test/Modules/merge-using-decls.cpp
  test/Modules/odr_hash.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21675.61756.patch
Type: text/x-patch
Size: 37913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160624/29e65cd9/attachment-0001.bin>


More information about the cfe-commits mailing list