Skip to content

Commit 1d0cf67

Browse files
committed
Merge remote-tracking branch 'upstream/main' into lldb-dap-column-breakpoints
2 parents 6937686 + d2e9532 commit 1d0cf67

File tree

216 files changed

+14424
-583
lines changed

Some content is hidden

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

216 files changed

+14424
-583
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
400400
}
401401

402402
static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
403-
if (!Ptr.isBlockPointer())
403+
if (!Ptr.isStatic() || !Ptr.isBlockPointer())
404404
return true;
405405
return CheckConstant(S, OpPC, Ptr.getDeclDesc());
406406
}
@@ -513,8 +513,8 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
513513
return false;
514514
}
515515

516-
bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
517-
AccessKinds AK) {
516+
static bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
517+
AccessKinds AK) {
518518
assert(Ptr.isLive());
519519

520520
// FIXME: This check here might be kinda expensive. Maybe it would be better

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -513,70 +513,25 @@ ProgramStateRef ExprEngine::updateObjectsUnderConstruction(
513513
static ProgramStateRef
514514
bindRequiredArrayElementToEnvironment(ProgramStateRef State,
515515
const ArrayInitLoopExpr *AILE,
516-
const LocationContext *LCtx, SVal Idx) {
517-
// The ctor in this case is guaranteed to be a copy ctor, otherwise we hit a
518-
// compile time error.
519-
//
520-
// -ArrayInitLoopExpr <-- we're here
521-
// |-OpaqueValueExpr
522-
// | `-DeclRefExpr <-- match this
523-
// `-CXXConstructExpr
524-
// `-ImplicitCastExpr
525-
// `-ArraySubscriptExpr
526-
// |-ImplicitCastExpr
527-
// | `-OpaqueValueExpr
528-
// | `-DeclRefExpr
529-
// `-ArrayInitIndexExpr
530-
//
531-
// The resulting expression might look like the one below in an implicit
532-
// copy/move ctor.
533-
//
534-
// ArrayInitLoopExpr <-- we're here
535-
// |-OpaqueValueExpr
536-
// | `-MemberExpr <-- match this
537-
// | (`-CXXStaticCastExpr) <-- move ctor only
538-
// | `-DeclRefExpr
539-
// `-CXXConstructExpr
540-
// `-ArraySubscriptExpr
541-
// |-ImplicitCastExpr
542-
// | `-OpaqueValueExpr
543-
// | `-MemberExpr
544-
// | `-DeclRefExpr
545-
// `-ArrayInitIndexExpr
546-
//
547-
// The resulting expression for a multidimensional array.
548-
// ArrayInitLoopExpr <-- we're here
549-
// |-OpaqueValueExpr
550-
// | `-DeclRefExpr <-- match this
551-
// `-ArrayInitLoopExpr
552-
// |-OpaqueValueExpr
553-
// | `-ArraySubscriptExpr
554-
// | |-ImplicitCastExpr
555-
// | | `-OpaqueValueExpr
556-
// | | `-DeclRefExpr
557-
// | `-ArrayInitIndexExpr
558-
// `-CXXConstructExpr <-- extract this
559-
// ` ...
560-
561-
const auto *OVESrc = AILE->getCommonExpr()->getSourceExpr();
516+
const LocationContext *LCtx, NonLoc Idx) {
517+
SValBuilder &SVB = State->getStateManager().getSValBuilder();
518+
MemRegionManager &MRMgr = SVB.getRegionManager();
519+
ASTContext &Ctx = SVB.getContext();
562520

563521
// HACK: There is no way we can put the index of the array element into the
564522
// CFG unless we unroll the loop, so we manually select and bind the required
565523
// parameter to the environment.
566-
const auto *CE =
524+
const Expr *SourceArray = AILE->getCommonExpr()->getSourceExpr();
525+
const auto *Ctor =
567526
cast<CXXConstructExpr>(extractElementInitializerFromNestedAILE(AILE));
568527

569-
SVal Base = UnknownVal();
570-
if (const auto *ME = dyn_cast<MemberExpr>(OVESrc))
571-
Base = State->getSVal(ME, LCtx);
572-
else if (const auto *DRE = dyn_cast<DeclRefExpr>(OVESrc))
573-
Base = State->getLValue(cast<VarDecl>(DRE->getDecl()), LCtx);
574-
else
575-
llvm_unreachable("ArrayInitLoopExpr contains unexpected source expression");
576-
577-
SVal NthElem = State->getLValue(CE->getType(), Idx, Base);
528+
const auto *SourceArrayRegion =
529+
cast<SubRegion>(State->getSVal(SourceArray, LCtx).getAsRegion());
530+
const ElementRegion *ElementRegion =
531+
MRMgr.getElementRegion(Ctor->getType(), Idx, SourceArrayRegion, Ctx);
578532

579-
return State->BindExpr(CE->getArg(0), LCtx, NthElem);
533+
return State->BindExpr(Ctor->getArg(0), LCtx,
534+
loc::MemRegionVal(ElementRegion));
580535
}
581536

582537
void ExprEngine::handleConstructor(const Expr *E,

clang/test/Analysis/array-init-loop.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,41 @@ void no_crash() {
330330
}
331331

332332
} // namespace crash
333+
334+
namespace array_subscript_initializer {
335+
struct S {
336+
int x;
337+
};
338+
339+
void no_crash() {
340+
S arr[][2] = {{1, 2}};
341+
342+
const auto [a, b] = arr[0]; // no-crash
343+
344+
clang_analyzer_eval(a.x == 1); // expected-warning{{TRUE}}
345+
clang_analyzer_eval(b.x == 2); // expected-warning{{TRUE}}
346+
}
347+
} // namespace array_subscript_initializer
348+
349+
namespace iterator_initializer {
350+
struct S {
351+
int x;
352+
};
353+
354+
void no_crash() {
355+
S arr[][2] = {{1, 2}, {3, 4}};
356+
357+
int i = 0;
358+
for (const auto [a, b] : arr) { // no-crash
359+
if (i == 0) {
360+
clang_analyzer_eval(a.x == 1); // expected-warning{{TRUE}}
361+
clang_analyzer_eval(b.x == 2); // expected-warning{{TRUE}}
362+
} else {
363+
clang_analyzer_eval(a.x == 3); // expected-warning{{TRUE}}
364+
clang_analyzer_eval(b.x == 4); // expected-warning{{TRUE}}
365+
}
366+
367+
++i;
368+
}
369+
}
370+
} // namespace iterator_initializer

flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,6 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
581581
/*genAssociated=*/false);
582582
} else if (auto vecTy = mlir::dyn_cast_or_null<fir::VectorType>(Ty)) {
583583
return convertVectorType(vecTy, fileAttr, scope, declOp);
584-
} else if (mlir::isa<mlir::NoneType>(Ty)) {
585-
return mlir::LLVM::DINullTypeAttr::get(context);
586584
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
587585
auto elTy = boxTy.getElementType();
588586
if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(elTy))

