[PATCH] D72281: [Matrix] Add matrix type to Clang.
Florian Hahn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 6 10:46:49 PDT 2020
fhahn updated this revision to Diff 262413.
fhahn marked 2 inline comments as done.
fhahn added a comment.
Fix template deduction.
In D72281#2022004 <https://reviews.llvm.org/D72281#2022004>, @rjmccall wrote:
> > The type of m1 matches the matrix argument in all 3 definitions of use_matrix and for some reason the return type is not used to disambiguate the definitions:
>
> C++ does not have the ability to use return types to disambiguate function calls.
>
> > I am not sure where things are going wrong unfortunately. The matrix argument deduction should mirror the code for types like DependentSizedArrayType. Do you have any idea what could be missing?
>
> This is what function template partial ordering is supposed to do. You'll see that it works if you replace the definition of `matrix` to use array types:
Ah right, thanks for clarifying. I think I managed to fix the remaining problems. Previously the patch did not handle DependentSizedMatrixTypes with non-dependent constant dimensions properly (e.g. a DependentSizedMatrixType could have one dependent and one non-dependent dimension). That's a difference to DependentSizedArrayType. Now the example works as expected (I've etxended it a bit). Cases like the one below are rejected
template <class T, unsigned long R, unsigned long C>
using matrix = T __attribute__((matrix_type(R, C)));
template <class T, unsigned long R>
void use_matrix(matrix<T, R, 10> &m) {}
// expected-note at -1 {{candidate function [with T = float, R = 10]}}
template <class T, unsigned long C>
void use_matrix(matrix<T, 10, C> &m) {}
// expected-note at -1 {{candidate function [with T = float, C = 10]}}
void test_ambigous_deduction1() {
matrix<float, 10, 10> m;
use_matrix(m);
// expected-error at -1 {{call to 'use_matrix' is ambiguous}}
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72281/new/
https://reviews.llvm.org/D72281
Files:
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeLoc.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TypeNodes.td
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/TypeBitCodes.def
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGen/debug-info-matrix-types.c
clang/test/CodeGen/matrix-type.c
clang/test/CodeGenCXX/matrix-type.cpp
clang/test/Parser/matrix-type-disabled.c
clang/test/SemaCXX/matrix-type.cpp
clang/tools/libclang/CIndex.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72281.262413.patch
Type: text/x-patch
Size: 102778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200506/c7ec7fb7/attachment-0001.bin>
More information about the cfe-commits
mailing list