[PATCH] D64374: [analyzer] CastValueChecker: Model casts

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 20:37:27 PDT 2019


Charusso added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:61
+
+  return Ty.getAsString();
+}
----------------
NoQ wrote:
> Use after free! `QualType::getAsString()` returns a temporary `std::string`. You're returning a `StringRef` that outlives the string it refers to. The solution is usually to return the `std::string` by value.
> 
> //*summons @rnkovacs*//
> 
> Generally, i'd rather bail out on this branch. If we're seeing a dyn_cast of something that //isn't a class//, we're already doing something wrong.
Well, at least it does not crash. Thanks! I like that general return which we could evolve further. It is the same story like `Assuming...`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64374/new/

https://reviews.llvm.org/D64374





More information about the cfe-commits mailing list