Commit Graph

50 Commits

Author SHA1 Message Date
Richard Trieu 68fbf8563f [ODRHash] Revert r307720 to fix buildbot.
llvm-svn: 307743
2017-07-12 00:38:27 +00:00
Richard Trieu 1d06f44f0f [ODRHash] Support more method types.
Hash CXXConstructorDecl and CXXDestructorDecl.  Extend the diagnostics from
CXXMethodDecl to include constructors and destructors.

llvm-svn: 307720
2017-07-11 22:10:49 +00:00
Richard Trieu ac6a1b6417 [ODRHash] Support FriendDecl
llvm-svn: 307458
2017-07-08 02:04:42 +00:00
Richard Trieu 96b4164968 [ODRHash] Revert r305104 - Skip inline namespaces when hashing.
Test inline namespaces and handle them in the ODR hash again.

llvm-svn: 306926
2017-07-01 02:00:05 +00:00
Richard Trieu 8844c52266 [ODRHash] Support Type TemplateArgument
llvm-svn: 306904
2017-06-30 22:40:33 +00:00
Richard Trieu 3e03d3ee54 [ODRHash] Improve typedef handling.
Follow typedef chains to find the root type when processing types, and also
keep track of qualifiers.

llvm-svn: 306753
2017-06-29 22:53:04 +00:00
Richard Trieu 6e13ff33c8 [ODRHash] Hash VarDecl members.
These VarDecl's are static data members of classes.  Since the initializers are
also hashed, this also provides checking for default arguments to methods.

