llvm-project/clang/lib/AST
Yuanfang Chen 340eac01f7 [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions
This implementation matches GCC behavior in that [[ https://eel.is/c++draft/temp.func.order#6.2.1 | temp.func.order p6.2.1 ]] is not implemented [1]. I reached out to the GCC author to confirm that some changes elsewhere to overload resolution are probably needed, but no solution has been developed sufficiently [3].

Most of the wordings are implemented straightforwardly. However,
for [[ https://eel.is/c++draft/temp.func.order#6.2.2 | temp.func.order p6.2.2 ]] "... or if the function parameters that positionally correspond between the two templates are not of the same type", the "same type" is not very clear ([2] is a bug related to this). Here is a quick example
```
template <C T, C U>        int f(T, U);
template <typename T, C U> int f(U, T);

int x = f(0, 0);
```
Is the `U` and `T` from different `f`s the "same type"? The answer is NO even though both `U` and `T` are deduced to be `int` in this case. The reason is that `U` and `T` are dependent types, according to [[ https://eel.is/c++draft/temp.over.link#3 |  temp.over.link p3 ]], they can not be the "same type".

To check if two function parameters are the "same type":
* For //function template//: compare the function parameter canonical types and return type between two function templates.
* For //class template/partial specialization//: by [[ https://eel.is/c++draft/temp.spec.partial.order#1.2 | temp.spec.partial.order p1.2 ]], compare the injected template arguments between two templates using hashing(TemplateArgument::Profile) is enough.

[1] https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=57b4daf8dc4ed7b669cc70638866ddb00f5b7746
[2] https://github.com/llvm/llvm-project/issues/49308
[3] https://lists.isocpp.org/core/2020/06/index.php#msg9392

Fixes https://github.com/llvm/llvm-project/issues/54039
Fixes https://github.com/llvm/llvm-project/issues/49308 (PR49964)

Reviewed By: royjacobson, #clang-language-wg, mizvekov

Differential Revision: https://reviews.llvm.org/D128750
2022-10-18 11:58:57 -07:00
..
Interp [clang] Use llvm::reverse (NFC) 2022-10-15 21:54:13 -07:00
APValue.cpp [clang] add APValue type check in `TryPrintAsStringLiteral` 2022-08-10 08:42:59 +08:00
ASTConcept.cpp Reapply "[Concepts] Recover properly from a RecoveryExpr in a concept" 2022-09-26 08:39:10 -07:00
ASTConsumer.cpp
ASTContext.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
ASTDiagnostic.cpp Properly print unnamed TagDecl objects in diagnostics 2022-10-14 08:18:28 -04:00
ASTDumper.cpp [clang]: Add DeclContext::dumpAsDecl(). 2022-10-03 17:25:44 -04:00
ASTImporter.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
ASTImporterLookupTable.cpp [clang][ASTImporter] Update lookup table correctly at deduction guides. 2021-12-06 20:40:16 +01:00
ASTStructuralEquivalence.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
ASTTypeTraits.cpp [clang] Add `ObjCProtocolLoc` to represent protocol references 2022-02-18 15:24:00 -05:00
AttrDocTable.cpp [clang] Use std::size instead of llvm::array_lengthof 2022-09-08 17:20:25 -06:00
AttrImpl.cpp [OpenMP][NFC] Use OMPInteropInfo in the OMPDeclareVariantAttr attribute 2022-08-22 10:41:16 -07:00
CMakeLists.txt [ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC. 2022-09-07 14:40:37 -07:00
CXXABI.h [clang] Remove unused forward declarations (NFC) 2022-01-08 11:56:40 -08:00
CXXInheritance.cpp [clang] Don't include SetVector.h (NFC) 2022-09-17 13:36:13 -07:00
Comment.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
CommentBriefParser.cpp [AST] Remove an unnecessary continue (NFC) 2021-12-11 23:04:08 -08:00
CommentCommandTraits.cpp [clang] Use std::size instead of llvm::array_lengthof 2022-09-08 17:20:25 -06:00
CommentLexer.cpp [Clang][Comments] Parse `<img src=""/>` in doc comments correctly 2022-09-01 13:17:42 +01:00
CommentParser.cpp Resolve overload ambiguity on Mac OS when printing size_t in diagnostics 2022-05-14 12:37:36 +02:00
CommentSema.cpp Comment parsing: Allow inline commands to have 0 or more than 1 argument 2022-05-13 13:48:46 +02:00
ComparisonCategories.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
ComputeDependence.cpp Reapply "[Concepts] Recover properly from a RecoveryExpr in a concept" 2022-09-26 08:39:10 -07:00
DataCollection.cpp
Decl.cpp [OpenMP] Make device functions have hidden visibility 2022-10-18 08:15:39 -05:00
DeclBase.cpp [NFC] Replace use of !isTranslationUnit && !isNamespace with !isFileContext 2022-10-06 09:40:51 -07:00
DeclCXX.cpp Properly print unnamed TagDecl objects in diagnostics 2022-10-14 08:18:28 -04:00
DeclFriend.cpp
DeclGroup.cpp
DeclObjC.cpp [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches. 2022-10-17 16:29:52 -07:00
DeclOpenMP.cpp
DeclPrinter.cpp Properly print unnamed TagDecl objects in diagnostics 2022-10-14 08:18:28 -04:00
DeclTemplate.cpp [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions 2022-10-18 11:58:57 -07:00
DeclarationName.cpp [NFC][AST] Return underlying strings directly instead of OS.str() 2021-12-09 16:05:46 -08:00
Expr.cpp [C2x] Implement support for nullptr and nullptr_t 2022-10-14 10:06:02 -04:00
ExprCXX.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
ExprClassification.cpp [Clang] Implement __builtin_source_location. 2022-03-28 18:29:02 -04:00
ExprConcepts.cpp [clang] Remove redundant member initialization (NFC) 2022-01-02 10:20:23 -08:00
ExprConstant.cpp [Clang] Support constexpr builtin fmin 2022-10-10 16:06:23 +00:00
ExprObjC.cpp [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr 2021-07-28 23:27:43 +02:00
ExternalASTMerger.cpp [clang] Use llvm::erase_if (NFC) 2021-10-17 13:50:29 -07:00
ExternalASTSource.cpp
FormatString.cpp [clang][Sema] check default argument promotions for printf 2022-09-01 10:10:10 +08:00
FormatStringParsing.h
InheritViz.cpp
ItaniumCXXABI.cpp Change __builtin_sycl_unique_stable_name to just use an Itanium mangling 2021-09-28 06:41:03 -07:00
ItaniumMangle.cpp [clang] adds unary type transformations as compiler built-ins 2022-08-22 03:03:32 +00:00
JSONNodeDumper.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
Linkage.h
Mangle.cpp [HLSL] Initial codegen for SV_GroupIndex 2022-08-25 11:17:54 -05:00
MicrosoftCXXABI.cpp [clang]Silence warning in MicrosoftCXXABI.cpp 2022-05-12 12:04:05 -04:00
MicrosoftMangle.cpp Add APFloat and MLIR type support for fp8 (e5m2). 2022-10-04 17:18:17 -07:00
NSAPI.cpp [Clang] Add __ibm128 type to represent ppc_fp128 2021-09-06 18:00:58 +08:00
NestedNameSpecifier.cpp Properly print unnamed TagDecl objects in diagnostics 2022-10-14 08:18:28 -04:00
ODRDiagsEmitter.cpp [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches. 2022-10-17 18:48:24 -07:00
ODRHash.cpp [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches. 2022-10-17 18:48:24 -07:00
OSLog.cpp [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC] 2022-06-29 18:28:51 +02:00
OpenMPClause.cpp [clang] Qualify auto in range-based for loops (NFC) 2022-09-03 23:27:27 -07:00
ParentMap.cpp Use DenseMap::lookup (NFC) 2021-12-17 18:19:25 -08:00
ParentMapContext.cpp [AST] Use std::apply to pop front of tuples. NFCI. 2022-08-25 00:03:08 +02:00
PrintfFormatString.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
QualTypeNames.cpp Preserve qualifiers when getting fully qualified type 2022-07-29 19:42:54 -07:00
Randstruct.cpp [randstruct] Randomize all elements of a record 2022-04-28 12:01:11 -07:00
RawCommentList.cpp [clang][extract-api] Add global record support 2022-03-16 15:13:55 -07:00
RecordLayout.cpp
RecordLayoutBuilder.cpp Itanium ABI: Pack non-pod members of packed types 2022-10-14 19:32:57 +00:00
ScanfFormatString.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
SelectorLocationsKind.cpp
Stmt.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
StmtCXX.cpp [C++20] [Coroutines] Implement return value optimization for get_return_object 2022-02-16 13:38:00 +08:00
StmtIterator.cpp
StmtObjC.cpp [clang] Convert ObjCAtTryStmt to llvm::TrailingObjects 2021-10-27 08:57:05 -04:00
StmtOpenMP.cpp [OpenMP] Initial parsing and semantic support for 'parallel masked taskloop simd' construct 2022-07-01 08:57:15 -07:00
StmtPrinter.cpp [LLDB] Fix crash when printing a struct with a static wchar_t member 2022-10-11 11:04:32 -07:00
StmtProfile.cpp [clang] Qualify auto in range-based for loops (NFC) 2022-09-03 23:27:27 -07:00
StmtViz.cpp
TemplateBase.cpp [clang] fix profiling of template arguments of template and declaration kind 2022-09-06 18:27:39 +02:00
TemplateName.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
TextNodeDumper.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
Type.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
TypeLoc.cpp [C2x] implement typeof and typeof_unqual 2022-09-28 13:27:52 -04:00
TypePrinter.cpp [clang] Track the templated entity in type substitution. 2022-10-15 22:08:36 +02:00
VTTBuilder.cpp
VTableBuilder.cpp [clang] Add a raw_ostream operator<< overload for QualType 2022-04-20 22:09:05 +01:00