Sema::CheckCastAlign currently ignores the aligned attribute attached to the declared variables, which causes clang to issue spurious warnings. This patch fixes the bug.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Sema/SemaChecking.cpp | ||
---|---|---|
10304 ↗ | (On Diff #78300) | NIT, but I think you don't need the extra variable and the if (SE) below if you extract the code inside if (SE) { into a static function that returns SrcAlign. Then the if/else below can be rewritten like: if (auto *CE = dyn_cast<CastExpr>(Op)) { if (CE->getCastKind() == CK_ArrayToPointerDecay) SrcAlign = newFunction(CE->getSubExpr(), Context); } else if (auto *UO = dyn_cast<UnaryOperator>(Op)) { if (UO->getOpcode() == UO_AddrOf) SrcAlign = newFunction(UO->getSubExpr(), Context); } |
10315 ↗ | (On Diff #78300) | You can use const auto here. |
10317 ↗ | (On Diff #78300) | Same here. |
lib/Sema/SemaChecking.cpp | ||
---|---|---|
10270 ↗ | (On Diff #78399) | I'm not sure if you can, since I don't really know CharUnits, but I think you should just return it instead of passing it as a parameter if it's a POD type (if you will end up doing that you should rename this function as well). |
10270 ↗ | (On Diff #78399) | Please add a brief doc comment as well. |