Skip to content

Commit 16ca2ca

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-max-cost-sentinel
2 parents 9f12dab + 3c6041d commit 16ca2ca

File tree

116 files changed

+6358
-2446
lines changed

Some content is hidden

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

116 files changed

+6358
-2446
lines changed

clang/cmake/caches/Android.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ set(CLANG_VENDOR Android CACHE STRING "")
99

1010
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
1111

12-
set(HAVE_LIBCXXABI ON CACHE BOOL "")
1312
set(LLVM_BUILD_TOOLS OFF CACHE BOOL "")
1413
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
1514
set(LLVM_ENABLE_THREADS OFF CACHE BOOL "")

clang/docs/AddressSanitizer.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ Limitations
313313
usually expected.
314314
* Static linking of executables is not supported.
315315

316+
Security Considerations
317+
=======================
318+
319+
AddressSanitizer is a bug detection tool and its runtime is not meant to be
320+
linked against production executables. While it may be useful for testing,
321+
AddressSanitizer's runtime was not developed with security-sensitive
322+
constraints in mind and may compromise the security of the resulting executable.
323+
316324
Supported Platforms
317325
===================
318326

clang/docs/HardwareAssistedAddressSanitizerDesign.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ than that of AddressSanitizer:
262262
`1/TG` extra memory for the shadow
263263
and some overhead due to `TG`-aligning all objects.
264264

265+
Security Considerations
266+
=======================
267+
268+
HWASAN is a bug detection tool and its runtime is not meant to be
269+
linked against production executables. While it may be useful for testing,
270+
HWASAN's runtime was not developed with security-sensitive
271+
constraints in mind and may compromise the security of the resulting executable.
272+
265273
Supported architectures
266274
=======================
267275
HWASAN relies on `Address Tagging`_ which is only available on AArch64.

clang/docs/LeakSanitizer.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ To use LeakSanitizer in stand-alone mode, link your program with
4343
link step, so that it would link in proper LeakSanitizer run-time library
4444
into the final executable.
4545

46+
Security Considerations
47+
=======================
48+
49+
LeakSanitizer is a bug detection tool and its runtime is not meant to be
50+
linked against production executables. While it may be useful for testing,
51+
LeakSanitizer's runtime was not developed with security-sensitive
52+
constraints in mind and may compromise the security of the resulting executable.
53+
4654
Supported Platforms
4755
===================
4856

clang/docs/MemorySanitizer.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ uninstrumented libc. For example, the authors were able to bootstrap
198198
MemorySanitizer-instrumented Clang compiler by linking it with
199199
self-built instrumented libc++ (as a replacement for libstdc++).
200200

