[PATCH] D27918: [analyzer] OStreamChecker

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 03:54:28 PST 2017


NoQ added a comment.

Hello,

Thanks for the patch, and for the impressing amount of work you put into this. Because the patch is huge, so it's going to take some time for somebody to understand how everything works.

I'd probably like to learn a bit more about the motivation behind the checker. You must be working on a project that uses a lot of `std` streams, and the checker seems to verify a particular coding guideline you're following (revert all changes to the stream locally). I wonder how universally useful this guideline is. For instance, there might exist a project that enjoys writing code like this:

  void set_my_favorite_format_specifiers() {
    std::cout << std::setprecision(12) << std::hex; // warning?
  }
  
  void revert_my_favorite_format_specifiers() {
    std::cout << std::setprecision(6) << std::dec;
  }
  
  void foo() {
    set_my_favorite_format_specifiers();
    std::cout << 100 << std::endl;
    revert_my_favorite_format_specifiers();
  }

Do you expect such pattern to be common? If we enable the checker by default, would positives on such code cause annoyance, and would there be a way to suppress them?


https://reviews.llvm.org/D27918





More information about the cfe-commits mailing list