Skip to content

Commit 2975966

Browse files
author
git apple-llvm automerger
committed
Merge commit 'e07aef9dde4c' from llvm.org/main into next
2 parents b889143 + e07aef9 commit 2975966

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,11 +3103,6 @@ class Sema final : public SemaBase {
31033103
/// function without this attribute.
31043104
bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
31053105

3106-
/// Returns true if `From` is a function or pointer to a function without the
3107-
/// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
3108-
/// function with this attribute.
3109-
bool AddingCFIUncheckedCallee(QualType From, QualType To) const;
3110-
31113106
/// This function calls Action when it determines that E designates a
31123107
/// misaligned member due to the packed attribute. This is used to emit
31133108
/// local diagnostics like in reference binding.

clang/lib/Sema/SemaChecking.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12442,14 +12442,9 @@ static void DiagnoseMixedUnicodeImplicitConversion(Sema &S, const Type *Source,
1244212442
}
1244312443
}
1244412444

12445-
enum CFIUncheckedCalleeChange {
12446-
None,
12447-
Adding,
12448-
Discarding,
12449-
};
12450-
12451-
static CFIUncheckedCalleeChange AdjustingCFIUncheckedCallee(QualType From,
12452-
QualType To) {
12445+
bool Sema::DiscardingCFIUncheckedCallee(QualType From, QualType To) const {
12446+
From = Context.getCanonicalType(From);
12447+
To = Context.getCanonicalType(To);
1245312448
QualType MaybePointee = From->getPointeeType();
1245412449
if (!MaybePointee.isNull() && MaybePointee->getAs<FunctionType>())
1245512450
From = MaybePointee;
@@ -12461,25 +12456,10 @@ static CFIUncheckedCalleeChange AdjustingCFIUncheckedCallee(QualType From,
1246112456
if (const auto *ToFn = To->getAs<FunctionType>()) {
1246212457
if (FromFn->getCFIUncheckedCalleeAttr() &&
1246312458
!ToFn->getCFIUncheckedCalleeAttr())
12464-
return Discarding;
12465-
if (!FromFn->getCFIUncheckedCalleeAttr() &&
12466-
ToFn->getCFIUncheckedCalleeAttr())
12467-
return Adding;
12459+
return true;
1246812460
}
1246912461
}
12470-
return None;
12471-
}
12472-
12473-
bool Sema::DiscardingCFIUncheckedCallee(QualType From, QualType To) const {
12474-
From = Context.getCanonicalType(From);
12475-
To = Context.getCanonicalType(To);
12476-
return ::AdjustingCFIUncheckedCallee(From, To) == Discarding;
12477-
}
12478-
12479-
bool Sema::AddingCFIUncheckedCallee(QualType From, QualType To) const {
12480-
From = Context.getCanonicalType(From);
12481-
To = Context.getCanonicalType(To);
12482-
return ::AdjustingCFIUncheckedCallee(From, To) == Adding;
12462+
return false;
1248312463
}
1248412464

1248512465
void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,

clang/lib/Sema/SemaOverload.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,15 +2532,12 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
25322532

25332533
SCS.setToType(2, FromType);
25342534

2535-
// If we have not converted the argument type to the parameter type,
2536-
// this is a bad conversion sequence, unless we're resolving an overload in C.
2537-
//
2538-
// Permit conversions from a function without `cfi_unchecked_callee` to a
2539-
// function with `cfi_unchecked_callee`.
2540-
if (CanonFrom == CanonTo || S.AddingCFIUncheckedCallee(CanonFrom, CanonTo))
2535+
if (CanonFrom == CanonTo)
25412536
return true;
25422537

2543-
if ((S.getLangOpts().CPlusPlus || !InOverloadResolution))
2538+
// If we have not converted the argument type to the parameter type,
2539+
// this is a bad conversion sequence, unless we're resolving an overload in C.
2540+
if (S.getLangOpts().CPlusPlus || !InOverloadResolution)
25442541
return false;
25452542

25462543
ExprResult ER = ExprResult{From};

clang/test/Frontend/cfi-unchecked-callee-attribute.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void (*checked_ptr)(void) = unchecked; // expected-warning{{implicit conversion
99
void (CFI_UNCHECKED_CALLEE *unchecked_ptr)(void) = unchecked;
1010
void (CFI_UNCHECKED_CALLEE *from_normal)(void) = checked;
1111
void (CFI_UNCHECKED_CALLEE *c_no_function_decay)(void) = &unchecked;
12+
void (CFI_UNCHECKED_CALLEE __attribute__((noreturn)) *other_conflict)(void) = &checked; // expected-error{{cannot initialize a variable of type 'void (*)() __attribute__((noreturn)) __attribute__((cfi_unchecked_callee))' with an rvalue of type 'void (*)()'}}
1213
void (CFI_UNCHECKED_CALLEE *arr[10])(void);
1314
void (*cfi_elem)(void) = arr[1]; // expected-warning{{implicit conversion from 'void (*)() __attribute__((cfi_unchecked_callee))' to 'void (*)()' discards 'cfi_unchecked_callee' attribute}}
1415
void (CFI_UNCHECKED_CALLEE *cfi_unchecked_elem)(void) = arr[1];

0 commit comments

Comments
 (0)