[clang] [clang][ThreadSafety] Check trylock function success and return types (PR #95290)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 30 16:32:09 PDT 2024
================
@@ -1359,17 +1361,18 @@ void ThreadSafetyAnalyzer::getMutexIDs(CapExprSet &Mtxs, AttrType *Attr,
const Expr *Exp, const NamedDecl *D,
const CFGBlock *PredBlock,
const CFGBlock *CurrBlock,
- Expr *BrE, bool Neg) {
- // Find out which branch has the lock
- bool branch = false;
- if (const auto *BLE = dyn_cast_or_null<CXXBoolLiteralExpr>(BrE))
- branch = BLE->getValue();
- else if (const auto *ILE = dyn_cast_or_null<IntegerLiteral>(BrE))
- branch = ILE->getValue().getBoolValue();
----------------
aaronpuchert wrote:
I kind of prefer the old code here. Regardless of what we accept as return type, we only care about the return type converted to `bool`, so other values don't really make sense as of now. (We need the `IntegerLiteral` for C.)
What we should document is that this isn't an equality comparison, but a comparison after conversion to `bool`. (Or whatever the equivalent for C is. Basically what is allowed in an `if` condition.)
Should we support integer/enumeration values properly, that would of course change the picture. In that case we can allow enumerators in the attribute, and the return type must be explicitly (?) convertible to type of the attribute.
https://github.com/llvm/llvm-project/pull/95290
More information about the cfe-commits
mailing list