[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 17:29:40 PDT 2024


================
@@ -4806,6 +4806,34 @@ getOverflowPatternBinOp(const BinaryOperator *E) {
   return {};
 }
 
+/// Compute and set the OverflowPatternExclusion bit based on whether the
----------------
vitalybuka wrote:

Maybe this way?
```
static void computeOverflowPatternExclusion(const ASTContext &Ctx,
                                            const BinaryOperator *E) {
  std::optional<BinaryOperator *> Result = getOverflowPatternBinOp(E);
  if (!Result.has_value())
    return;
  QualType AdditionResultType = Result.value()->getType();

  bool AddSignedOverflowTest = Ctx.getLangOpts().isOverflowPatternExcluded(
      LangOptions::OverflowPatternExclusionKind::AddSignedOverflowTest) &&
     AdditionResultType->isSignedIntegerType();
  bool AddUnsignedOverflowTest = Ctx.getLangOpts().isOverflowPatternExcluded(
      LangOptions::OverflowPatternExclusionKind::AddUnsignedOverflowTest)
      && AdditionResultType->isUnsignedIntegerType();

  if (AddSignedOverflowTest || AddUnsignedOverflowTest)
     Result.value()->setExcludedOverflowPattern(true);
}
```


https://github.com/llvm/llvm-project/pull/105709


More information about the cfe-commits mailing list