201+
Security Considerations
202+
=======================
203+
204+
MemorySanitizer is a bug detection tool and its runtime is not meant to be
205+
linked against production executables. While it may be useful for testing,
206+
MemorySanitizer's runtime was not developed with security-sensitive
207+
constraints in mind and may compromise the security of the resulting executable.
208+
201209
Supported Platforms
202210
===================
203211

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ Bug Fixes to C++ Support
481481
in certain friend declarations. (#GH93099)
482482
- Clang now instantiates the correct lambda call operator when a lambda's class type is
483483
merged across modules. (#GH110401)
484+
- Clang now uses the correct set of template argument lists when comparing the constraints of
485+
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
486+
a class template. (#GH102320)
484487

485488
Bug Fixes to AST Handling
486489
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/ThreadSanitizer.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ Limitations
135135
flag had been supplied if compiling without ``-fPIC``, and as though the
136136
``-pie`` flag had been supplied if linking an executable.
137137

138+
Security Considerations
139+
-----------------------
140+
141+
ThreadSanitizer is a bug detection tool and its runtime is not meant to be
142+
linked against production executables. While it may be useful for testing,
143+
ThreadSanitizer's runtime was not developed with security-sensitive
144+
constraints in mind and may compromise the security of the resulting executable.
145+
138146
Current Status
139147
--------------
140148

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ Volatile
256256
The ``null``, ``alignment``, ``object-size``, ``local-bounds``, and ``vptr`` checks do not apply
257257
to pointers to types with the ``volatile`` qualifier.
258258

259+
.. _minimal-runtime:
260+
259261
Minimal Runtime
260262
===============
261263

@@ -416,6 +418,15 @@ There are several limitations:
416418
* Check groups (like ``undefined``) can't be used in suppressions file, only
417419
fine-grained checks are supported.
418420

421+
Security Considerations
422+
=======================
423+
424+
UndefinedBehaviorSanitizer's runtime is meant for testing purposes and its usage
425+
in production environment should be carefully considered from security
426+
perspective as it may compromise the security of the resulting executable.
427+
For security-sensitive applications consider using :ref:`Minimal Runtime
428+
<minimal-runtime>` or trap mode for all checks.
429+
419430
Supported Platforms
420431
===================
421432

clang/include/clang/AST/DeclTemplate.h

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,11 @@ class RedeclarableTemplateDecl : public TemplateDecl,
781781
EntryType *Entry, void *InsertPos);
782782

783783
struct CommonBase {
784-
CommonBase() : InstantiatedFromMember(nullptr, false) {}
784+
CommonBase() {}
785785

786786
/// The template from which this was most
787787
/// directly instantiated (or null).
788-
///
789-
/// The boolean value indicates whether this template
790-
/// was explicitly specialized.
791-
llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
792-
InstantiatedFromMember;
788+
RedeclarableTemplateDecl *InstantiatedFromMember = nullptr;
793789

794790
/// If non-null, points to an array of specializations (including
795791
/// partial specializations) known only by their external declaration IDs.
@@ -809,14 +805,19 @@ class RedeclarableTemplateDecl : public TemplateDecl,
809805
};
810806

811807
/// Pointer to the common data shared by all declarations of this
812-
/// template.
813-
mutable CommonBase *Common = nullptr;
808+
/// template, and a flag indicating if the template is a member
809+
/// specialization.
810+
mutable llvm::PointerIntPair<CommonBase *, 1, bool> Common;
811+
812+
CommonBase *getCommonPtrInternal() const { return Common.getPointer(); }
814813

815814
/// Retrieves the "common" pointer shared by all (re-)declarations of
816815
/// the same template. Calling this routine may implicitly allocate memory
817816
/// for the common pointer.
818817
CommonBase *getCommonPtr() const;
819818

819+
void setCommonPtr(CommonBase *C) const { Common.setPointer(C); }
820+
820821
virtual CommonBase *newCommon(ASTContext &C) const = 0;
821822

822823
// Construct a template decl with name, parameters, and templated element.
@@ -857,15 +858,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
857858
/// template<> template<typename T>
858859
/// struct X<int>::Inner { /* ... */ };
859860
/// \endcode
860-
bool isMemberSpecialization() const {
861-
return getCommonPtr()->InstantiatedFromMember.getInt();
862-
}
861+
bool isMemberSpecialization() const { return Common.getInt(); }
863862

864863
/// Note that this member template is a specialization.
865864
void setMemberSpecialization() {
866-
assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
867-
"Only member templates can be member template specializations");
868-
getCommonPtr()->InstantiatedFromMember.setInt(true);
865+
assert(!isMemberSpecialization() && "already a member specialization");
866+
Common.setInt(true);
869867
}
870868

871869
/// Retrieve the member template from which this template was
@@ -905,12 +903,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
905903
/// void X<T>::f(T, U);
906904
/// \endcode
907905
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() const {
908-
return getCommonPtr()->InstantiatedFromMember.getPointer();
906+
return getCommonPtr()->InstantiatedFromMember;
909907
}
910908

911909
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD) {
912-
assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
913-
getCommonPtr()->InstantiatedFromMember.setPointer(TD);
910+
assert(!getCommonPtr()->InstantiatedFromMember);
911+
getCommonPtr()->InstantiatedFromMember = TD;
914912
}
915913

