Skip to content

Commit 795a1cc

Browse files
Merge branch 'main' into drop-cmp0116-old
2 parents cc5af23 + e33aec8 commit 795a1cc

File tree

294 files changed

+15929
-935
lines changed

Some content is hidden

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

294 files changed

+15929
-935
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/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
852852
if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
853853
Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
854854
else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking)
855-
Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe);
855+
Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeBlocking);
856856
}
857857

858858
// Apply fuzzing attribute to the function.

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

clang/test/CodeGen/rtsan_attribute_inserted.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ float process(float *a) [[clang::nonblocking]] { return *a; }
88
int spinlock(int *a) [[clang::blocking]] { return *a; }
99
// CHECK: @spinlock{{.*}} #1 {
1010
// CHECK: attributes #1 = {
11-
// CHECK-SAME: {{.*sanitize_realtime_unsafe .*}}
11+
// CHECK-SAME: {{.*sanitize_realtime_blocking .*}}

clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ int spinlock(int *a) [[clang::blocking]] { return *a; }
55

66
// Without the -fsanitize=realtime flag, we shouldn't attach the attributes.
77
// CHECK-NOT: {{.*sanitize_realtime .*}}
8-
// CHECK-NOT: {{.*sanitize_realtime_unsafe .*}}
8+
// CHECK-NOT: {{.*sanitize_realtime_blocking .*}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: rm -f a.c b.c
2+
3+
// RUN: not clang-format a.c b.c 2>&1 | FileCheck %s
4+
// CHECK: a.c:
5+
// CHECK-NEXT: b.c:

clang/test/Modules/no-external-type-id.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export module b;
2323
import a;
2424
export int b();
2525

26-
// CHECK: <DECL_FUNCTION {{.*}} op8=4112
26+
// CHECK: <DECL_FUNCTION {{.*}} op8=4120
2727
// CHECK: <TYPE_FUNCTION_PROTO
2828

2929
//--- a.v1.cppm

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
410410
const bool IsSTDIN = FileName == "-";
411411
if (!OutputXML && Inplace && IsSTDIN) {
412412
errs() << "error: cannot use -i when reading from stdin.\n";
413-
return false;
413+
return true;
414414
}
415415
// On Windows, overwriting a file with an open file mapping doesn't work,
416416
// so read the whole file into memory when formatting in-place.
@@ -419,7 +419,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
419419
? MemoryBuffer::getFileAsStream(FileName)
420420
: MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true);
421421
if (std::error_code EC = CodeOrErr.getError()) {
422-
errs() << EC.message() << "\n";
422+
errs() << FileName << ": " << EC.message() << "\n";
423423
return true;
424424
}
425425
std::unique_ptr<llvm::MemoryBuffer> Code = std::move(CodeOrErr.get());

compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ TEST(TestRtsan, ThrowingAnExceptionDiesWhenRealtime) {
204204

205205
TEST(TestRtsan, DoesNotDieIfTurnedOff) {
206206
std::mutex mutex;
207-
auto RealtimeUnsafeFunc = [&]() {
207+
auto RealtimeBlockingFunc = [&]() {
208208
__rtsan_disable();
209209
mutex.lock();
210210
mutex.unlock();
211211
__rtsan_enable();
212212
};
213-
RealtimeInvoke(RealtimeUnsafeFunc);
213+
RealtimeInvoke(RealtimeBlockingFunc);
214214
}

0 commit comments

Comments
 (0)