Skip to content

Commit 7d38d47

Browse files
authored
Merge branch 'main' into fix/116485
2 parents 673ba79 + ca79e12 commit 7d38d47

File tree

174 files changed

+3247
-1434
lines changed

Some content is hidden

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

174 files changed

+3247
-1434
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ Non-comprehensive list of changes in this release
356356
issues with the sanitizer because the counter is automatically set.
357357

358358
- ``__builtin_reduce_add`` function can now be used in constant expressions.
359+
- ``__builtin_reduce_mul`` function can now be used in constant expressions.
359360

360361
New Compiler Flags
361362
------------------
@@ -555,6 +556,8 @@ Improvements to Clang's diagnostics
555556
getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
556557
}
557558

559+
- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
560+
558561
- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
559562

560563
Improvements to Clang's time-trace

clang/docs/ThreadSafetyAnalysis.rst

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,25 @@ implementation.
933933
MutexLocker(Mutex *mu, defer_lock_t) EXCLUDES(mu) : mut(mu), locked(false) {}
934934
935935
// Same as constructors, but without tag types. (Requires C++17 copy elision.)
936-
static MutexLocker Lock(Mutex *mu) ACQUIRE(mu);
937-
static MutexLocker Adopt(Mutex *mu) REQUIRES(mu);
938-
static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu);
939-
static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu);
940-
static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu);
936+
static MutexLocker Lock(Mutex *mu) ACQUIRE(mu) {
937+
return MutexLocker(mu);
938+
}
939+
940+
static MutexLocker Adopt(Mutex *mu) REQUIRES(mu) {
941+
return MutexLocker(mu, adopt_lock);
942+
}
943+
944+
static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu) {
945+
return MutexLocker(mu, shared_lock);
946+
}
947+
948+
static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu) {
949+
return MutexLocker(mu, adopt_lock, shared_lock);
950+
}
951+
952+
static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu) {
953+
return MutexLocker(mu, defer_lock);
954+
}
941955
942956
// Release *this and all associated mutexes, if they are still held.
943957
// There is no warning if the scope was already unlocked before.

clang/include/clang/Basic/Builtins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ def ReduceAdd : Builtin {
15101510

15111511
def ReduceMul : Builtin {
15121512
let Spellings = ["__builtin_reduce_mul"];
1513-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1513+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
15141514
let Prototype = "void(...)";
15151515
}
15161516

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ def warn_cxx98_compat_defaulted_deleted_function : Warning<
976976
"%select{defaulted|deleted}0 function definitions are incompatible with C++98">,
977977
InGroup<CXX98Compat>, DefaultIgnore;
978978

979-
def ext_delete_with_message : ExtWarn<
979+
def ext_delete_with_message : Extension<
980980
"'= delete' with a message is a C++2c extension">, InGroup<CXX26>;
981981
def warn_cxx23_delete_with_message : Warning<
982982
"'= delete' with a message is incompatible with C++ standards before C++2c">,

clang/include/clang/Frontend/FrontendAction.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "clang/Basic/LLVM.h"
2222
#include "clang/Basic/LangOptions.h"
2323
#include "clang/Frontend/ASTUnit.h"
24+
#include "clang/Frontend/CompilerInstance.h"
2425
#include "clang/Frontend/FrontendOptions.h"
2526
#include "llvm/ADT/StringRef.h"
2627
#include "llvm/Support/Error.h"
@@ -185,7 +186,12 @@ class FrontendAction {
185186
virtual bool usesPreprocessorOnly() const = 0;
186187

187188
/// For AST-based actions, the kind of translation unit we're handling.
188-
virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; }
189+
virtual TranslationUnitKind getTranslationUnitKind() {
190+
// The ASTContext, if exists, knows the exact TUKind of the frondend.
191+
if (Instance && Instance->hasASTContext())
192+
return Instance->getASTContext().TUKind;
193+
return TU_Complete;
194+
}
189195

190196
/// Does this action support use with PCH?
191197
virtual bool hasPCHSupport() const { return true; }

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ class Interpreter {
177177

178178
CodeGenerator *getCodeGen() const;
179179
std::unique_ptr<llvm::Module> GenModule();
180-
PartialTranslationUnit &RegisterPTU(TranslationUnitDecl *TU);
180+
PartialTranslationUnit &RegisterPTU(TranslationUnitDecl *TU,
181+
std::unique_ptr<llvm::Module> M = {});
181182

182183
// A cache for the compiled destructors used to for de-allocation of managed
183184
// clang::Values.

clang/include/clang/Interpreter/PartialTranslationUnit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct PartialTranslationUnit {
3131

3232
/// The llvm IR produced for the input.
3333
std::unique_ptr<llvm::Module> TheModule;
34+
bool operator==(const PartialTranslationUnit &other) {
35+
return other.TUPart == TUPart && other.TheModule == TheModule;
36+
}
3437
};
3538
} // namespace clang
3639

clang/lib/AST/ExprConstant.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13527,18 +13527,33 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1352713527
return Success(DidOverflow, E);
1352813528
}
1352913529