916914
/// Retrieve the "injected" template arguments that correspond to the
@@ -1989,6 +1987,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19891987
/// template arguments have been deduced.
19901988
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
19911989
const TemplateArgumentList *TemplateArgs) {
1990+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
1991+
"A partial specialization cannot be instantiated from a template");
19921992
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
19931993
"Already set to a class template partial specialization!");
19941994
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2000,6 +2000,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
20002000
/// Note that this class template specialization is an instantiation
20012001
/// of the given class template.
20022002
void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
2003+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
2004+
"A partial specialization cannot be instantiated from a template");
20032005
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
20042006
"Previously set to a class template partial specialization!");
20052007
SpecializedTemplate = TemplDecl;
@@ -2187,18 +2189,11 @@ class ClassTemplatePartialSpecializationDecl
21872189
/// struct X<int>::Inner<T*> { /* ... */ };
21882190
/// \endcode
21892191
bool isMemberSpecialization() const {
2190-
const auto *First =
2191-
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2192-
return First->InstantiatedFromMember.getInt();
2192+
return InstantiatedFromMember.getInt();
21932193
}
21942194

21952195
/// Note that this member template is a specialization.
2196-
void setMemberSpecialization() {
2197-
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2198-
assert(First->InstantiatedFromMember.getPointer() &&
2199-
"Only member templates can be member template specializations");
2200-
return First->InstantiatedFromMember.setInt(true);
2201-
}
2196+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
22022197

22032198
/// Retrieves the injected specialization type for this partial
22042199
/// specialization. This is not the same as the type-decl-type for
@@ -2268,10 +2263,6 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22682263
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
22692264
}
22702265

2271-
void setCommonPtr(Common *C) {
2272-
RedeclarableTemplateDecl::Common = C;
2273-
}
2274-
22752266
public:
22762267

22772268
friend class ASTDeclReader;
@@ -2754,6 +2745,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27542745
/// template arguments have been deduced.
27552746
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec,
27562747
const TemplateArgumentList *TemplateArgs) {
2748+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2749+
"A partial specialization cannot be instantiated from a template");
27572750
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27582751
"Already set to a variable template partial specialization!");
27592752
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2765,6 +2758,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27652758
/// Note that this variable template specialization is an instantiation
27662759
/// of the given variable template.
27672760
void setInstantiationOf(VarTemplateDecl *TemplDecl) {
2761+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2762+
"A partial specialization cannot be instantiated from a template");
27682763
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27692764
"Previously set to a variable template partial specialization!");
27702765
SpecializedTemplate = TemplDecl;
@@ -2949,18 +2944,11 @@ class VarTemplatePartialSpecializationDecl
29492944
/// U* X<int>::Inner<T*> = (T*)(0) + 1;
29502945
/// \endcode
29512946
bool isMemberSpecialization() const {
2952-
const auto *First =
2953-
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2954-
return First->InstantiatedFromMember.getInt();
2947+
return InstantiatedFromMember.getInt();
29552948
}
29562949

29572950
/// Note that this member template is a specialization.
2958-
void setMemberSpecialization() {
2959-
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2960-
assert(First->InstantiatedFromMember.getPointer() &&
2961-
"Only member templates can be member template specializations");
2962-
return First->InstantiatedFromMember.setInt(true);
2963-
}
2951+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
29642952

29652953
SourceRange getSourceRange() const override LLVM_READONLY;
29662954

clang/include/clang/Basic/PlistSupport.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ using FIDMap = llvm::DenseMap<FileID, unsigned>;
2626

2727
inline unsigned AddFID(FIDMap &FIDs, SmallVectorImpl<FileID> &V,
2828
FileID FID) {
29-
FIDMap::iterator I = FIDs.find(FID);
30-
if (I != FIDs.end())
31-
return I->second;
32-
unsigned NewValue = V.size();
33-
FIDs[FID] = NewValue;
34-
V.push_back(FID);
35-
return NewValue;
29+
auto [I, Inserted] = FIDs.try_emplace(FID, V.size());
30+
if (Inserted)
31+
V.push_back(FID);
32+
return I->second;
3633
}
3734

3835
inline unsigned AddFID(FIDMap &FIDs, SmallVectorImpl<FileID> &V,

0 commit comments

Comments
 (0)