Skip to content

Commit d477327

Browse files
authored
merge main into amd-staging (llvm#1314)
2 parents bce01c0 + e0e5bf4 commit d477327

File tree

245 files changed

+6305
-1908
lines changed

Some content is hidden

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

245 files changed

+6305
-1908
lines changed

clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ class HeaderGuardPPCallbacks : public PPCallbacks {
8888
continue;
8989

9090
// Look up Locations for this guard.
91-
SourceLocation Ifndef =
92-
Ifndefs[MacroEntry.first.getIdentifierInfo()].second;
91+
const auto &Locs = Ifndefs[MacroEntry.first.getIdentifierInfo()];
92+
SourceLocation Ifndef = Locs.second;
9393
SourceLocation Define = MacroEntry.first.getLocation();
94-
SourceLocation EndIf =
95-
EndIfs[Ifndefs[MacroEntry.first.getIdentifierInfo()].first];
94+
SourceLocation EndIf = EndIfs[Locs.first];
9695

9796
// If the macro Name is not equal to what we can compute, correct it in
9897
// the #ifndef and #define.

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "PrimType.h"
1717
#include "Record.h"
1818
#include "Source.h"
19+
#include "clang/AST/ExprCXX.h"
1920

2021
using namespace clang;
2122
using namespace clang::interp;
@@ -453,6 +454,30 @@ QualType Descriptor::getElemQualType() const {
453454
return T;
454455
}
455456

457+
QualType Descriptor::getDataType(const ASTContext &Ctx) const {
458+
auto MakeArrayType = [&](QualType ElemType) -> QualType {
459+
if (IsArray)
460+
return Ctx.getConstantArrayType(
461+
ElemType, APInt(64, static_cast<uint64_t>(getNumElems()), false),
462+
nullptr, ArraySizeModifier::Normal, 0);
463+
return ElemType;
464+
};
465+
466+
if (const auto *E = asExpr()) {
467+
if (isa<CXXNewExpr>(E))
468+
return MakeArrayType(E->getType()->getPointeeType());
469+
470+
// std::allocator.allocate() call.
471+
if (const auto *ME = dyn_cast<CXXMemberCallExpr>(E);
472+
ME && ME->getRecordDecl()->getName() == "allocator" &&
473+
ME->getMethodDecl()->getName() == "allocate")
474+
return MakeArrayType(E->getType()->getPointeeType());
475+
return E->getType();
476+
}
477+
478+
return getType();
479+
}
480+
456481
SourceLocation Descriptor::getLocation() const {
457482
if (auto *D = dyn_cast<const Decl *>(Source))
458483
return D->getLocation();

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ struct Descriptor final {
207207

208208
QualType getType() const;
209209
QualType getElemQualType() const;
210+
QualType getDataType(const ASTContext &Ctx) const;
210211
SourceLocation getLocation() const;
211212
SourceInfo getLoc() const;
212213

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -979,17 +979,7 @@ bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC,
979979
if (AllocForm == DeleteForm)
980980
return true;
981981

982-
QualType TypeToDiagnose;
983-
// We need to shuffle things around a bit here to get a better diagnostic,
984-
// because the expression we allocated the block for was of type int*,
985-
// but we want to get the array size right.
986-
if (D->isArray()) {
987-
QualType ElemQT = D->getType()->getPointeeType();
988-
TypeToDiagnose = S.getASTContext().getConstantArrayType(
989-
ElemQT, APInt(64, static_cast<uint64_t>(D->getNumElems()), false),
990-
nullptr, ArraySizeModifier::Normal, 0);
991-
} else
992-
TypeToDiagnose = D->getType()->getPointeeType();
982+
QualType TypeToDiagnose = D->getDataType(S.getASTContext());
993983

994984
const SourceInfo &E = S.Current->getSource(OpPC);
995985
S.FFDiag(E, diag::note_constexpr_new_delete_mismatch)
@@ -1665,15 +1655,7 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
16651655
return false;
16661656

16671657
const auto *NewExpr = cast<CXXNewExpr>(E);
1668-
QualType StorageType = Ptr.getType();
1669-
1670-
if ((isa_and_nonnull<CXXNewExpr>(Ptr.getFieldDesc()->asExpr()) ||
1671-
isa_and_nonnull<CXXMemberCallExpr>(Ptr.getFieldDesc()->asExpr())) &&
1672-
StorageType->isPointerType()) {
1673-
// FIXME: Are there other cases where this is a problem?
1674-
StorageType = StorageType->getPointeeType();
1675-
}
1676-
1658+
QualType StorageType = Ptr.getFieldDesc()->getDataType(S.getASTContext());
16771659
const ASTContext &ASTCtx = S.getASTContext();
16781660
QualType AllocType;
16791661
if (ArraySize) {

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ static QualType getElemType(const Pointer &P) {
158158
return T->getAs<PointerType>()->getPointeeType();
159159
if (Desc->isArray())
160160
return Desc->getElemQualType();
161+
if (const auto *AT = T->getAsArrayTypeUnsafe())
162+
return AT->getElementType();
161163
return T;
162164
}
163165

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,10 @@ struct ConvertConstructorToDeductionGuideTransform {
376376
if (NestedPattern)
377377
Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
378378
auto [Depth, Index] = getDepthAndIndex(Param);
379-
// Depth can still be 0 if FTD belongs to an explicit class template
380-
// specialization with an empty template parameter list. In that case,
381-
// we don't want the NewDepth to overflow, and it should remain 0.
382-
assert(Depth ||
383-
cast<ClassTemplateSpecializationDecl>(FTD->getDeclContext())
384-
->isExplicitSpecialization());
379+
// Depth can be 0 if FTD belongs to a non-template class/a class
380+
// template specialization with an empty template parameter list. In
381+
// that case, we don't want the NewDepth to overflow, and it should
382+
// remain 0.
385383
NamedDecl *NewParam = transformTemplateParameter(
386384
SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
387385
Depth ? Depth - 1 : 0);
@@ -970,6 +968,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
970968
return {Template, AliasRhsTemplateArgs};
971969
}
972970

971+
bool IsNonDeducedArgument(const TemplateArgument &TA) {
972+
// The following cases indicate the template argument is non-deducible:
973+
// 1. The result is null. E.g. When it comes from a default template
974+
// argument that doesn't appear in the alias declaration.
975+
// 2. The template parameter is a pack and that cannot be deduced from
976+
// the arguments within the alias declaration.
977+
// Non-deducible template parameters will persist in the transformed
978+
// deduction guide.
979+
return TA.isNull() ||
980+
(TA.getKind() == TemplateArgument::Pack &&
981+
llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
982+
}
983+
973984
// Build deduction guides for a type alias template from the given underlying
974985
// deduction guide F.
975986
FunctionTemplateDecl *
@@ -1033,20 +1044,6 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
10331044
AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
10341045
/*NumberOfArgumentsMustMatch=*/false);
10351046

1036-
static std::function<bool(const TemplateArgument &TA)> IsNonDeducedArgument =
1037-
[](const TemplateArgument &TA) {
1038-
// The following cases indicate the template argument is non-deducible:
1039-
// 1. The result is null. E.g. When it comes from a default template
1040-
// argument that doesn't appear in the alias declaration.
1041-
// 2. The template parameter is a pack and that cannot be deduced from
1042-
// the arguments within the alias declaration.
1043-
// Non-deducible template parameters will persist in the transformed
1044-
// deduction guide.
1045-
return TA.isNull() ||
1046-
(TA.getKind() == TemplateArgument::Pack &&
1047-
llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
1048-
};
1049-
10501047
SmallVector<TemplateArgument> DeducedArgs;
10511048
SmallVector<unsigned> NonDeducedTemplateParamsInFIndex;
10521049
// !!NOTE: DeduceResults respects the sequence of template parameters of

clang/test/SemaTemplate/deduction-guide.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,3 +723,51 @@ void test() { NewDeleteAllocator abc(42); } // expected-error {{no viable constr
723723
// CHECK-NEXT: `-ParmVarDecl {{.+}} 'T'
724724

725725
} // namespace GH128691
726+
727+
namespace GH132616_DeductionGuide {
728+
729+
template <class T> struct A {
730+
template <class U>
731+
A(U);
732+
};
733+
734+
template <typename>
735+
struct B : A<int> {
736+
using A::A;
737+
};
738+
739+
template <class T>
740+
B(T) -> B<T>;
741+
742+
B b(24);
743+
744+
// CHECK-LABEL: Dumping GH132616_DeductionGuide::<deduction guide for B>:
745+
// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit <deduction guide for B>
746+
// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0
747+
// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U
748+
// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for B> 'auto (U) -> B<type-parameter-0-0>'
749+
// CHECK-NEXT: `-ParmVarDecl {{.+}} 'U'
750+
751+
struct C {
752+
template <class U>
753+
C(U);
754+
};
755+
756+
template <typename>
757+
struct D : C {
758+
using C::C;
759+
};
760+
761+
template <class T>
762+
D(T) -> D<T>;
763+
764+
D d(24);
765+
766+
// CHECK-LABEL: Dumping GH132616_DeductionGuide::<deduction guide for D>:
767+
// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit <deduction guide for D>
768+
// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0
769+
// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U
770+
// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for D> 'auto (U) -> D<type-parameter-0-0>'
771+
// CHECK-NEXT: `-ParmVarDecl {{.+}} 'U'
772+
773+
} // namespace GH132616_DeductionGuide

compiler-rt/lib/asan/asan_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
111111
ReleaseMemoryPagesToOS(MemToShadow(p), MemToShadow(p + size));
112112
}
113113

114-
void ReExecWithoutASLR() {
114+
void TryReExecWithoutASLR() {
115115
# if SANITIZER_LINUX
116116
// ASLR personality check.
117117
// Caution: 'personality' is sometimes forbidden by sandboxes, so only call

compiler-rt/lib/orc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set(ORC_COMMON_SOURCES
55
debug.cpp
66
dlfcn_wrapper.cpp
7-
extensible_rtti.cpp
7+
rtti.cpp
88
log_error_to_stderr.cpp
99
run_program_wrapper.cpp
1010
resolve.cpp
@@ -18,7 +18,7 @@ set(ORC_COMMON_IMPL_HEADERS
1818
endianness.h
1919
error.h
2020
executor_address.h
21-
extensible_rtti.h
21+
rtti.h
2222
simple_packed_serialization.h
2323
stl_extras.h
2424
wrapper_function_utils.h

compiler-rt/lib/orc/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define ORC_RT_ERROR_H
1111

1212
#include "compiler.h"
13-
#include "extensible_rtti.h"
13+
#include "rtti.h"
1414
#include "stl_extras.h"
1515

1616
#include <cassert>

0 commit comments

Comments
 (0)