flang/test/Transforms/debug-none-type.fir

Lines changed: 0 additions & 14 deletions
This file was deleted.

libc/src/math/generic/atan2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ LLVM_LIBC_FUNCTION(double, atan2, (double y, double x)) {
230230
if (LIBC_UNLIKELY(max_exp > 0x7ffU - 128U || min_exp < 128U)) {
231231
if (x_bits.is_nan() || y_bits.is_nan())
232232
return FPBits::quiet_nan().get_val();
233-
unsigned x_except = x_abs == 0 ? 0 : (FPBits(x_abs).is_inf() ? 2 : 1);
234-
unsigned y_except = y_abs == 0 ? 0 : (FPBits(y_abs).is_inf() ? 2 : 1);
233+
unsigned x_except = x == 0.0 ? 0 : (FPBits(x_abs).is_inf() ? 2 : 1);
234+
unsigned y_except = y == 0.0 ? 0 : (FPBits(y_abs).is_inf() ? 2 : 1);
235235

236236
// Exceptional cases:
237237
// EXCEPT[y_except][x_except][x_is_neg]

libc/src/math/generic/cbrt.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ LLVM_LIBC_FUNCTION(double, cbrt, (double x)) {
151151

152152
if (LIBC_UNLIKELY(x_abs < FPBits::min_normal().uintval() ||
153153
x_abs >= FPBits::inf().uintval())) {
154-
if (x_abs == 0 || x_abs >= FPBits::inf().uintval())
154+
if (x == 0.0 || x_abs >= FPBits::inf().uintval())
155155
// x is 0, Inf, or NaN.
156-
return x;
156+
// Make sure it works for FTZ/DAZ modes.
157+
return static_cast<double>(x + x);
157158

158159
// x is non-zero denormal number.
159160
// Normalize x.

libc/src/math/generic/cbrtf.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ LLVM_LIBC_FUNCTION(float, cbrtf, (float x)) {
9393
uint32_t x_abs = x_bits.uintval() & 0x7fff'ffff;
9494
uint32_t sign_bit = (x_bits.uintval() >> 31) << DoubleBits::EXP_LEN;
9595

96-
if (LIBC_UNLIKELY(x_abs == 0 || x_abs >= 0x7f80'0000)) {
96+
if (LIBC_UNLIKELY(x == 0.0f || x_abs >= 0x7f80'0000)) {
9797
// x is 0, Inf, or NaN.
98-
return x;
98+
// Make sure it works for FTZ/DAZ modes.
99+
return x + x;
99100
}
100101

101102
double xd = static_cast<double>(x);

libc/src/math/generic/log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ LLVM_LIBC_FUNCTION(double, log, (double x)) {
749749

750750
if (LIBC_UNLIKELY(xbits.uintval() < FPBits_t::min_normal().uintval() ||
751751
xbits.uintval() > FPBits_t::max_normal().uintval())) {
752-
if (xbits.is_zero()) {
752+
if (x == 0.0) {
753753
// return -Inf and raise FE_DIVBYZERO.
754754
fputil::set_errno_if_required(ERANGE);
755755
fputil::raise_except_if_required(FE_DIVBYZERO);

libc/src/math/generic/log10.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ LLVM_LIBC_FUNCTION(double, log10, (double x)) {
751751

752752
if (LIBC_UNLIKELY(xbits.uintval() < FPBits_t::min_normal().uintval() ||
753753
xbits.uintval() > FPBits_t::max_normal().uintval())) {
754-
if (xbits.is_zero()) {
754+
if (x == 0.0) {
755755
// return -Inf and raise FE_DIVBYZERO.
756756
fputil::set_errno_if_required(ERANGE);
757757
fputil::raise_except_if_required(FE_DIVBYZERO);

0 commit comments

Comments
 (0)