[PATCH] D65889: [analyzer] CastValueChecker: Model castAs(), getAs()
Csaba Dabis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 09:02:33 PDT 2019
Charusso marked 4 inline comments as done.
Charusso added a comment.
This is a little-bit WIP as the symbol conjuring is very naive.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:111
+ QualType Ty = CE->getCallReturnType(C.getASTContext());
+ V = C.getSValBuilder().makeTruthVal(true, Ty);
+ }
----------------
That is a very lame way to conjure a symbol, but with a cool wrapper I believe this would be okay. Do we have a better way to create a non-null symbol?
================
Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:718
+ assert(ThisVal.isUnknownOrUndef() || ThisVal.getAs<Loc>() ||
+ ThisVal.getAs<nonloc::ConcreteInt>()->getValue().getExtValue() == 1);
return ThisVal;
----------------
This is the only necessary addition to make it usable.
================
Comment at: clang/test/Analysis/cast-value.cpp:113
+ // logic-warning at -1 {{TRUE}}
+ // logic-warning at -2 {{FALSE}}
+
----------------
I am not sure what is going on here,
================
Comment at: clang/test/Analysis/cast-value.cpp:131
+ // logic-warning at -1 {{TRUE}}
+ // logic-warning at -2 {{FALSE}}
+
----------------
and here.
================
Comment at: clang/test/Analysis/cast-value.cpp:193
+ // expected-warning at -2 {{Division by zero}}
+ // logic-warning at -3 {{Division by zero}}
+}
----------------
Known-value printing fails, but at least it is working well.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65889/new/
https://reviews.llvm.org/D65889
More information about the cfe-commits
mailing list