summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ODRHash.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Concepts] Placeholder constraints and abbreviated templatesSaar Raz2020-01-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This patch implements P1141R2 "Yet another approach for constrained declarations". General strategy for this patch was: - Expand AutoType to include optional type-constraint, reflecting the wording and easing the integration of constraints. - Replace autos in parameter type specifiers with invented parameters in GetTypeSpecTypeForDeclarator, using the same logic previously used for generic lambdas, now unified with abbreviated templates, by: - Tracking the template parameter lists in the Declarator object - Tracking the template parameter depth before parsing function declarators (at which point we can match template parameters against scope specifiers to know if we have an explicit template parameter list to append invented parameters to or not). - When encountering an AutoType in a parameter context we check a stack of InventedTemplateParameterInfo structures that contain the info required to create and accumulate invented template parameters (fields that were already present in LambdaScopeInfo, which now inherits from this class and is looked up when an auto is encountered in a lambda context). Resubmit after fixing MSAN failures caused by incomplete initialization of AutoTypeLocs in TypeSpecLocFiller. Differential Revision: https://reviews.llvm.org/D65042 (cherry picked from commit b481f028144ca91c15d1db3649ce14f174259e7e)
* [Concepts] Type ConstraintsSaar Raz2020-01-151-0/+5
| | | | | | | Add support for type-constraints in template type parameters. Also add support for template type parameters as pack expansions (where the type constraint can now contain an unexpanded parameter pack). Differential Revision: https://reviews.llvm.org/D44352
* [ODRHash] Fix null pointer dereference for ObjC selectors with empty slots.Volodymyr Sapsai2019-06-281-1/+6
| | | | | | | | | | | | | | | | | `Selector::getIdentifierInfoForSlot` returns NULL if a slot has no corresponding identifier. Add a boolean to the hash and a NULL check. rdar://problem/51615164 Reviewers: rtrieu Reviewed By: rtrieu Subscribers: dexonsmith, cfe-commits, jkorous Differential Revision: https://reviews.llvm.org/D63789 llvm-svn: 364664
* [ODRHash] Skip some typedef types.Richard Trieu2019-06-221-0/+45
| | | | | | | | | | | | | | | In some cases, a typedef only strips aways a keyword for a type, keeping the same name as the root record type. This causes some confusion when the type is defined in one modules but only forward declared in another. Skipping the typedef and going straight to the record will avoid this issue. typedef struct S {} S; S* s; // S is TypedefType here struct S; S* s; // S is RecordType here llvm-svn: 364119
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* Reduce amount of work ODR hashing does.Richard Trieu2019-05-041-4/+26
| | | | | | | | | | | | | | | When a FunctionProtoType is in the original type in a DecayedType, the decayed type is a PointerType which points back the original FunctionProtoType. The visitor for ODRHashing will attempt to process both Type's, doing double work. By chaining together multiple DecayedType's and FunctionProtoType's, this would result in 2^N Type's visited only N DecayedType's and N FunctionProtoType's exsit. Another bug where VisitDecayedType and VisitAdjustedType did redundant work doubled the work at each level, giving 4^N Type's visited. This patch removed the double work and detects when a FunctionProtoType decays to itself to only check the Type once. This lowers the exponential runtime to linear runtime. Fixes https://bugs.llvm.org/show_bug.cgi?id=41625 llvm-svn: 359960
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Misc typos fixes in ./lib folderRaphael Isemann2018-12-101-1/+1
| | | | | | | | | | | | | | Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned` Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55475 llvm-svn: 348755
* [ODRHash] Fix early exit that skipped code.Richard Trieu2018-09-141-3/+9
| | | | | | | | | | There is a bit of code at the end of AddDeclaration that should be run on every exit of the function. However, there was an early exit beforehand that could be triggered, which causes a small amount of data to skip the hashing, leading to false positive mismatch. Use a separate function so that this code is always run. llvm-svn: 342199
* [ODRHash] Extend hash to support all Type's.Richard Trieu2018-09-041-25/+231
| | | | llvm-svn: 341421
* [ODRHash] Support hashing enums.Richard Trieu2018-07-251-1/+35
| | | | llvm-svn: 337978
* [ODRHash] Merge the two function hashes into one.Richard Trieu2018-07-101-37/+56
| | | | | | | | | | | Functions that are a sub-Decl of a record were hashed differently than other functions. This change keeps the AddFunctionDecl function and the hash of records now calls this function. In addition, AddFunctionDecl has an option to perform a hash as if the body was absent, which is required for some checks after loading modules. Additional logic prevents multiple error message from being printed. llvm-svn: 336632
* [ODRHash] Do not rely on Type* when computing the hash.Vassil Vassilev2018-06-281-9/+0
| | | | | | | | | | | | | | | | | ODRHash aims to provide Cross-TU stable hashing. Making clang::Type pointer part of the hash connects (remotely) the ODRHash with the TU-specific ::Profile hasher. r332281 exposed the issue by changing the way the ASTContext different elaborated types if there is an owning tag. In that case, ODRHash stores two different types in its TypeMap which yields false ODR violation in modules. The current state of implementation shouldn't need the TypeMap concept anymore. Rip it out. Differential Revision: https://reviews.llvm.org/D48524 llvm-svn: 335853
* [ODRHash] Adjust info stored for FunctionTemplateDecl.Richard Trieu2018-06-071-1/+1
| | | | | | | Avoid storing information for definitions since those can be out-of-line and vary between modules even when the declarations are the same. llvm-svn: 334151
* [ODRHash] Support FunctionTemplateDecl in records.Richard Trieu2018-05-301-0/+21
| | | | llvm-svn: 333486
* [ODRHash] Hash template arguments of methods.Richard Trieu2018-04-251-0/+11
| | | | llvm-svn: 330789
* [ODRHash] Support pointer and reference types.Richard Trieu2018-04-131-0/+18
| | | | | | | Recommit r328404 which was reverted in rL328404. r329869 fixed the issue that caused the revert. llvm-svn: 330074
* [ODRHash] Skip more types hashing TypedefTypeRichard Trieu2018-04-121-3/+13
| | | | | | To get the underlying type for TypedefType's, also skip ElaboratedType's. llvm-svn: 329869
* Temporarily revert r328404:Eric Christopher2018-04-021-18/+0
| | | | | | | | | | | | | | commit 519b97132a4c960e8dedbfe4290d86970d92e995 Author: Richard Trieu <rtrieu@google.com> Date: Sat Mar 24 00:52:44 2018 +0000 [ODRHash] Support pointer and reference types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328404 91177308-0d34-0410-b5e6-96231b3b80d8 As it's breaking some tests. I've communicated with Richard offline about testcases. llvm-svn: 329001
* [ODRHash] Support pointer and reference types.Richard Trieu2018-03-241-0/+18
| | | | llvm-svn: 328404
* [ODRHash] Fix hashing for friend functions.Richard Trieu2018-02-221-3/+0
| | | | | | | When hashing a templated function, use the hash of the function it was instantiated from. llvm-svn: 325742
* [ODRHash] Handle some template weirdness.Richard Trieu2018-02-221-14/+15
| | | | | | | | Build the index off of DeclarationName instead of Decl pointers. When finding an UnresolvedLookupExprClass, hash it as if it were a DeclRefExpr. This will allow methods to be hashed. llvm-svn: 325741
* [ODRHash] Don't hash friend functions.Richard Trieu2018-01-121-0/+2
| | | | | | | | In certain combinations of templated classes and friend functions, the body of friend functions does not get propagated along with function signature. Exclude friend functions for hashing to avoid this case. llvm-svn: 322350
* [ODRHash] Disable hashing on methods.Richard Trieu2017-12-231-0/+3
| | | | | | | Turn off hashing for class methods, but leave it on for other functions. This should get the buildbot to green for the time being. llvm-svn: 321396
* [ODRHash] Support ODR violation detection in functions.Richard Trieu2017-12-231-0/+30
| | | | | | | Extend the hashing to functions, which allows detection of function definition mismatches across modules. This is a re-commit of r320230. llvm-svn: 321395
* [ODRHash] Canonicalize Decl's before processing.Richard Trieu2017-12-211-0/+1
| | | | | | | Canonicalizing the Decl before processing it as part of the hash should reduce issues with non-canonical types showing up as mismatches. llvm-svn: 321319
* Revert r320230 to fix buildbots.Richard Trieu2017-12-091-30/+0
| | | | llvm-svn: 320239
* [ODRHash] Support ODR violation detection in functions.Richard Trieu2017-12-091-0/+30
| | | | | | | Extend the hashing to functions, which allows detection of function definition mismatches across modules. llvm-svn: 320230
* [ODRHash] Add base classes to hashing CXXRecordDecl.Richard Trieu2017-09-301-0/+8
| | | | llvm-svn: 314581
* [ODRHash] Diagnose differing template parameters.Richard Trieu2017-08-231-1/+54
| | | | llvm-svn: 311519
* [ODRHash] Move into anonymous namespace. NFC.Benjamin Kramer2017-08-201-0/+4
| | | | llvm-svn: 311286
* [ODRHash] Treat some non-templated classes as templated.Richard Trieu2017-08-051-2/+6
| | | | | | | | | | When using nested classes, if the inner class is not templated, but the outer class is templated, the inner class will not be templated, but may have some traits as if it were. This is particularly evident if the inner class refers to the outer class in some fashion. Treat any class that is in the context of a templated class as also a templated class. llvm-svn: 310158
* [ODRHash] Revert r307743 which reverted r307720Richard Trieu2017-07-151-0/+2
| | | | | | | Reapply r307720 to allow processing of constructors and destructors. Reuse the diagnostics for CXXMethodDecl for them. llvm-svn: 308077
* [ODRHash] Avoid taking the types of FunctionDecl'sRichard Trieu2017-07-141-1/+5
| | | | | | | | FunctionDecl already hashes most of the information in the function's type. Add hashing of the return type, and skip hashing the function's type to avoid redundancy and extra work when computing the hash. llvm-svn: 307986
* [ODRHash] Revert r307720 to fix buildbot.Richard Trieu2017-07-121-2/+0
| | | | llvm-svn: 307743
* [ODRHash] Support more method types.Richard Trieu2017-07-111-0/+2
| | | | | | | Hash CXXConstructorDecl and CXXDestructorDecl. Extend the diagnostics from CXXMethodDecl to include constructors and destructors. llvm-svn: 307720
* [ODRHash] Support FriendDeclRichard Trieu2017-07-081-0/+18
| | | | llvm-svn: 307458
* [ODRHash] Revert r305104 - Skip inline namespaces when hashing.Richard Trieu2017-07-011-18/+9
| | | | | | Test inline namespaces and handle them in the ODR hash again. llvm-svn: 306926
* [ODRHash] Support Type TemplateArgumentRichard Trieu2017-06-301-0/+3
| | | | llvm-svn: 306904
* [ODRHash] Improve typedef handling.Richard Trieu2017-06-291-1/+14
| | | | | | | Follow typedef chains to find the root type when processing types, and also keep track of qualifiers. llvm-svn: 306753
* [ODRHash] Hash VarDecl members.Richard Trieu2017-06-161-0/+12
| | | | | | | 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
* [ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmTypeRichard Trieu2017-06-151-0/+11
| | | | llvm-svn: 305440
* [ODRHash] Remove debugging code from r305361Richard Trieu2017-06-141-1/+0
| | | | llvm-svn: 305362
* [ODRHash] Hash Template and TemplateExpansion in TemplateArgument.Richard Trieu2017-06-141-0/+3
| | | | llvm-svn: 305361
* [ODRHash] Hash Expr for TemplateArgument::ExpressionRichard Trieu2017-06-141-0/+16
| | | | llvm-svn: 305360
* [ODRHash] Add TemplateArgument kind to hash.Richard Trieu2017-06-131-1/+5
| | | | llvm-svn: 305328
* Revert r305110 to fix buildbotRichard Trieu2017-06-091-19/+1
| | | | llvm-svn: 305130
* [ODRHash] Add support for TemplateArgument types.Richard Trieu2017-06-091-1/+19
| | | | | | | Recommit r304592 that was reverted in r304618. r305104 should have fixed the issue. llvm-svn: 305110
* [ODRHash] Skip inline namespaces when hashing.Richard Trieu2017-06-091-9/+18
| | | | | | | Speculatively try to fix the underlying issue from r304592, of underlying types being confused when inline namespaces are used. llvm-svn: 305104
* Revert r304592Richard Trieu2017-06-031-19/+1
| | | | | | | r304592 - [ODRHash] Add support for TemplateArgument types. Possibly causing one of the errors in modules build bot. llvm-svn: 304618
OpenPOWER on IntegriCloud