[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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 37913 bytes
Desc: not available
More information about the cfe-commits