Skip to content

Commit 2c2e050

Browse files
[clang][ThreadSafety] Skip past implicit cast in translateAttrExpr
Ignore `ImplicitCastExpr` when building `AttrExp` for capability attribute diagnostics. Fixes: #92118.
1 parent 7b4dfec commit 2c2e050

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/lib/Analysis/ThreadSafetyCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
197197
else if (const auto *UO = dyn_cast<UnaryOperator>(AttrExp)) {
198198
if (UO->getOpcode() == UO_LNot) {
199199
Neg = true;
200-
AttrExp = UO->getSubExpr();
200+
AttrExp = UO->getSubExpr()->IgnoreImplicit();
201201
}
202202
}
203203

clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5341,7 +5341,7 @@ void dispatch_log(const char *msg) __attribute__((requires_capability(!FlightCon
53415341
void dispatch_log2(const char *msg) __attribute__((requires_capability(Logger))) {}
53425342

53435343
void flight_control_entry(void) __attribute__((requires_capability(FlightControl))) {
5344-
dispatch_log("wrong"); /* expected-warning {{cannot call function 'dispatch_log' while mutex 'FlightControl' is held}} */
5344+
dispatch_log("wrong"); /* expected-warning {{cannot call function 'dispatch_log' while role 'FlightControl' is held}} */
53455345
dispatch_log2("also wrong"); /* expected-warning {{calling function 'dispatch_log2' requires holding role 'Logger' exclusively}} */
53465346
}
53475347

0 commit comments

Comments
 (0)