[AST] Use canonical constraint declaration for ASTContext::getAutoType
When we do profiling in ASTContext::getAutoType, it wouldn't think about the canonical declaration for the type constraint. It is bad since it would cause a negative ODR mismatch while we already know the type constraint declaration is a redeclaration for the previous one. Also it shouldn't be bad to use the canonical declaration here.
This commit is contained in:
parent
c9fb3c6ea6
commit
f4dd977537
|
@ -5707,6 +5707,9 @@ QualType ASTContext::getAutoTypeInternal(
|
|||
!TypeConstraintConcept && !IsDependent)
|
||||
return getAutoDeductType();
|
||||
|
||||
if (TypeConstraintConcept)
|
||||
TypeConstraintConcept = TypeConstraintConcept->getCanonicalDecl();
|
||||
|
||||
// Look in the folding set for an existing type.
|
||||
void *InsertPos = nullptr;
|
||||
llvm::FoldingSetNodeID ID;
|
||||
|
|
|
@ -1,10 +1,54 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: mkdir %t
|
||||
// RUN: %clang_cc1 -x c++ -std=c++20 %S/Inputs/concept/A.cppm -emit-module-interface -o %t/A.pcm
|
||||
// RUN: %clang_cc1 -x c++ -std=c++20 -fprebuilt-module-path=%t -I%S/Inputs/concept %s -fsyntax-only -verify
|
||||
// expected-no-diagnostics
|
||||
// RUN: split-file %s %t
|
||||
//
|
||||
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
|
||||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/B.cppm -verify
|
||||
|
||||
//--- foo.h
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
template <class T>
|
||||
concept Range = requires(T &t) { t.begin(); };
|
||||
|
||||
template<class _Tp>
|
||||
concept __integer_like = true;
|
||||
|
||||
template <class _Tp>
|
||||
concept __member_size = requires(_Tp &&t) { t.size(); };
|
||||
|
||||
struct A {
|
||||
public:
|
||||
template <Range T>
|
||||
using range_type = T;
|
||||
};
|
||||
|
||||
struct __fn {
|
||||
template <__member_size _Tp>
|
||||
constexpr __integer_like auto operator()(_Tp&& __t) const {
|
||||
return __t.size();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//--- A.cppm
|
||||
module;
|
||||
#include "foo.h"
|
||||
export module A;
|
||||
|
||||
//--- B.cppm
|
||||
// expected-no-diagnostics
|
||||
module;
|
||||
#include "foo.h"
|
||||
export module B;
|
||||
import A;
|
||||
|
||||
void foo() {
|
||||
A a;
|
||||
struct S {
|
||||
int size() { return 0; }
|
||||
auto operator+(S s) { return 0; }
|
||||
};
|
||||
__fn{}(S());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue