Skip to content

Commit 5147b27

Browse files
committed
Merge branch 'main' into hgh/libcxx/P2255R2-A_type_trait_to_detect_reference_binding_to_temporary
2 parents 0f34c04 + 94f6b6d commit 5147b27

File tree

167 files changed

+4814
-1574
lines changed

Some content is hidden

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

167 files changed

+4814
-1574
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ jobs:
255255
- name: Install a current LLVM
256256
if: ${{ matrix.mingw != true }}
257257
run: |
258-
choco install -y llvm --version=18.1.6 --allow-downgrade
258+
choco install -y llvm --version=19.1.7 --allow-downgrade
259259
- name: Install llvm-mingw
260260
if: ${{ matrix.mingw == true }}
261261
run: |
262-
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20240606/llvm-mingw-20240606-ucrt-x86_64.zip
262+
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-x86_64.zip
263263
powershell Expand-Archive llvm-mingw*.zip -DestinationPath .
264264
del llvm-mingw*.zip
265265
mv llvm-mingw* c:\llvm-mingw

clang/include/clang/Basic/arm_sve.td

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4392,11 +4392,11 @@ class Sema final : public SemaBase {
43924392
// Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
43934393
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee);
43944394

4395-
private:
43964395
/// Function or variable declarations to be checked for whether the deferred
43974396
/// diagnostics should be emitted.
43984397
llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
43994398

4399+
private:
44004400
/// Map of current shadowing declarations to shadowed declarations. Warn if
44014401
/// it looks like the user is trying to modify the shadowing declaration.
44024402
llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10223,6 +10223,7 @@ llvm::Type *CodeGenFunction::getEltType(const SVETypeFlags &TypeFlags) {
1022310223
default:
1022410224
llvm_unreachable("Invalid SVETypeFlag!");
1022510225

10226+
case SVETypeFlags::EltTyMFloat8:
1022610227
case SVETypeFlags::EltTyInt8:
1022710228
return Builder.getInt8Ty();
1022810229
case SVETypeFlags::EltTyInt16:
@@ -10651,7 +10652,7 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const CallExpr *E,
1065110652
unsigned IntrinsicID,
1065210653
bool IsZExtReturn) {
1065310654
QualType LangPTy = E->getArg(1)->getType();
10654-
llvm::Type *MemEltTy = CGM.getTypes().ConvertType(
10655+
llvm::Type *MemEltTy = CGM.getTypes().ConvertTypeForMem(
1065510656
LangPTy->castAs<PointerType>()->getPointeeType());
1065610657

1065710658
// The vector type that is returned may be different from the
@@ -10698,7 +10699,7 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const CallExpr *E,
1069810699
SmallVectorImpl<Value *> &Ops,
1069910700
unsigned IntrinsicID) {
1070010701
QualType LangPTy = E->getArg(1)->getType();
10701-
llvm::Type *MemEltTy = CGM.getTypes().ConvertType(
10702+
llvm::Type *MemEltTy = CGM.getTypes().ConvertTypeForMem(
1070210703
LangPTy->castAs<PointerType>()->getPointeeType());
1070310704

1070410705
// The vector type that is stored may be different from the

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) {
107107
MT->getNumRows() * MT->getNumColumns());
108108
}
109109

110+
if (T->isMFloat8Type())
111+
return llvm::Type::getInt8Ty(getLLVMContext());
112+
110113
llvm::Type *R = ConvertType(T);
111114

112115
// Check for the boolean vector case.

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
28832883
/*ReadDirectiveWithinMetadirective=*/true);
28842884
break;
28852885
}
2886+
// If no match is found and no otherwise clause is present, skip
2887+
// OMP5.2 Chapter 7.4: If no otherwise clause is specified the effect is as
2888+
// if one was specified without an associated directive variant.
2889+
if (BestIdx == -1 && Idx == 1) {
2890+
assert(Tok.is(tok::annot_pragma_openmp_end) &&
2891+
"Expecting the end of the pragma here");
2892+
ConsumeAnnotationToken();
2893+
return StmtEmpty();
2894+
}
28862895
break;
28872896
}
28882897
case OMPD_threadprivate: {

clang/lib/Sema/Sema.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,47 @@ class DeferredDiagnosticsEmitter
17981798
Inherited::visitUsedDecl(Loc, D);
17991799
}
18001800

1801+
// Visitor member and parent dtors called by this dtor.
1802+
void VisitCalledDestructors(CXXDestructorDecl *DD) {
1803+
const CXXRecordDecl *RD = DD->getParent();
1804+
1805+
// Visit the dtors of all members
1806+
for (const FieldDecl *FD : RD->fields()) {
1807+
QualType FT = FD->getType();
1808+
if (const auto *RT = FT->getAs<RecordType>())
1809+
if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1810+
if (ClassDecl->hasDefinition())
1811+
if (CXXDestructorDecl *MemberDtor = ClassDecl->getDestructor())
1812+
asImpl().visitUsedDecl(MemberDtor->getLocation(), MemberDtor);
1813+
}
1814+
1815+
// Also visit base class dtors
1816+
for (const auto &Base : RD->bases()) {
1817+
QualType BaseType = Base.getType();
1818+
if (const auto *RT = BaseType->getAs<RecordType>())
1819+
if (const auto *BaseDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1820+
if (BaseDecl->hasDefinition())
1821+
if (CXXDestructorDecl *BaseDtor = BaseDecl->getDestructor())
1822+
asImpl().visitUsedDecl(BaseDtor->getLocation(), BaseDtor);
1823+
}
1824+
}
1825+
1826+
void VisitDeclStmt(DeclStmt *DS) {
1827+
// Visit dtors called by variables that need destruction
1828+
for (auto *D : DS->decls())
1829+
if (auto *VD = dyn_cast<VarDecl>(D))
1830+
if (VD->isThisDeclarationADefinition() &&
1831+
VD->needsDestruction(S.Context)) {
1832+
QualType VT = VD->getType();
1833+
if (const auto *RT = VT->getAs<RecordType>())
1834+
if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1835+
if (ClassDecl->hasDefinition())
1836+
if (CXXDestructorDecl *Dtor = ClassDecl->getDestructor())
1837+
asImpl().visitUsedDecl(Dtor->getLocation(), Dtor);
1838+
}
1839+
1840+
Inherited::VisitDeclStmt(DS);
1841+
}
18011842
void checkVar(VarDecl *VD) {
18021843
assert(VD->isFileVarDecl() &&
18031844
"Should only check file-scope variables");
@@ -1839,6 +1880,8 @@ class DeferredDiagnosticsEmitter
18391880
if (auto *S = FD->getBody()) {
18401881
this->Visit(S);
18411882
}
1883+
if (CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(FD))
1884+
asImpl().VisitCalledDestructors(Dtor);
18421885
UsePath.pop_back();
18431886
InUsePath.erase(FD);
18441887
}

clang/lib/Sema/SemaCUDA.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,21 @@ bool SemaCUDA::inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
372372
CXXMethodDecl *MemberDecl,
373373
bool ConstRHS,
374374
bool Diagnose) {
375+
// If MemberDecl is virtual destructor of an explicit template class
376+
// instantiation, it must be emitted, therefore it needs to be inferred
377+
// conservatively by ignoring implicit host/device attrs of member and parent
378+
// dtors called by it. Also, it needs to be checed by deferred diag visitor.
379+
bool IsExpVDtor = false;
380+
if (isa<CXXDestructorDecl>(MemberDecl) && MemberDecl->isVirtual()) {
381+
if (auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(ClassDecl)) {
382+
TemplateSpecializationKind TSK = Spec->getTemplateSpecializationKind();
383+
IsExpVDtor = TSK == TSK_ExplicitInstantiationDeclaration ||
384+
TSK == TSK_ExplicitInstantiationDefinition;
385+
}
386+
}
387+
if (IsExpVDtor)
388+
SemaRef.DeclsToCheckForDeferredDiags.insert(MemberDecl);
389+
375390
// If the defaulted special member is defined lexically outside of its
376391
// owning class, or the special member already has explicit device or host
377392
// attributes, do not infer.

clang/lib/Sema/SemaDecl.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20473,6 +20473,21 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(const FunctionDecl *FD,
2047320473

2047420474
if (IsEmittedForExternalSymbol())
2047520475
return FunctionEmissionStatus::Emitted;
20476+
20477+
// If FD is a virtual destructor of an explicit instantiation
20478+
// of a template class, return Emitted.
20479+
if (auto *Destructor = dyn_cast<CXXDestructorDecl>(FD)) {
20480+
if (Destructor->isVirtual()) {
20481+
if (auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
20482+
Destructor->getParent())) {
20483+
TemplateSpecializationKind TSK =
20484+
Spec->getTemplateSpecializationKind();
20485+
if (TSK == TSK_ExplicitInstantiationDeclaration ||
20486+
TSK == TSK_ExplicitInstantiationDefinition)
20487+
return FunctionEmissionStatus::Emitted;
20488+
}
20489+
}
20490+
}
2047620491
}
2047720492

2047820493
// Otherwise, the function is known-emitted if it's in our set of

clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,9 @@ RegionStoreManager::bind(LimitedRegionBindingsConstRef B, Loc L, SVal V) {
25702570
LimitedRegionBindingsRef
25712571
RegionStoreManager::setImplicitDefaultValue(LimitedRegionBindingsConstRef B,
25722572
const MemRegion *R, QualType T) {
2573+
if (B.hasExhaustedBindingLimit())
2574+
return B;
2575+
25732576
SVal V;
25742577

25752578
if (Loc::isLocType(T))
@@ -2596,6 +2599,8 @@ RegionStoreManager::setImplicitDefaultValue(LimitedRegionBindingsConstRef B,
25962599
std::optional<LimitedRegionBindingsRef> RegionStoreManager::tryBindSmallArray(
25972600
LimitedRegionBindingsConstRef B, const TypedValueRegion *R,
25982601
const ArrayType *AT, nonloc::LazyCompoundVal LCV) {
2602+
if (B.hasExhaustedBindingLimit())
2603+
return B.withValuesEscaped(LCV);
25992604

26002605
auto CAT = dyn_cast<ConstantArrayType>(AT);
26012606

@@ -2632,6 +2637,8 @@ RegionStoreManager::bindArray(LimitedRegionBindingsConstRef B,
26322637
const TypedValueRegion *R, SVal Init) {
26332638
llvm::TimeTraceScope TimeScope("RegionStoreManager::bindArray",
26342639
[R]() { return R->getDescriptiveName(); });
2640+
if (B.hasExhaustedBindingLimit())
2641+
return B.withValuesEscaped(Init);
26352642

26362643
const ArrayType *AT =cast<ArrayType>(Ctx.getCanonicalType(R->getValueType()));
26372644
QualType ElementTy = AT->getElementType();
@@ -2698,6 +2705,9 @@ RegionStoreManager::bindVector(LimitedRegionBindingsConstRef B,
26982705
const TypedValueRegion *R, SVal V) {
26992706
llvm::TimeTraceScope TimeScope("RegionStoreManager::bindVector",
27002707
[R]() { return R->getDescriptiveName(); });
2708+
if (B.hasExhaustedBindingLimit())
2709+
return B.withValuesEscaped(V);
2710+
27012711
QualType T = R->getValueType();
27022712
const VectorType *VT = T->castAs<VectorType>(); // Use castAs for typedefs.
27032713

@@ -2722,6 +2732,9 @@ RegionStoreManager::bindVector(LimitedRegionBindingsConstRef B,
27222732
if (VI == VE)
27232733
break;
27242734

2735+
if (NewB.hasExhaustedBindingLimit())
2736+
return NewB.withValuesEscaped(VI, VE);
2737+
27252738
NonLoc Idx = svalBuilder.makeArrayIndex(index);
27262739
const ElementRegion *ER = MRMgr.getElementRegion(ElemType, Idx, R, Ctx);
27272740

@@ -2758,6 +2771,9 @@ RegionStoreManager::getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const {
27582771
std::optional<LimitedRegionBindingsRef> RegionStoreManager::tryBindSmallStruct(
27592772
LimitedRegionBindingsConstRef B, const TypedValueRegion *R,
27602773
const RecordDecl *RD, nonloc::LazyCompoundVal LCV) {
2774+
if (B.hasExhaustedBindingLimit())
2775+
return B.withValuesEscaped(LCV);
2776+
27612777
// If we try to copy a Conjured value representing the value of the whole
27622778
// struct, don't try to element-wise copy each field.
27632779
// That would unnecessarily bind Derived symbols slicing off the subregion for
@@ -2822,6 +2838,9 @@ RegionStoreManager::bindStruct(LimitedRegionBindingsConstRef B,
28222838
const TypedValueRegion *R, SVal V) {
28232839
llvm::TimeTraceScope TimeScope("RegionStoreManager::bindStruct",
28242840
[R]() { return R->getDescriptiveName(); });
2841+
if (B.hasExhaustedBindingLimit())
2842+
return B.withValuesEscaped(V);
2843+
28252844
QualType T = R->getValueType();
28262845
assert(T->isStructureOrClassType());
28272846

@@ -2931,6 +2950,9 @@ RegionStoreManager::bindStruct(LimitedRegionBindingsConstRef B,
29312950
++VI;
29322951
}
29332952

2953+
if (NewB.hasExhaustedBindingLimit())
2954+
return NewB.withValuesEscaped(VI, VE);
2955+
29342956
// There may be fewer values in the initialize list than the fields of struct.
29352957
if (FI != FE) {
29362958
NewB = NewB.addBinding(R, BindingKey::Default,
@@ -2945,6 +2967,9 @@ RegionStoreManager::bindAggregate(LimitedRegionBindingsConstRef B,
29452967
const TypedRegion *R, SVal Val) {
29462968
llvm::TimeTraceScope TimeScope("RegionStoreManager::bindAggregate",
29472969
[R]() { return R->getDescriptiveName(); });
2970+
if (B.hasExhaustedBindingLimit())
2971+
return B.withValuesEscaped(Val);
2972+
29482973
// Remove the old bindings, using 'R' as the root of all regions
29492974
// we will invalidate. Then add the new binding.
29502975
return removeSubRegionBindings(B, R).addBinding(R, BindingKey::Default, Val);

0 commit comments

Comments
 (0)