Skip to content

Commit da3fdea

Browse files
authored
Merge branch 'main' into fix/161070
2 parents 1284b5a + 30b0215 commit da3fdea

File tree

107 files changed

+4667
-1531
lines changed

Some content is hidden

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

107 files changed

+4667
-1531
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ Bug Fixes to C++ Support
432432
- Fix an assertion failure when taking the address on a non-type template parameter argument of
433433
object type. (#GH151531)
434434
- Suppress ``-Wdouble-promotion`` when explicitly asked for with C++ list initialization (#GH33409).
435+
- Fix the result of `__builtin_is_implicit_lifetime` for types with a user-provided constructor. (#GH160610)
435436
- Fixed a crash in the pre-C++23 warning for attributes before a lambda declarator (#GH161070).
436437

437438
Bug Fixes to AST Handling

clang/include/clang/Basic/AMDGPUTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#endif
2222

2323
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy, 128, 128, 8)
24+
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_texture_t", AMDGPUTexture, AMDGPUTextureTy, 256, 256, 0)
2425

2526
AMDGPU_NAMED_BARRIER_TYPE("__amdgpu_named_workgroup_barrier_t", AMDGPUNamedWorkgroupBarrier, AMDGPUNamedWorkgroupBarrierTy, 128, 32, 0)
2627

clang/include/clang/Basic/Builtins.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
// Q -> target builtin type, followed by a character to distinguish the builtin type
3535
// Qa -> AArch64 svcount_t builtin type.
3636
// Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type.
37+
// Qt -> AMDGPU __amdgpu_texture_t builtin type.
3738
// E -> ext_vector, followed by the number of elements and the base type.
3839
// X -> _Complex, followed by the base type.
3940
// Y -> ptrdiff_t

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12590,6 +12590,10 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
1259012590
Type = Context.AMDGPUBufferRsrcTy;
1259112591
break;
1259212592
}
12593+
case 't': {
12594+
Type = Context.AMDGPUTextureTy;
12595+
break;
12596+
}
1259312597
default:
1259412598
llvm_unreachable("Unexpected target builtin type");
1259512599
}

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/AST/DeclObjC.h"
2727
#include "clang/AST/DeclTemplate.h"
2828
#include "clang/AST/Expr.h"
29+
#include "clang/AST/LambdaCapture.h"
2930
#include "clang/AST/RecordLayout.h"
3031
#include "clang/AST/RecursiveASTVisitor.h"
3132
#include "clang/AST/VTableBuilder.h"
@@ -1903,46 +1904,61 @@ CGDebugInfo::createInlinedSubprogram(StringRef FuncName,
19031904
return SP;
19041905
}
19051906

1907+
llvm::StringRef
1908+
CGDebugInfo::GetLambdaCaptureName(const LambdaCapture &Capture) {
1909+
if (Capture.capturesThis())
1910+
return CGM.getCodeGenOpts().EmitCodeView ? "__this" : "this";
1911+
1912+
assert(Capture.capturesVariable());
1913+
1914+
const ValueDecl *CaptureDecl = Capture.getCapturedVar();
1915+
assert(CaptureDecl && "Expected valid decl for captured variable.");
1916+
1917+
return CaptureDecl->getName();
1918+
}
1919+
19061920
void CGDebugInfo::CollectRecordLambdaFields(
19071921
const CXXRecordDecl *CXXDecl, SmallVectorImpl<llvm::Metadata *> &elements,
19081922
llvm::DIType *RecordTy) {
19091923
// For C++11 Lambdas a Field will be the same as a Capture, but the Capture
19101924
// has the name and the location of the variable so we should iterate over
19111925
// both concurrently.
1912-
const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(CXXDecl);
19131926
RecordDecl::field_iterator Field = CXXDecl->field_begin();
19141927
unsigned fieldno = 0;
19151928
for (CXXRecordDecl::capture_const_iterator I = CXXDecl->captures_begin(),
19161929
E = CXXDecl->captures_end();
19171930
I != E; ++I, ++Field, ++fieldno) {
1918-
const LambdaCapture &C = *I;
1919-
if (C.capturesVariable()) {
1920-
SourceLocation Loc = C.getLocation();
1921-
assert(!Field->isBitField() && "lambdas don't have bitfield members!");
1922-
ValueDecl *V = C.getCapturedVar();
1923-
StringRef VName = V->getName();
1924-
llvm::DIFile *VUnit = getOrCreateFile(Loc);
1925-
auto Align = getDeclAlignIfRequired(V, CGM.getContext());
1926-
llvm::DIType *FieldType = createFieldType(
1927-
VName, Field->getType(), Loc, Field->getAccess(),
1928-
layout.getFieldOffset(fieldno), Align, VUnit, RecordTy, CXXDecl);
1929-
elements.push_back(FieldType);
1930-
} else if (C.capturesThis()) {
1931+
const LambdaCapture &Capture = *I;
1932+
const uint64_t FieldOffset =
1933+
CGM.getContext().getASTRecordLayout(CXXDecl).getFieldOffset(fieldno);
1934+
1935+
assert(!Field->isBitField() && "lambdas don't have bitfield members!");
1936+
1937+
SourceLocation Loc;
1938+
uint32_t Align = 0;
1939+
1940+
if (Capture.capturesThis()) {
19311941
// TODO: Need to handle 'this' in some way by probably renaming the
19321942
// this of the lambda class and having a field member of 'this' or
19331943
// by using AT_object_pointer for the function and having that be
19341944
// used as 'this' for semantic references.
1935-
FieldDecl *f = *Field;
1936-
llvm::DIFile *VUnit = getOrCreateFile(f->getLocation());
1937-
QualType type = f->getType();
1938-
StringRef ThisName =
1939-
CGM.getCodeGenOpts().EmitCodeView ? "__this" : "this";
1940-
llvm::DIType *fieldType = createFieldType(
1941-
ThisName, type, f->getLocation(), f->getAccess(),
1942-
layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
1943-
1944-
elements.push_back(fieldType);
1945+
Loc = Field->getLocation();
1946+
} else if (Capture.capturesVariable()) {
1947+
Loc = Capture.getLocation();
1948+
1949+
const ValueDecl *CaptureDecl = Capture.getCapturedVar();
1950+
assert(CaptureDecl && "Expected valid decl for captured variable.");
1951+
1952+
Align = getDeclAlignIfRequired(CaptureDecl, CGM.getContext());
1953+
} else {
1954+
continue;
19451955
}
1956+
1957+
llvm::DIFile *VUnit = getOrCreateFile(Loc);
1958+
1959+
elements.push_back(createFieldType(
1960+
GetLambdaCaptureName(Capture), Field->getType(), Loc,
1961+
Field->getAccess(), FieldOffset, Align, VUnit, RecordTy, CXXDecl));
19461962
}
19471963
}
19481964

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ class CGDebugInfo {
397397
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
398398
SmallVectorImpl<llvm::Metadata *> &E,
399399
llvm::DICompositeType *RecordTy);
400+
llvm::StringRef GetLambdaCaptureName(const LambdaCapture &Capture);
400401

401402
/// If the C++ class has vtable info then insert appropriate debug
402403
/// info entry in EltTys vector.

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6613,6 +6613,9 @@ std::string Driver::GetStdModuleManifestPath(const Compilation &C,
66136613
const ToolChain &TC) const {
66146614
std::string error = "<NOT PRESENT>";
66156615

6616+
if (C.getArgs().hasArg(options::OPT_nostdlib))
6617+
return error;
6618+
66166619
switch (TC.GetCXXStdlibType(C.getArgs())) {
66176620
case ToolChain::CST_Libcxx: {
66186621
auto evaluate = [&](const char *library) -> std::optional<std::string> {

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,9 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,
983983
case UninitUse::AfterDecl:
984984
case UninitUse::AfterCall:
985985
S.Diag(VD->getLocation(), diag::warn_sometimes_uninit_var)
986-
<< VD->getDeclName() << IsCapturedByBlock
987-
<< (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)
988-
<< const_cast<DeclContext*>(VD->getLexicalDeclContext())
989-
<< VD->getSourceRange();
986+
<< VD->getDeclName() << IsCapturedByBlock
987+
<< (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)
988+
<< VD->getLexicalDeclContext() << VD->getSourceRange();
990989
S.Diag(Use.getUser()->getBeginLoc(), diag::note_uninit_var_use)
991990
<< IsCapturedByBlock << Use.getUser()->getSourceRange();
992991
return;

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ DiagRecursiveConstraintEval(Sema &S, llvm::FoldingSetNodeID &ID,
193193
// Sema::InstantiatingTemplate::isAlreadyBeingInstantiated function.
194194
if (S.SatisfactionStackContains(Templ, ID)) {
195195
S.Diag(E->getExprLoc(), diag::err_constraint_depends_on_self)
196-
<< const_cast<Expr *>(E) << E->getSourceRange();
196+
<< E << E->getSourceRange();
197197
return true;
198198
}
199199

clang/lib/Sema/SemaOpenACCAtomic.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,7 @@ class AtomicOperandChecker {
454454
// If nothing matches, error out.
455455
DiagnoseInvalidAtomic(BinInf->FoundExpr->getExprLoc(),
456456
SemaRef.PDiag(diag::note_acc_atomic_mismatch_operand)
457-
<< const_cast<Expr *>(AssignInf.LHS)
458-
<< const_cast<Expr *>(BinInf->LHS)
459-
<< const_cast<Expr *>(BinInf->RHS));
457+
<< AssignInf.LHS << BinInf->LHS << BinInf->RHS);
460458
return IDACInfo::Fail();
461459
}
462460

@@ -592,8 +590,7 @@ class AtomicOperandChecker {
592590

593591
PartialDiagnostic PD =
594592
SemaRef.PDiag(diag::note_acc_atomic_mismatch_compound_operand)
595-
<< FirstKind << const_cast<Expr *>(FirstX) << SecondKind
596-
<< const_cast<Expr *>(SecondX);
593+
<< FirstKind << FirstX << SecondKind << SecondX;
597594

598595
return DiagnoseInvalidAtomic(SecondX->getExprLoc(), PD);
599596
}

0 commit comments

Comments
 (0)