Skip to content

Commit 81f336a

Browse files
authored
Merge branch 'llvm:main' into update_pch_algorithm
2 parents 7868fc9 + 13fa78c commit 81f336a

File tree

426 files changed

+8870
-4598
lines changed

Some content is hidden

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

426 files changed

+8870
-4598
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
- uses: actions/checkout@v4
209209
- uses: maxim-lobanov/setup-xcode@v1
210210
with:
211-
xcode-version: 'latest-stable'
211+
xcode-version: 'latest'
212212
- uses: seanmiddleditch/gha-setup-ninja@master
213213
- name: Build and test
214214
run: |

.github/workflows/release-asset-audit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import github
22
import sys
33

4+
_SPECIAL_CASE_BINARIES = {
5+
"keith": {"clang+llvm-18.1.8-arm64-apple-macos11.tar.xz"},
6+
}
7+
8+
9+
def _is_valid(uploader_name, valid_uploaders, asset_name):
10+
if uploader_name in valid_uploaders:
11+
return True
12+
13+
if uploader_name in _SPECIAL_CASE_BINARIES:
14+
return asset_name in _SPECIAL_CASE_BINARIES[uploader_name]
15+
16+
return False
17+
18+
419
def main():
520
token = sys.argv[1]
621

@@ -41,7 +56,7 @@ def main():
4156
print(
4257
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
4358
)
44-
if asset.uploader.login not in uploaders:
59+
if not _is_valid(asset.uploader.login, uploaders, asset.name):
4560
with open('comment', 'w') as file:
4661
file.write(f'@{asset.uploader.login} is not a valid uploader.')
4762
sys.exit(1)

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ Attribute Changes in Clang
220220
- ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
221221
where they were previously silently ignored.
222222

