[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 1 04:05:08 PDT 2017


NoQ added a comment.

I have just one comment and i think it'd be good to land.



================
Comment at: lib/StaticAnalyzer/Core/CheckerHelpers.cpp:104
+  ProgramStateManager &Mgr = State->getStateManager();
+  if (!LHSVal.getAs<NonLoc>() && LHSVal.getAs<Loc>()) {
+    LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),
----------------
Every `SVal` is either `Unknown` or `Undefined` or `NonLoc` or `Loc`, so the check after `&&` is unnecessary.

Also, i believe that it'd be more correct to look at the AST's `Expr::isLValue()` (in the caller function, where the expression is still available) instead of looking at the `SVal` type here. These approaches are significantly different: you need to discriminate between pointer-type rvalues and integer-type lvalues, both of which are represented as `Loc` values; in the former case, we shouldn't blindly get the binding. I've seen these incorrectly discriminated-between in multiple places in the analyzer, and i believe we should fix this eventually.


Repository:
  rL LLVM

https://reviews.llvm.org/D30295





More information about the cfe-commits mailing list