[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

Dominic Chen via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 20:32:50 PDT 2016


ddcc added a comment.

To summarize, here is a list of changes:

- General
  - Fixed some issues with formatting (`clang-format`)
  - Fixed inconsistent capitalization following camel case style guidelines

- `ConstraintManager.h`
  - Renamed `assumeWithinInclusiveRange*()` to `assumeInclusiveRange*()`, since the range is not necessarily inclusive unless `Assumption` is true, to match `assume()`

- `RangedConstraintManager.h` (inherits `SimpleConstraintManager`)
  - Moved `assumeSym*` and `canReasonAbout()` from `SimpleConstraintManager` to here
  - Renamed `assumeSymbolWithinInclusiveRange`/`assumeSymbolOutOfInclusiveRange` to `assumeSymWithinInclusiveRange`/`assumeSymOutsideInclusiveRange` to match the above, and moved to here
  - This is now inherited by `RangeConstraintManager`, and essentially provides the current interface in `SimpleConstraintManager`

- `SimpleConstraintManager.h` (inherits `ConstraintManager`)
  - Implemented a new interface that internally converts the `DefinedSVal` in `assume(...)` from `ConstraintManager.h` to `NonLoc` to `SymbolRef`. Subclasses only need to override `ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumption)`
  - For inclusive ranges, implemented a new interface that internally converts from `NonLoc` to `SymbolRef`. Subclasses only need to override `ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange)`
  - Implemented a new interface that internally handles expressions that fail `canReasonAbout()` by adding them directly to the constraint manager state. Subclasses only need to expose `ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym, BinaryOperator::Opcode op, const llvm::APSInt &Int)`

- `RangeConstraintManager.cpp`
  - Minor optimization to avoid updating the state if nothing is pruned in `removeDeadBindings()`


https://reviews.llvm.org/D26061





More information about the cfe-commits mailing list