llvm-svn: 305543
2017-06-16 02:44:29 +00:00
Richard Trieu d9201d0a02 [ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmType
llvm-svn: 305440
2017-06-15 01:35:06 +00:00
Richard Trieu ee132d6eb2 [ODRHash] Hash Template and TemplateExpansion in TemplateArgument.
llvm-svn: 305361
2017-06-14 03:17:26 +00:00
Richard Trieu 1dcb405ca1 [ODRHash] Hash Expr for TemplateArgument::Expression
llvm-svn: 305360
2017-06-14 01:28:00 +00:00
Richard Trieu 3b261bb725 [ODRHash] Add TemplateArgument kind to hash.
llvm-svn: 305328
2017-06-13 22:21:18 +00:00
Richard Trieu 11d566acee [ODRHash] Add diagnostic messages for typedef and type alias.
llvm-svn: 305238
2017-06-12 21:58:22 +00:00
Richard Trieu be5cb93088 Revert r305110 to fix buildbot
llvm-svn: 305130
2017-06-09 23:03:40 +00:00
Richard Trieu 4ab80f2e9e [ODRHash] Add support for TemplateArgument types.
Recommit r304592 that was reverted in r304618.  r305104 should have fixed the
issue.

llvm-svn: 305110
2017-06-09 21:00:10 +00:00
Richard Trieu d064d1b6e8 Revert r304592
r304592 - [ODRHash] Add support for TemplateArgument types.
Possibly causing one of the errors in modules build bot.

llvm-svn: 304618
2017-06-03 00:11:23 +00:00
Richard Trieu 24c302b915 [ODRHash] Add support for TemplateArgument types.
llvm-svn: 304592
2017-06-02 20:35:29 +00:00
Richard Trieu 96b4962c8d [ODRHash] Support TemplateSpecializationType
llvm-svn: 304261
2017-05-31 00:31:58 +00:00
Richard Trieu cc6893736b [ODRHash] Revert r303450 to fix buildbot
r303450
[ODRHash] Support TemplateName and TemplateArgument

llvm-svn: 303459
2017-05-19 22:35:41 +00:00
Richard Trieu d05a006a53 [ODRHash] Support TemplateName and TemplateArgument
llvm-svn: 303450
2017-05-19 20:05:16 +00:00
Richard Trieu ce81b194a0 [ODRHash] Support NestedNameSpecifier
llvm-svn: 303233
2017-05-17 03:23:35 +00:00
Richard Trieu 58bb7bd18a [ODRHash] Support more types in the ODR checker.
Added support for TagType, TypeWithKeyword, and all children types.

llvm-svn: 303231
2017-05-17 02:29:02 +00:00
Richard Trieu b35ef2a599 [ODRHash] Loosen checks on typedefs.
When a type in a class is from a typedef, only check the canonical type.  Skip
checking the intermediate underlying types.  This is in response to PR 32965

llvm-svn: 302505
2017-05-09 03:24:34 +00:00
Richard Trieu 0255227a58 [ODRHash] Add support for array and decayed types, and parameter names and types.
llvm-svn: 301989
2017-05-02 23:58:52 +00:00
Richard Trieu 157ed94ee7 [ODRHash] Add testcase with different paramter names. NFC
llvm-svn: 301701
2017-04-28 22:03:28 +00:00
Richard Trieu fe56405467 [ODRHash] clean up test and add new examples. NFC
Use a macro to generate the struct with all decls.  Previously, four identical
changes would be needed to update this test.  This macro reduces that to one
location.  Added two other tests for issues that triggered false positives
during testing.

llvm-svn: 300814
2017-04-20 02:53:53 +00:00
Hans Wennborg 227077613a Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"
It caused PR32640.

llvm-svn: 300074
2017-04-12 16:40:26 +00:00
Richard Trieu 304ef22e6e Revert r298824 & r298816, recommit r298742 & r298754
r299989 fixes the underlying issue by waiting long enough to late parsed
arguments to be processed before doing an calculating the hash.

r298742
[ODRHash] Add error messages for mismatched parameters in methods.

r298754
[ODRHash] Add support for array and decayed types.

llvm-svn: 300001
2017-04-11 22:32:03 +00:00
Vassil Vassilev 3b7a6f9be6 Revert r298742 "[ODRHash] Add error messages for mismatched parameters in methods."
I failed to revert this in r298816.

llvm-svn: 298824
2017-03-26 21:39:16 +00:00
Vassil Vassilev bae9202b9a Revert 298754 and 298742.
They broke llvm modules builds and our internal modules infrastructure.

llvm-svn: 298816
2017-03-26 18:32:53 +00:00
Richard Trieu 7583bec0c3 [ODRHash] Add support for array and decayed types.
llvm-svn: 298754
2017-03-25 00:48:52 +00:00
Richard Trieu 73bac6a2f0 [ODRHash] Add error messages for mismatched parameters in methods.
llvm-svn: 298742
2017-03-24 21:17:48 +00:00
Alex Lorenz 76377dcf99 Print nested name specifiers for typedefs and type aliases
Printing typedefs or type aliases using clang_getTypeSpelling() is missing the
namespace they are defined in. This is in contrast to other types that always
yield the full typename including namespaces.

Patch by Michael Reiher!

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

llvm-svn: 297465
2017-03-10 15:04:58 +00:00
Richard Trieu 33562c2dcc [ODRHash] Hash typedefs and usings statements in classes.
llvm-svn: 297246
2017-03-08 00:13:19 +00:00
Richard Trieu f4b54fe64b [ODRHash] Try again to fix build bot.
llvm-svn: 296958
2017-03-04 03:04:15 +00:00
Richard Trieu 054c35c0c1 [ODRHash] Change test to try to appease buildbot.
llvm-svn: 296953
2017-03-04 02:05:13 +00:00
Richard Trieu 583e2c175a [ODRHash] Add support for detecting different method properties.
Now print diagnostics for static, virtual, inline, volatile, and const
differences in methods.  Also use DeclarationName instead of IdentifierInfo
for additional robustness in diagnostic printing.

llvm-svn: 296932
2017-03-04 00:08:58 +00:00
Richard Trieu 48143749f8 [ODRHash] Add basic support for CXXRecordDecl
llvm-svn: 296521
2017-02-28 21:24:38 +00:00
Richard Trieu 8d543e2741 [ODRHash] Finish FieldDecl support by handling mutable and initializers.
https://reviews.llvm.org/rL296170

llvm-svn: 296198
2017-02-24 23:35:37 +00:00
Richard Trieu 93772fcfc7 [ODRHash] Add handling of bitfields
Differential Revision: https://reviews.llvm.org/D21675

llvm-svn: 296170
2017-02-24 20:59:28 +00:00
Richard Trieu 8459ddf12a [ODRHash] Add handling of TypedefType and DeclarationName
Differential Revision: https://reviews.llvm.org/D21675

llvm-svn: 296078
2017-02-24 02:59:12 +00:00
Richard Trieu bcaaf96674 [ODRHash] Handle types in ODR hashing.
Fields will now have their types added to the hash, allowing for detection of
mismatched field types.  This detection allows the existing ODR checking to
produce the correct message.

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

llvm-svn: 295931
2017-02-23 03:25:57 +00:00
Richard Trieu d0786099b1 [ODRHash] Add IdentiferInfo and FieldDecl support.
IdentifierInfo is hashed based on the stored string.  FieldDecl versus other
Decl is now detected, as well as differently named fields.

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

llvm-svn: 295911
2017-02-23 00:23:01 +00:00
Richard Trieu 639d7b68d6 [ODRHash] static_cast and Stmt hashing.
Add support for static_cast in classes.  Add pointer-independent profiling for
Stmt's, sharing most of the logic with Stmt::Profile.  This is the first of the
deep sub-Decl diffing for error messages.

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

llvm-svn: 295890
2017-02-22 22:22:42 +00:00
Richard Trieu e7f7ed2be7 Add more ODR checking.
Add the basics for the ODRHash class, which will only process Decl's from
a whitelist, which currently only has AccessSpecDecl.  Different access
specifiers in merged classes can now be detected.

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

llvm-svn: 295800
2017-02-22 01:11:25 +00:00
Richard Trieu dc4cb02470 Revert r295421, new ODR checker for modules, to fix build bot.
llvm-svn: 295427
2017-02-17 07:19:24 +00:00
Richard Trieu cb6b72628e Add better ODR checking for modules.
A slightly weaker form of ODR checking than previous attempts, but hopefully
won't break the modules build bot.  Future work will be needed to catch all
cases.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295421
2017-02-17 05:54:30 +00:00
Richard Trieu e55fb7f6f1 Revert r295284: Add better ODR checking for modules.
Fix modules build bot.

llvm-svn: 295293
2017-02-16 07:09:18 +00:00
Richard Trieu f351ac8987 Add better ODR checking for modules.
Recommit r293585 that was reverted in r293611 with new fixes.  The previous
issue was determined to be an overly aggressive AST visitor from forward
declared objects.  The visitor will now only deeply visit certain Decl's and
only do a shallow information extraction from all other Decl's.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295284
2017-02-16 04:53:40 +00:00
Sam McCall 61e29aafa7 Revert r293585 "Add better ODR checking for modules."
We're seeing what we believe are false positives. (It's hard to tell with the
available diagnostics, and I'm not sure how to reduce them yet).
I'll send Richard reproduction details offline.

djasper/chandlerc suggested this should be a warning for now, to make rolling it
out feasible.

llvm-svn: 293611
2017-01-31 08:24:40 +00:00
Richard Trieu fa3d93a148 Add better ODR checking for modules.
When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taked from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 293585
2017-01-31 01:44:15 +00:00