223+
- Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
224+
``std::span, std::string_view`` constructors, this enables Clang to capture
225+
more cases where the returned reference outlives the object.
226+
(#GH100567)
227+
223228
Improvements to Clang's diagnostics
224229
-----------------------------------
225230

@@ -312,6 +317,8 @@ Bug Fixes to C++ Support
312317
- Clang now properly handles the order of attributes in `extern` blocks. (#GH101990).
313318
- Fixed an assertion failure by preventing null explicit object arguments from being deduced. (#GH102025).
314319
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
320+
- When performing partial ordering of function templates, clang now checks that
321+
the deduction was consistent. Fixes (#GH18291).
315322
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
316323
template depth than the friend function template. (#GH98258)
317324
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context

clang/docs/UsersManual.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,13 @@ treated as a file name and is searched for sequentially in the directories:
950950
- system directory,
951951
- the directory where Clang executable resides.
952952

953-
Both user and system directories for configuration files are specified during
954-
clang build using CMake parameters, ``CLANG_CONFIG_FILE_USER_DIR`` and
955-
``CLANG_CONFIG_FILE_SYSTEM_DIR`` respectively. The first file found is used.
956-
It is an error if the required file cannot be found.
953+
Both user and system directories for configuration files can be specified
954+
either during build or during runtime. At build time, use
955+
``CLANG_CONFIG_FILE_USER_DIR`` and ``CLANG_CONFIG_FILE_SYSTEM_DIR``. At run
956+
time use the ``--config-user-dir=`` and ``--config-system-dir=`` command line
957+
options. Specifying config directories at runtime overrides the config
958+
directories set at build time The first file found is used. It is an error if
959+
the required file cannot be found.
957960

958961
The default configuration files are searched for in the same directories
959962
following the rules described in the next paragraphs. Loading default

clang/include/clang/Basic/BuiltinsNVPTX.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ BUILTIN(__nvvm_atom_xor_gen_ll, "LLiLLiD*LLi", "n")
844844
TARGET_BUILTIN(__nvvm_atom_cta_xor_gen_ll, "LLiLLiD*LLi", "n", SM_60)
845845
TARGET_BUILTIN(__nvvm_atom_sys_xor_gen_ll, "LLiLLiD*LLi", "n", SM_60)
846846

847+
TARGET_BUILTIN(__nvvm_atom_cas_gen_us, "UsUsD*UsUs", "n", SM_70)
848+
TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_us, "UsUsD*UsUs", "n", SM_70)
849+
TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_us, "UsUsD*UsUs", "n", SM_70)
847850
BUILTIN(__nvvm_atom_cas_gen_i, "iiD*ii", "n")
848851
TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_i, "iiD*ii", "n", SM_60)
849852
TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_i, "iiD*ii", "n", SM_60)

clang/include/clang/Sema/Sema.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,9 @@ class Sema final : public SemaBase {
18061806
/// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
18071807
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record);
18081808

1809+
/// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
1810+
void inferLifetimeBoundAttribute(FunctionDecl *FD);
1811+
18091812
/// Add [[gsl::Pointer]] attributes for std:: types.
18101813
void inferGslPointerAttribute(TypedefNameDecl *TD);
18111814

@@ -13280,6 +13283,10 @@ class Sema final : public SemaBase {
1328013283
/// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
1328113284
/// acceptable as the top level type of the result.
1328213285
///
13286+
/// \param IsIncompleteSubstitution If provided, the pointee will be set
13287+
/// whenever substitution would perform a replacement with a null or
13288+
/// non-existent template argument.
13289+
///
1328313290
/// \returns If the instantiation succeeds, the instantiated
1328413291
/// type. Otherwise, produces diagnostics and returns a NULL type.
1328513292
TypeSourceInfo *SubstType(TypeSourceInfo *T,
@@ -13289,7 +13296,8 @@ class Sema final : public SemaBase {
1328913296

1329013297
QualType SubstType(QualType T,
1329113298
const MultiLevelTemplateArgumentList &TemplateArgs,
13292-
SourceLocation Loc, DeclarationName Entity);
13299+
SourceLocation Loc, DeclarationName Entity,
13300+
bool *IsIncompleteSubstitution = nullptr);
1329313301

1329413302
TypeSourceInfo *SubstType(TypeLoc TL,
1329513303
const MultiLevelTemplateArgumentList &TemplateArgs,

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file defines CheckerVisitor.
9+
// This file defines various utilities used by checkers.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -114,6 +114,10 @@ OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK,
114114

115115
std::optional<SVal> getPointeeVal(SVal PtrSVal, ProgramStateRef State);
116116

117+
/// Returns true if declaration \p D is in std namespace or any nested namespace
118+
/// or class scope.
119+
bool isWithinStdNamespace(const Decl *D);
120+
117121
} // namespace ento
118122

119123
} // namespace clang

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ class ExprEngine {
286286
const Stmt *DiagnosticStmt = nullptr,
287287
ProgramPoint::Kind K = ProgramPoint::PreStmtPurgeDeadSymbolsKind);
288288

289+
/// A tag to track convenience transitions, which can be removed at cleanup.
290+
/// This tag applies to a node created after removeDead.
291+
static const ProgramPointTag *cleanupNodeTag();
292+
289293
/// processCFGElement - Called by CoreEngine. Used to generate new successor
290294
/// nodes by processing the 'effects' of a CFG element.
291295
void processCFGElement(const CFGElement E, ExplodedNode *Pred,

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,6 +4991,8 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
49914991
const Expr *SubExpr = E->getSubExpr();
49924992
if (SubExpr->getType()->isAnyComplexType())
49934993
return this->VisitComplexUnaryOperator(E);
4994+
if (SubExpr->getType()->isVectorType())
4995+
return this->VisitVectorUnaryOperator(E);
49944996
std::optional<PrimType> T = classify(SubExpr->getType());
49954997

49964998
switch (E->getOpcode()) {
@@ -5312,6 +5314,110 @@ bool Compiler<Emitter>::VisitComplexUnaryOperator(const UnaryOperator *E) {
53125314
return true;
53135315
}
53145316

5317+
template <class Emitter>
5318+
bool Compiler<Emitter>::VisitVectorUnaryOperator(const UnaryOperator *E) {
5319+
const Expr *SubExpr = E->getSubExpr();
5320+
assert(SubExpr->getType()->isVectorType());
5321+
5322+
if (DiscardResult)
5323+
return this->discard(SubExpr);
5324+
5325+
auto UnaryOp = E->getOpcode();
5326+
if (UnaryOp != UO_Plus && UnaryOp != UO_Minus && UnaryOp != UO_LNot &&
5327+
UnaryOp != UO_Not)
5328+
return this->emitInvalid(E);
5329+
5330+
// Nothing to do here.
5331+
if (UnaryOp == UO_Plus)
5332+
return this->delegate(SubExpr);
5333+
5334+
if (!Initializing) {
5335+
std::optional<unsigned> LocalIndex = allocateLocal(SubExpr);
5336+
if (!LocalIndex)
5337+
return false;
5338+
if (!this->emitGetPtrLocal(*LocalIndex, E))
5339+
return false;
5340+
}
5341+
5342+
// The offset of the temporary, if we created one.
5343+
unsigned SubExprOffset =
5344+
this->allocateLocalPrimitive(SubExpr, PT_Ptr, true, false);
5345+
if (!this->visit(SubExpr))
5346+
return false;
5347+
if (!this->emitSetLocal(PT_Ptr, SubExprOffset, E))
5348+
return false;
5349+
5350+
const auto *VecTy = SubExpr->getType()->getAs<VectorType>();
5351+
PrimType ElemT = classifyVectorElementType(SubExpr->getType());
5352+
auto getElem = [=](unsigned Offset, unsigned Index) -> bool {
5353+
if (!this->emitGetLocal(PT_Ptr, Offset, E))
5354+
return false;
5355+
return this->emitArrayElemPop(ElemT, Index, E);
5356+
};
5357+
5358+
switch (UnaryOp) {
5359+
case UO_Minus:
5360+
for (unsigned I = 0; I != VecTy->getNumElements(); ++I) {
5361+
if (!getElem(SubExprOffset, I))
5362+
return false;
5363+
if (!this->emitNeg(ElemT, E))
5364+
return false;
5365+
if (!this->emitInitElem(ElemT, I, E))
5366+
return false;
5367+
}
5368+
break;
5369+
case UO_LNot: { // !x
5370+
// In C++, the logic operators !, &&, || are available for vectors. !v is
5371+
// equivalent to v == 0.
5372+
//
5373+
// The result of the comparison is a vector of the same width and number of
5374+
// elements as the comparison operands with a signed integral element type.
5375+
//
5376+
// https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
5377+
QualType ResultVecTy = E->getType();
5378+
PrimType ResultVecElemT =
5379+
classifyPrim(ResultVecTy->getAs<VectorType>()->getElementType());
5380+
for (unsigned I = 0; I != VecTy->getNumElements(); ++I) {
5381+
if (!getElem(SubExprOffset, I))
5382+
return false;
5383+
// operator ! on vectors returns -1 for 'truth', so negate it.
5384+
if (!this->emitPrimCast(ElemT, PT_Bool, Ctx.getASTContext().BoolTy, E))
5385+
return false;
5386+
if (!this->emitInv(E))
5387+
return false;
5388+
if (!this->emitPrimCast(PT_Bool, ElemT, VecTy->getElementType(), E))
5389+
return false;
5390+
if (!this->emitNeg(ElemT, E))
5391+
return false;
5392+
if (ElemT != ResultVecElemT &&
5393+
!this->emitPrimCast(ElemT, ResultVecElemT, ResultVecTy, E))
5394+
return false;
5395+
if (!this->emitInitElem(ResultVecElemT, I, E))
5396+
return false;
5397+
}
5398+
break;
5399+
}
5400+
case UO_Not: // ~x
5401+
for (unsigned I = 0; I != VecTy->getNumElements(); ++I) {
5402+
if (!getElem(SubExprOffset, I))
5403+
return false;
5404+
if (ElemT == PT_Bool) {
5405+
if (!this->emitInv(E))
5406+
return false;
5407+
} else {
5408+
if (!this->emitComp(ElemT, E))
5409+
return false;
5410+
}
5411+
if (!this->emitInitElem(ElemT, I, E))
5412+
return false;
5413+
}
5414+
break;
5415+
default:
5416+
llvm_unreachable("Unsupported unary operators should be handled up front");
5417+
}
5418+
return true;
5419+
}
5420+
53155421
template <class Emitter>
53165422
bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
53175423
if (DiscardResult)

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
139139
bool VisitGNUNullExpr(const GNUNullExpr *E);
140140
bool VisitCXXThisExpr(const CXXThisExpr *E);
141141
bool VisitUnaryOperator(const UnaryOperator *E);
142+
bool VisitVectorUnaryOperator(const UnaryOperator *E);
142143
bool VisitComplexUnaryOperator(const UnaryOperator *E);
143144
bool VisitDeclRefExpr(const DeclRefExpr *E);
144145
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
@@ -349,6 +350,11 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
349350
return *this->classify(ElemType);
350351
}
351352

353+
PrimType classifyVectorElementType(QualType T) const {
354+
assert(T->isVectorType());
355+
return *this->classify(T->getAs<VectorType>()->getElementType());
356+
}
357+
352358
bool emitComplexReal(const Expr *SubExpr);
353359
bool emitComplexBoolCast(const Expr *E);
354360
bool emitComplexComparison(const Expr *LHS, const Expr *RHS,

0 commit comments

Comments
 (0)