[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 7 10:16:34 PST 2017


aaron.ballman added a comment.

In https://reviews.llvm.org/D20693#639030, @hintonda wrote:

> Matthias, I think you make a good point.  While noexcept(expr) is valuable, noexcept(false) adds no value.  Therefore, I think we should do as you suggest, i.e.:
>
>   s/throw()/noexcept/
>   s/throw(something)//
>   
>
> Aaron, does this work for you?


I think it makes a reasonable option, but I think it should be off by default. Again, I think that's hostile towards users to remove an explicit exception specification entirely when there was an explicit dynamic exception specification written on the function signature. `noexcept(false)` is a stronger signal to anyone reading the signature than no exception specification whatsoever.

Be careful, though, not to break code by removing the exception specification. These two are *not* equivalent, for instance:

  struct S {
    ~S() noexcept(false);
    void operator delete(void *ptr) noexcept(false); 
  };
  
  struct T {
    ~T(); // Is actually noexcept(true) by default!
    void operator delete(void *ptr); // Is actually noexcept(true) by default!
  };


https://reviews.llvm.org/D20693





More information about the cfe-commits mailing list