13530-
case Builtin::BI__builtin_reduce_add: {
13530+
case Builtin::BI__builtin_reduce_add:
13531+
case Builtin::BI__builtin_reduce_mul: {
1353113532
APValue Source;
1353213533
if (!EvaluateAsRValue(Info, E->getArg(0), Source))
1353313534
return false;
1353413535

1353513536
unsigned SourceLen = Source.getVectorLength();
1353613537
APSInt Reduced = Source.getVectorElt(0).getInt();
1353713538
for (unsigned EltNum = 1; EltNum < SourceLen; ++EltNum) {
13538-
if (!CheckedIntArithmetic(
13539-
Info, E, Reduced, Source.getVectorElt(EltNum).getInt(),
13540-
Reduced.getBitWidth() + 1, std::plus<APSInt>(), Reduced))
13539+
switch (BuiltinOp) {
13540+
default:
1354113541
return false;
13542+
case Builtin::BI__builtin_reduce_add: {
13543+
if (!CheckedIntArithmetic(
13544+
Info, E, Reduced, Source.getVectorElt(EltNum).getInt(),
13545+
Reduced.getBitWidth() + 1, std::plus<APSInt>(), Reduced))
13546+
return false;
13547+
break;
13548+
}
13549+
case Builtin::BI__builtin_reduce_mul: {
13550+
if (!CheckedIntArithmetic(
13551+
Info, E, Reduced, Source.getVectorElt(EltNum).getInt(),
13552+
Reduced.getBitWidth() * 2, std::multiplies<APSInt>(), Reduced))
13553+
return false;
13554+
break;
13555+
}
13556+
}
1354213557
}
1354313558

1354413559
return Success(Reduced, E);

clang/lib/CodeGen/CGExprComplex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) {
471471
CGF.ErrorUnsupported(E, "complex expression");
472472
llvm::Type *EltTy =
473473
CGF.ConvertType(getComplexType(E->getType())->getElementType());
474-
llvm::Value *U = llvm::UndefValue::get(EltTy);
474+
llvm::Value *U = llvm::PoisonValue::get(EltTy);
475475
return ComplexPairTy(U, U);
476476
}
477477

@@ -1449,7 +1449,7 @@ ComplexPairTy ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *E) {
14491449
CGF.ErrorUnsupported(E, "complex va_arg expression");
14501450
llvm::Type *EltTy =
14511451
CGF.ConvertType(E->getType()->castAs<ComplexType>()->getElementType());
1452-
llvm::Value *U = llvm::UndefValue::get(EltTy);
1452+
llvm::Value *U = llvm::PoisonValue::get(EltTy);
14531453
return ComplexPairTy(U, U);
14541454
}
14551455

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ Value *ScalarExprEmitter::VisitExpr(Expr *E) {
18281828
CGF.ErrorUnsupported(E, "scalar expression");
18291829
if (E->getType()->isVoidType())
18301830
return nullptr;
1831-
return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
1831+
return llvm::PoisonValue::get(CGF.ConvertType(E->getType()));
18321832
}
18331833

18341834
Value *

0 commit comments

Comments
 (0)