Skip to content

Commit 45c6166

Browse files
committed
Merge release/21.x into cheriot
2 parents 7bb6d64 + ca11cf3 commit 45c6166

Some content is hidden

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

52 files changed

+2213
-747
lines changed

clang/cmake/caches/PGO.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
55
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
66

77
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
8-
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
8+
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE BOOL "")
99
set(CLANG_BOOTSTRAP_TARGETS
1010
generate-profdata
1111
stage2

clang/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Using Clang as a Compiler
4545
BoundsSafetyImplPlans
4646
ControlFlowIntegrity
4747
LTOVisibility
48+
PointerAuthentication
4849
SafeStack
4950
ShadowCallStack
5051
SourceBasedCodeCoverage

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
656656
bool containsNonRelocatablePointerAuth(QualType T) {
657657
if (!isPointerAuthenticationAvailable())
658658
return false;
659-
return findPointerAuthContent(T) ==
660-
PointerAuthContent::AddressDiscriminatedData;
659+
return findPointerAuthContent(T) != PointerAuthContent::None;
661660
}
662661

663662
private:

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ bool ASTContext::hasUniqueObjectRepresentations(
30913091
return true;
30923092
}
30933093

3094-
// All other pointers (except __ptrauth pointers) are unique.
3094+
// All other pointers are unique.
30953095
if (Ty->isPointerType())
30963096
return !Ty.hasAddressDiscriminatedPointerAuth();
30973097

clang/lib/AST/DeclCXX.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,13 @@ void CXXRecordDecl::addedMember(Decl *D) {
14481448
data().StructuralIfLiteral = false;
14491449
}
14501450

1451+
// If this type contains any address discriminated values we should
1452+
// have already indicated that the only special member functions that
1453+
// can possibly be trivial are the default constructor and destructor.
1454+
if (T.hasAddressDiscriminatedPointerAuth())
1455+
data().HasTrivialSpecialMembers &=
1456+
SMF_DefaultConstructor | SMF_Destructor;
1457+
14511458
// C++14 [meta.unary.prop]p4:
14521459
// T is a class type [...] with [...] no non-static data members other
14531460
// than subobjects of zero size

clang/lib/AST/ExprConstant.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7914,8 +7914,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
79147914
// so its layout is unspecified. For now, we'll simply treat these cases
79157915
// as unsupported (this should only be possible with OpenCL bool vectors
79167916
// whose element count isn't a multiple of the byte size).
7917-
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7918-
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
7917+
if (Info)
7918+
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7919+
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
79197920
return false;
79207921
}
79217922

@@ -7924,8 +7925,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
79247925
// The layout for x86_fp80 vectors seems to be handled very inconsistently
79257926
// by both clang and LLVM, so for now we won't allow bit_casts involving
79267927
// it in a constexpr context.
7927-
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7928-
<< EltTy;
7928+
if (Info)
7929+
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7930+
<< EltTy;
79297931
return false;
79307932
}
79317933
}

clang/lib/AST/Type.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,11 @@ bool QualType::isCXX98PODType(const ASTContext &Context) const {
28642864
return false;
28652865

28662866
QualType CanonicalType = getTypePtr()->CanonicalType;
2867+
2868+
// Any type that is, or contains, address discriminated data is never POD.
2869+
if (const_cast<ASTContext&>(Context).containsAddressDiscriminatedPointerAuth(CanonicalType))
2870+
return false;
2871+
28672872
switch (CanonicalType->getTypeClass()) {
28682873
// Everything not explicitly mentioned is not POD.
28692874
default:
@@ -2922,6 +2927,11 @@ bool QualType::isTrivialType(const ASTContext &Context) const {
29222927
if (CanonicalType->isDependentType())
29232928
return false;
29242929

2930+
// Any type that is, or contains, address discriminated data is never a
2931+
// trivial type.
2932+
if (const_cast<ASTContext&>(Context).containsAddressDiscriminatedPointerAuth(CanonicalType))
2933+
return false;
2934+
29252935
// C++0x [basic.types]p9:
29262936
// Scalar types, trivial class types, arrays of such types, and
29272937
// cv-qualified versions of these types are collectively called trivial
@@ -3019,6 +3029,12 @@ bool QualType::isBitwiseCloneableType(const ASTContext &Context) const {
30193029

30203030
if (CanonicalType->isIncompleteType())
30213031
return false;
3032+
3033+
// Any type that is, or contains, address discriminated data is never
3034+
// bitwise clonable.
3035+
if (const_cast<ASTContext&>(Context).containsAddressDiscriminatedPointerAuth(CanonicalType))
3036+
return false;
3037+
30223038
const auto *RD = CanonicalType->getAsRecordDecl(); // struct/union/class
30233039
if (!RD)
30243040
return true;
@@ -3264,6 +3280,10 @@ bool QualType::isCXX11PODType(const ASTContext &Context) const {
32643280
if (BaseTy->isIncompleteType())
32653281
return false;
32663282

3283+
// Any type that is, or contains, address discriminated data is non-POD.
3284+
if (const_cast<ASTContext&>(Context).containsAddressDiscriminatedPointerAuth(*this))
3285+
return false;
3286+
32673287
// As an extension, Clang treats vector types as Scalar types.
32683288
if (BaseTy->isScalarType() || BaseTy->isVectorType())
32693289
return true;

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19813,6 +19813,7 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
1981319813
Q && Q.isAddressDiscriminated()) {
1981419814
Record->setArgPassingRestrictions(
1981519815
RecordArgPassingKind::CanNeverPassInRegs);
19816+
Record->setNonTrivialToPrimitiveCopy(true);
1981619817
}
1981719818
}
1981819819

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,10 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT,
17781778
// Objective-C lifetime, this is a non-trivial assignment.
17791779
if (LhsT.getNonReferenceType().hasNonTrivialObjCLifetime())
17801780
return false;
1781-
1781+
ASTContext &Context = Self.getASTContext();
1782+
if (Context.containsAddressDiscriminatedPointerAuth(LhsT) ||
1783+
Context.containsAddressDiscriminatedPointerAuth(RhsT))
1784+
return false;
17821785
return !Result.get()->hasNonTrivialCall(Self.Context);
17831786
}
17841787

clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,8 @@ VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex,
920920
QualType T = Ex->getTypeOfArgument();
921921

922922
for (ExplodedNode *N : CheckedSet) {
923-
if (Ex->getKind() == UETT_SizeOf) {
923+
if (Ex->getKind() == UETT_SizeOf || Ex->getKind() == UETT_DataSizeOf ||
924+
Ex->getKind() == UETT_CountOf) {
924925
if (!T->isIncompleteType() && !T->isConstantSizeType()) {
925926
assert(T->isVariableArrayType() && "Unknown non-constant-sized type.");
926927

0 commit comments

Comments
 (0)