Skip to content

Commit abb0ec0

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge llvm/main into amd-debug
2 parents 0505057 + 0f391d6 commit abb0ec0

File tree

67 files changed

+2715
-2475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2715
-2475
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
544544
case clang::DiagnosticsEngine::ak_attr:
545545
Builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
546546
break;
547+
case clang::DiagnosticsEngine::ak_attr_info:
548+
Builder << reinterpret_cast<AttributeCommonInfo *>(Info.getRawArg(Index));
549+
break;
547550
case clang::DiagnosticsEngine::ak_addrspace:
548551
Builder << static_cast<LangAS>(Info.getRawArg(Index));
549552
break;

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ Bug Fixes to C++ Support
898898
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
899899
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
900900
- Fixed a function declaration mismatch that caused inconsistencies between concepts and variable template declarations. (#GH139476)
901+
- Fixed an out-of-line declaration mismatch involving nested template parameters. (#GH145521)
901902
- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616).
902903
- Fix an incorrect deduction when calling an explicit object member function template through an overload set address.
903904
- Fixed bug in constant evaluation that would allow using the value of a

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,10 @@ def note_unsatisfied_trait_reason
18121812
"%DeletedAssign{has a deleted %select{copy|move}1 "
18131813
"assignment operator}|"
18141814
"%UnionWithUserDeclaredSMF{is a union with a user-declared "
1815-
"%sub{select_special_member_kind}1}"
1815+
"%sub{select_special_member_kind}1}|"
1816+
"%FunctionType{is a function type}|"
1817+
"%CVVoidType{is a cv void type}|"
1818+
"%IncompleteArrayType{is an incomplete array type}"
18161819
"}0">;
18171820

18181821
def warn_consteval_if_always_true : Warning<

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
898898
Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo,
899899
const Expr *ConstrExpr) {
900900
MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
901-
DeclInfo.getDecl(), DeclInfo.getLexicalDeclContext(), /*Final=*/false,
901+
DeclInfo.getDecl(), DeclInfo.getDeclContext(), /*Final=*/false,
902902
/*Innermost=*/std::nullopt,
903903
/*RelativeToPrimary=*/true,
904904
/*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true,

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "clang/AST/DeclCXX.h"
14+
#include "clang/AST/TemplateBase.h"
1415
#include "clang/AST/Type.h"
16+
#include "clang/Basic/DiagnosticIDs.h"
1517
#include "clang/Basic/DiagnosticParse.h"
1618
#include "clang/Basic/DiagnosticSema.h"
1719
#include "clang/Basic/TypeTraits.h"
@@ -1963,6 +1965,7 @@ static std::optional<TypeTrait> StdNameToTypeTrait(StringRef Name) {
19631965
.Case("is_assignable", TypeTrait::BTT_IsAssignable)
19641966
.Case("is_empty", TypeTrait::UTT_IsEmpty)
19651967
.Case("is_standard_layout", TypeTrait::UTT_IsStandardLayout)
1968+
.Case("is_constructible", TypeTrait::TT_IsConstructible)
19661969
.Default(std::nullopt);
19671970
}
19681971

@@ -1999,8 +2002,16 @@ static ExtractedTypeTraitInfo ExtractTypeTraitFromExpression(const Expr *E) {
19992002
Trait = StdNameToTypeTrait(Name);
20002003
if (!Trait)
20012004
return std::nullopt;
2002-
for (const auto &Arg : VD->getTemplateArgs().asArray())
2003-
Args.push_back(Arg.getAsType());
2005+
for (const auto &Arg : VD->getTemplateArgs().asArray()) {
2006+
if (Arg.getKind() == TemplateArgument::ArgKind::Pack) {
2007+
for (const auto &InnerArg : Arg.pack_elements())
2008+
Args.push_back(InnerArg.getAsType());
2009+
} else if (Arg.getKind() == TemplateArgument::ArgKind::Type) {
2010+
Args.push_back(Arg.getAsType());
2011+
} else {
2012+
llvm_unreachable("Unexpected kind");
2013+
}
2014+
}
20042015
return {{Trait.value(), std::move(Args)}};
20052016
}
20062017

@@ -2273,6 +2284,60 @@ static void DiagnoseNonTriviallyCopyableReason(Sema &SemaRef,
22732284
}
22742285
}
22752286

2287+
static void DiagnoseNonConstructibleReason(
2288+
Sema &SemaRef, SourceLocation Loc,
2289+
const llvm::SmallVector<clang::QualType, 1> &Ts) {
2290+
if (Ts.empty()) {
2291+
return;
2292+
}
2293+
2294+
bool ContainsVoid = false;
2295+
for (const QualType &ArgTy : Ts) {
2296+
ContainsVoid |= ArgTy->isVoidType();
2297+
}
2298+
2299+
if (ContainsVoid)
2300+
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
2301+
<< diag::TraitNotSatisfiedReason::CVVoidType;
2302+
2303+
QualType T = Ts[0];
2304+
if (T->isFunctionType())
2305+
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
2306+
<< diag::TraitNotSatisfiedReason::FunctionType;
2307+
2308+
if (T->isIncompleteArrayType())
2309+
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
2310+
<< diag::TraitNotSatisfiedReason::IncompleteArrayType;
2311+
2312+
const CXXRecordDecl *D = T->getAsCXXRecordDecl();
2313+
if (!D || D->isInvalidDecl() || !D->hasDefinition())
2314+
return;
2315+
2316+
llvm::BumpPtrAllocator OpaqueExprAllocator;
2317+
SmallVector<Expr *, 2> ArgExprs;
2318+
ArgExprs.reserve(Ts.size() - 1);
2319+
for (unsigned I = 1, N = Ts.size(); I != N; ++I) {
2320+
QualType ArgTy = Ts[I];
2321+
if (ArgTy->isObjectType() || ArgTy->isFunctionType())
2322+
ArgTy = SemaRef.Context.getRValueReferenceType(ArgTy);
2323+
ArgExprs.push_back(
2324+
new (OpaqueExprAllocator.Allocate<OpaqueValueExpr>())
2325+
OpaqueValueExpr(Loc, ArgTy.getNonLValueExprType(SemaRef.Context),
2326+
Expr::getValueKindForType(ArgTy)));
2327+
}
2328+
2329+
EnterExpressionEvaluationContext Unevaluated(
2330+
SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
2331+
Sema::ContextRAII TUContext(SemaRef,
2332+
SemaRef.Context.getTranslationUnitDecl());
2333+
InitializedEntity To(InitializedEntity::InitializeTemporary(T));
2334+
InitializationKind InitKind(InitializationKind::CreateDirect(Loc, Loc, Loc));
2335+
InitializationSequence Init(SemaRef, To, InitKind, ArgExprs);
2336+
2337+
Init.Diagnose(SemaRef, To, InitKind, ArgExprs);
2338+
SemaRef.Diag(D->getLocation(), diag::note_defined_here) << D;
2339+
}
2340+
22762341
static void DiagnoseNonTriviallyCopyableReason(Sema &SemaRef,
22772342
SourceLocation Loc, QualType T) {
22782343
SemaRef.Diag(Loc, diag::note_unsatisfied_trait)
@@ -2559,6 +2624,9 @@ void Sema::DiagnoseTypeTraitDetails(const Expr *E) {
25592624
case UTT_IsStandardLayout:
25602625
DiagnoseNonStandardLayoutReason(*this, E->getBeginLoc(), Args[0]);
25612626
break;
2627+
case TT_IsConstructible:
2628+
DiagnoseNonConstructibleReason(*this, E->getBeginLoc(), Args);
2629+
break;
25622630
default:
25632631
break;
25642632
}

clang/test/CXX/drs/cwg18xx.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,12 @@ struct A {
564564
namespace ex2 {
565565
#if __cplusplus >= 201103L
566566
struct Bar {
567-
struct Baz {
567+
struct Baz { // #cwg1890-Baz
568568
int a = 0;
569569
};
570570
static_assert(__is_constructible(Baz), "");
571571
// since-cxx11-error@-1 {{static assertion failed due to requirement '__is_constructible(cwg1890::ex2::Bar::Baz)'}}
572+
// since-cxx11-note@#cwg1890-Baz {{'Baz' defined here}}
572573
};
573574
#endif
574575
} // namespace ex2

0 commit comments

Comments
 (0)